-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintrospect.yml
280 lines (252 loc) · 11.8 KB
/
introspect.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
- name: Auto generate instackenv.json for virt
import_playbook: "{{ overcloud_virt | default('hypervisor.yml') }}"
tags:
- hypervisor
- ironic
- instack
when: "'hypervisor' in groups"
- name: Auto generate instackenv.json for ovb
import_playbook: "{{ overcloud_ovb | default('ovb.yml') }}"
tags:
- ironic
- instack
- ovb
when: "'bmc' in groups"
- name: Introspect our machines
hosts: undercloud
gather_facts: no
any_errors_fatal: true
vars:
undercloud_provision_cidr: "{{ ansible_br_ctlplane.ipv4.network }}/{{ ansible_br_ctlplane.ipv4.netmask }}"
instack_input: "{{ (install.instackenv|default({})).file | default('') }}"
ironic_cli: "{{ (install.version|default(undercloud_version)|openstack_release < 14)|ternary('ironic node-list','openstack baremetal node list') }}"
tasks:
- block:
- name: Get flavor list for UEFI updating
shell: |
set -eo pipefail
source ~/stackrc
openstack flavor list -c Name -f value
register: flavor_list
- name: Update flavors when UEFI boot mode is used
shell: |
set -eo pipefail
source ~/stackrc
openstack flavor set {{ item }} \
--property capabilities:boot_option='local' \
--property capabilities:profile='{{ item }}' \
--property capabilities:boot_mode=uefi
with_items: "{{ flavor_list.stdout_lines }}"
when:
- install.boot.mode == 'uefi'
- install.version|default(undercloud_version) |openstack_release > 9
tags:
- ironic
- skip_ansible_lint
- name: inject instackenv file if provided by the user
tags: ironic
copy:
src: "{{ instack_input }}"
dest: "~/{{ instack_input | basename }}"
when: not instack_input == ''
register: inject_instackenv
- name: verify that instackenv json file exists
stat:
path: "~/{{ (instack_input or 'instackenv.json') | basename }}"
register: instack_file_path
tags: ironic
- name: fail if instackenv file is missing
fail:
msg: instackenv file is missing
when: not instack_file_path.stat.exists
tags: ironic
# FIXME(psedlak): netboot boot for non-virthost nodes?
# Not confirmed atm, but there is likely change needed (for 13+?),
# to in place of --instance-boot-option local,
# use netboot instead of local, when nodes are not local vms?
# That would also mean to instead of passing instance-boot-option to
# import, to instead after import do loop over all nodes uuids,
# and based on if they are virthost or not, set corresponding value.
# Workaround for bug in osp13, bz 1714205
- name: get the python-tripleoclient-9-2-7-9 RPM
get_url:
url: "https://url.corp.redhat.com/python-tripleoclient-9-2-7-9-el7ost-noarch-rpm"
dest: "/tmp/python-tripleoclient-9-2-7-9-el7ost-noarch.rpm"
force: yes
validate_certs: no
become: yes
when: "install.version|openstack_release == 13"
- name: update python-tripleoclient RPM for osp13
package:
name: /tmp/python-tripleoclient-9-2-7-9-el7ost-noarch.rpm
state: present
become: yes
when: "install.version|openstack_release == 13"
- name: register hosts to instack and configure boot
shell: |
set -eo pipefail
source ~/stackrc
{% if install.version|default(undercloud_version) |openstack_release < 13 %}
openstack baremetal import --json {{ instack_file_path.stat.path }}
openstack baremetal configure boot
{% else %}
openstack overcloud node import --instance-boot-option=local {{ instack_file_path.stat.path }}
{% endif %}
tags:
- ironic
# FIXME(yfried) use "--os-cloud" instead of "source rc" and replace with command
- skip_ansible_lint
- name: set the root device for baremetal nodes (with size hint)
shell: |
source ~/stackrc
NODE_UUID=$({{ ironic_cli }} | awk '/{{ item.name | default(item) }}/ {print $2}' )
ironic node-update ${NODE_UUID} add properties/root_device='{"size": {{ hostvars[item].disk }} }'
#TODO(skatlapa): Check if Ironic CLI BZ#1602066 affects baremetal update command
with_items: "{{ groups['overcloud_nodes'] | default([])}}"
when: "'bmc' in groups"
- name: set root-disk override fact
tags:
- root_device
vars:
ceph_default_disk_name: '/dev/vda'
default_disk_override:
- node: "ceph"
hint: "name"
hintvalue: "{{ ceph_default_disk_name }}"
ceph_defaults: "{{ ((install.version|default(undercloud_version)|openstack_release > 9) and
'ceph' in groups and
'hypervisor' in groups)|ternary(default_disk_override, []) }}"
set_fact:
root_disk: "{{ ceph_defaults|union(install.get('root',{}).get('disk',{}).get('override', [])) }}"
- name: configure root-disk for multi-disk nodes
shell: |
set -exo pipefail
REGEX=".*-[0-9]+$"
source ~/stackrc
{% for node in item.node.split(':') %}
if [[ "{{ node }}" =~ $REGEX ]]; then
{% if install.version|default(undercloud_version) |openstack_release > 9 %}
openstack baremetal node set \
--property root_device='{"{{item.hint}}":"{{item.hintvalue}}"}' {{ node }}
{% else %}
ironic node-list|awk '/{{ node }}/ {print $2}'| \
xargs -I{} ironic node-update {} add properties/root_device='{"{{item.hint}}":"{{item.hintvalue}}"}'
{% endif %}
else
{% if install.version|default(undercloud_version) |openstack_release > 9 %}
openstack baremetal node list|awk '/{{ node }}/ {print $2}'| \
xargs -I{} openstack baremetal node set {} --property root_device='{"{{item.hint}}":"{{item.hintvalue}}"}'
{% else %}
ironic node-list|awk '/{{ node }}/ {print $2}'| \
xargs -I{} ironic node-update {} add properties/root_device='{"{{item.hint}}":"{{item.hintvalue}}"}'
{% endif %}
fi
{% endfor %}
tags:
- skip_ansible_lint
- root_device
with_items: "{{ root_disk }}"
when: root_disk is defined
- name: set deploy_interface option to direct
shell: |
source ~/stackrc
NODE_UUID=$({{ ironic_cli }} | awk '/{{ item.name | default(item) }}/ {print $2}' )
openstack baremetal node set --deploy-interface direct ${NODE_UUID}
with_items: "{{ groups['overcloud_nodes'] | default([])}}"
when:
- install.image_direct_deploy != 'iscsi'
- install.version|default(undercloud_version) | openstack_release >= 13
# Because introspection is faulty and tricky especially on baremetals
# we need to check multiple times if any failure occured. Reasonable time
# for this process to take is < 10 minutes no matter how many nodes for baremetals.
# Virtual setups don't suffer from long timeouts caused by delays in boot
# process, BIOS timeouts and errors in firmware so they are covered by such timeout
# seamlessly. This must be async task because we need to enforce explicit timeout
# for this process, otherwise timeout is controlled by ironic and seriously long
# (usually one must wait for 1 hour if any failure on any node occurs).
- name: start node introspection
shell: |
source ~/stackrc
{% if install.version|default(undercloud_version) |openstack_release < 13 %}
openstack baremetal introspection bulk start
{% else %}
openstack overcloud node introspect --provide --all-manageable
{% endif %}
tags:
# FIXME(yfried) use "--os-cloud" instead of "source rc" and replace with command
- skip_ansible_lint
register: bulk_intro_result
poll: 50
async: 1000
retries: 20
delay: 90
ignore_errors: yes
# Async tasks in Ansible don't have rc defined if they failed (for some reason) which makes registered
# variable different for various outcomes and just using "result" key is not possible here.
# Following fact will construct properly introspection result properly from possibly
# different statutes presented by output of async task.
- set_fact:
bulk_intro_ok: "{{ true if bulk_intro_result.rc is defined and bulk_intro_result.rc == 0 else false }}"
# If bulk introspection failed, play introspection_recovery playbook which runs node-by-node introspection
# and also helps with debugging and recovery.
- name: Recover from errors during bulk introspection
include_tasks: tasks/introspection_recovery.yml
when: not bulk_intro_ok
# when we need to use vbmc for OSP10 we have an issue [1] with pxe_impi driver
# and the fix [2] for that issue cannot be backported to the OSP10:
# [1] https://bugzilla.redhat.com/show_bug.cgi?id=1373468
# [2] https://github.com/openstack/ironic-inspector/commit/0ce5cdb7c8344e981a919aab136c4c2eba79d4a2
- name: switch pxe_ssh to the pxe_impi
shell: |
source ~/stackrc
NODE_UUID=$({{ ironic_cli }} | grep -w {{ item.key }} | awk '{print $2}' )
openstack baremetal node set $NODE_UUID \
--driver pxe_ipmitool \
--driver-info ipmi_username={{ install.vbmc.username }} \
--driver-info ipmi_address=::ffff:{{ vbmc_management_address }} \
--driver-info ipmi_password={{ install.vbmc.password }} \
--driver-info ipmi_port={{ item.value }}
with_dict: "{{ vbmc_ports }}"
when:
- install.vbmc.force
- install.version|default(undercloud_version) | openstack_release == 10
- vbmc_ports is defined
#
# With baremetal deployments hosts from custom instackenv are missing from inventory
# Add them to Ansible's inventory for future use
#
- name: Add introspected BMs to inventory
hosts: localhost
tags: add_bms_to_inventory
gather_facts: no
any_errors_fatal: true
vars:
instack_input: "{{ (install.instackenv|default({})).file | default('') }}"
tasks:
- block:
- name: read instackenv file
command: cat "~/{{ (instack_input or 'instackenv.json') | basename }}"
register: overcloud_hosts_facts
delegate_to: "{{ groups['undercloud']|first }}"
- name: set overcloud_facts
set_fact:
overcloud_facts: "{{ overcloud_hosts_facts.stdout | from_json }}"
- name: add bm nodes to inventory
add_host:
hostname: "{{ item.name }}"
groups:
- overcloud_nodes
- openstack_nodes
- "{{ item.name.split('-')[0] }}"
ansible_user: root
when:
- item.name|default('') != ''
- item.name not in groups.get('all',[])
with_items: "{{ overcloud_facts.nodes }}"
register: update_inventory
- include_role:
name: inventory-update
vars:
inventory_file_name: 'hosts-prov'
with_items: "{{ update_inventory.results }}"
when: ('hypervisor' not in groups and 'bmc' not in groups) or install.get('hybrid', omit) is defined