5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Block traffic during nodes power on/off so that possible old deployment
18 # clients cannot connect new deployment services (like mysql) and ruin
20 - name: Block traffic on infra_internal
26 in_interface: "{{ networking['infra_internal']['interface'] }}"
28 - installation_phase == "provisioning-started"
30 - name: Power off nodes
32 OS_AUTH_TOKEN: "fake-token"
33 IRONIC_URL: "{{ ironic_service_adminurl }}"
34 command: "/usr/bin/ironic node-set-power-state {{item.uuid}} off"
35 with_items: "{{ baremetal_ironic_nodes_ids }}"
38 - installation_phase == "provisioning-started"
42 label: "{{ item.name }}"
44 - name: Power off nodes
45 command: "openstack --os-cloud default baremetal node power off {{item.uuid}}"
46 with_items: "{{ baremetal_ironic_nodes_ids }}"
49 - installation_phase != "provisioning-started"
53 label: "{{ item.name }}"
55 - name: Ensure nodes are powered off
57 OS_AUTH_TOKEN: "fake-token"
58 IRONIC_URL: "{{ ironic_service_adminurl }}"
62 ironic_url: "{{ ironic_service_adminurl }}"
63 nodes_details: "{{ baremetal_ironic_nodes_ids }}"
64 power_state: 'power off'
65 until: power_pending_list | length == 0
69 - not virtual_env and baremetal_ironic_nodes_ids | length > 0
70 - installation_phase == "provisioning-started"
73 - name: Ensure nodes are powered off
77 ironic_url: "{{ ironic_service_adminurl }}"
78 nodes_details: "{{ baremetal_ironic_nodes_ids }}"
79 power_state: 'power off'
80 endpoint_type: internal
81 until: power_pending_list | length == 0
85 - not virtual_env and baremetal_ironic_nodes_ids | length > 0
86 - installation_phase != "provisioning-started"
89 # Sleep to make sure power is off
90 - name: Sleep for 15 seconds
93 when: not virtual_env and baremetal_ironic_nodes_ids | length > 0
95 - name: Create config-drive directories for all nodes
97 path: "/var/lib/ironic/confdrive/{{item.name}}/openstack/latest/"
101 with_items: "{{ baremetal_ironic_nodes_ids }}"
103 label: "{{ item.name }}"
105 - name: Generate config-drive files
107 src: "{{ item[1].src }}"
108 dest: "/var/lib/ironic/confdrive/{{item[0].name}}/openstack/latest/{{ item[1].dest }}"
112 config_type: "{{ item[1].config_type }}"
114 - "{{ baremetal_ironic_nodes_ids }}"
115 - "{{ config_drive_templates }}"
117 label: "{{ item[0].name }}"
119 - name: Stat config-drive files to check if they exists
121 path: "/var/lib/ironic/confdrive/{{ item.name }}.base64"
122 register: confdrive_stat
123 with_items: "{{ baremetal_ironic_nodes_ids }}"
125 - name: Prepare Config-drive ISO file
128 genisoimage -o /var/lib/ironic/confdrive/{{ item.item.name }}.iso -ldots -allow-lowercase -allow-multidot -l -publisher 'ironicclient-configdrive 0.1' -quiet -J -r -V config-2 /var/lib/ironic/confdrive/{{ item.item.name }}
130 gzip /var/lib/ironic/confdrive/{{ item.item.name }}.iso
131 # Encode it to base64
132 base64 -w 0 /var/lib/ironic/confdrive/{{ item.item.name }}.iso.gz > /var/lib/ironic/confdrive/{{ item.item.name }}.base64
133 when: not item.stat.exists
134 with_items: "{{confdrive_stat.results}}"
136 - name: Remove os_net_config temp files
138 dest: "/tmp/{{item.name}}_config.yaml"
140 with_items: "{{ baremetal_ironic_nodes }}"
142 label: "{{ item.name }}"
144 - name: Calculate md5sum of Golden image
146 path: "/opt/images/guest-image.img"
148 register: golden_img_md5sum
149 when: baremetal_ironic_nodes_ids | length > 0
151 - name: Enable traffic on infra_internal
156 in_interface: "{{ networking['infra_internal']['interface'] }}"
158 - installation_phase == "provisioning-started"
160 - name: Configure Baremetal deployment
162 OS_AUTH_TOKEN: "fake-token"
163 IRONIC_URL: "{{ ironic_service_adminurl }}"
167 ironic_url: "{{ ironic_service_adminurl }}"
168 uuid: "{{item.uuid}}"
175 image_source: "http://{{ansible_host}}:{{golden_image_http_port}}/guest-image.img"
176 image_checksum: "{{golden_img_md5sum.stat.md5}}"
177 with_items: "{{ baremetal_ironic_nodes_ids }}"
179 label: "{{ item.name }}"
181 - installation_phase == "provisioning-started"
183 - name: Configure Baremetal deployment
186 endpoint_type: internal
188 uuid: "{{item.uuid}}"
195 image_source: "http://{{ansible_host}}:{{golden_image_http_port}}/guest-image.img"
196 image_checksum: "{{golden_img_md5sum.stat.md5}}"
197 with_items: "{{ baremetal_ironic_nodes_ids }}"
199 label: "{{ item.name }}"
201 - installation_phase != "provisioning-started"
203 - name: Start Baremetal deployment
205 OS_AUTH_TOKEN: "fake-token"
206 IRONIC_URL: "{{ ironic_service_adminurl }}"
210 ironic_url: "{{ ironic_service_adminurl }}"
213 config_drive: "{{lookup('file', '/var/lib/ironic/confdrive/{{ item.name }}.base64')}}"
214 uuid: "{{item.uuid}}"
217 image_source: "http://{{ansible_host}}:{{golden_image_http_port}}/guest-image.img"
218 image_checksum: "{{golden_img_md5sum.stat.md5}}"
219 with_items: "{{ baremetal_ironic_nodes_ids }}"
221 label: "{{ item.name }}"
223 - installation_phase == "provisioning-started"
225 - name: Start Baremetal deployment
228 endpoint_type: internal
232 config_drive: "{{lookup('file', '/var/lib/ironic/confdrive/{{ item.name }}.base64')}}"
233 uuid: "{{item.uuid}}"
236 image_source: "http://{{ansible_host}}:{{golden_image_http_port}}/guest-image.img"
237 image_checksum: "{{golden_img_md5sum.stat.md5}}"
238 with_items: "{{ baremetal_ironic_nodes_ids }}"
240 label: "{{ item.name }}"
242 - installation_phase != "provisioning-started"
244 - name: Verify node provisioning state. Waiting for 60mins max.
246 OS_AUTH_TOKEN: "fake-token"
247 IRONIC_URL: "{{ ironic_service_adminurl }}"
248 os_node_provision_check:
251 ironic_url: "{{ ironic_service_adminurl }}"
252 nodes_details: "{{baremetal_ironic_nodes_ids}}"
253 register: baremetal_ironic_node_provisionin_results
254 until: provision_pending_list | length == 0
258 - installation_phase == "provisioning-started"
260 - name: Checking for any deployment failures
262 msg: "One or more nodes failed in deployment. {{baremetal_ironic_node_provisionin_results['ansible_facts']['provision_failed_list'] }}"
264 - installation_phase == "provisioning-started"
265 - baremetal_ironic_node_provisionin_results['ansible_facts']['provision_failed_list'] | length > 0
267 - name: Verify node provisioning state. Waiting for 60mins max.
268 os_node_provision_check:
270 endpoint_type: internal
272 nodes_details: "{{baremetal_ironic_nodes_ids}}"
273 register: baremetal_ironic_node_provisionin_results
274 until: provision_pending_list | length == 0
278 - installation_phase != "provisioning-started"
280 - name: Checking for any deployment failures
282 msg: "One or more nodes failed in deployment. {{baremetal_ironic_node_provisionin_results['ansible_facts']['provision_failed_list'] }}"
284 - installation_phase != "provisioning-started"
285 - baremetal_ironic_node_provisionin_results['ansible_facts']['provision_failed_list'] | length > 0
287 # JanneS: until looping is a fix for the problem in wait_for module; it does not catch socket error in recv if peer closes the connection.
288 - name: Verify remote node ssh ports active. Waiting for 60mins max.
290 host: "{{ item.node_ip[0] }}"
292 search_regex: OpenSSH
295 register: remote_success
296 until: remote_success | success
298 with_items: "{{net_conn_details}}"
300 - name: Wait for remote node ssh login. Waiting for 10mins max.
301 become: "{{ ansible_env.SUDO_USER }}"
302 local_action: shell ssh -oBatchMode=yes -4 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null {{ item.node_ip[0] }} "echo success"
303 register: user_enabled
304 with_items: "{{net_conn_details}}"
305 until: user_enabled.stdout.find("success") != -1
309 - name: Set Ironic maintenance mode to all nodes.
312 endpoint_type: internal
314 uuid: "{{item.name}}"
317 with_items: "{{ baremetal_ironic_nodes }}"
319 label: "{{ item.name }}"
321 - installation_phase != "provisioning-started"
323 - name: Set Ironic maintenance mode to all nodes.
325 OS_AUTH_TOKEN: "fake-token"
326 IRONIC_URL: "{{ ironic_service_adminurl }}"
330 ironic_url: "{{ ironic_service_adminurl }}"
331 uuid: "{{item.name}}"
334 with_items: "{{ baremetal_ironic_nodes }}"
336 label: "{{ item.name }}"
338 - installation_phase == "provisioning-started"