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"
32 - name: Power off nodes
34 OS_AUTH_TOKEN: "fake-token"
35 IRONIC_URL: "{{ ironic_service_adminurl }}"
36 command: "/usr/bin/ironic node-set-power-state {{baremetal_ironic_node_id.uuid}} off"
39 - installation_phase == "provisioning-started"
43 - name: Power off nodes
44 command: "openstack --os-cloud default baremetal node power off {{baremetal_ironic_node_id.uuid}}"
47 - installation_phase != "provisioning-started"
51 - name: Ensure nodes are powered off
53 OS_AUTH_TOKEN: "fake-token"
54 IRONIC_URL: "{{ ironic_service_adminurl }}"
58 ironic_url: "{{ ironic_service_adminurl }}"
60 - "{{ baremetal_ironic_node_id }}"
61 power_state: 'power off'
62 until: power_pending_list | length == 0
67 - installation_phase == "provisioning-started"
70 - name: Ensure nodes are powered off
74 ironic_url: "{{ ironic_service_adminurl }}"
76 - "{{ baremetal_ironic_node_id }}"
77 power_state: 'power off'
78 endpoint_type: internal
79 until: power_pending_list | length == 0
84 - installation_phase != "provisioning-started"
87 # Sleep to make sure power is off
88 - name: Sleep for 15 seconds
93 - name: Create config-drive directories for all nodes
95 path: "/var/lib/ironic/confdrive/{{baremetal_ironic_node_id.name}}/openstack/latest/"
101 - name: Generate config-drive files
104 dest: "/var/lib/ironic/confdrive/{{baremetal_ironic_node_id.name}}/openstack/latest/{{item.dest}}"
108 config_type: "{{item.config_type}}"
110 - "{{ config_drive_templates }}"
112 - name: Stat config-drive files to check if they exists
114 path: "/var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}.base64"
115 register: confdrive_stat
117 - name: Prepare Config-drive ISO file
120 genisoimage -o /var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}.iso -ldots -allow-lowercase -allow-multidot -l -publisher 'ironicclient-configdrive 0.1' -quiet -J -r -V config-2 /var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}
122 gzip /var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}.iso
123 # Encode it to base64
124 base64 -w 0 /var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}.iso.gz > /var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}.base64
125 chown ironic:ironic /var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}.iso.gz
126 chown ironic:ironic /var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}.base64
127 chmod o+r /var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}.iso.gz
128 chmod o+r /var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}.base64
129 when: not confdrive_stat.stat.exists
131 - name: Remove os_net_config temp files
133 dest: "/tmp/{{baremetal_ironic_node_id.name}}_config.yaml"
136 - name: Calculate md5sum of Golden image
138 path: "/opt/images/guest-image.img"
140 register: golden_img_md5sum
143 - name: Enable traffic on infra_internal
148 in_interface: "{{ networking['infra_internal']['interface'] }}"
150 - installation_phase == "provisioning-started"
155 initiator_host: "{{ lookup('file', '/etc/hostname') }}"
158 initiator_host_ip: "{{ hostvars[initiator_host]['networking']['infra_internal']['ip'] }}"
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: "{{baremetal_ironic_node_id.uuid}}"
175 image_source: "http://{{initiator_host_ip}}:{{golden_image_http_port}}/guest-image.img"
176 image_checksum: "{{golden_img_md5sum.stat.md5}}"
178 - installation_phase == "provisioning-started"
180 - name: Configure Baremetal deployment
183 endpoint_type: internal
185 uuid: "{{baremetal_ironic_node_id.uuid}}"
192 image_source: "http://{{initiator_host_ip}}:{{golden_image_http_port}}/guest-image.img"
193 image_checksum: "{{golden_img_md5sum.stat.md5}}"
195 - installation_phase != "provisioning-started"
197 - name: Start Baremetal deployment
199 OS_AUTH_TOKEN: "fake-token"
200 IRONIC_URL: "{{ ironic_service_adminurl }}"
204 ironic_url: "{{ ironic_service_adminurl }}"
207 config_drive: "{{lookup('file', '/var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}.base64')}}"
208 uuid: "{{baremetal_ironic_node_id.uuid}}"
211 image_source: "http://{{initiator_host_ip}}:{{golden_image_http_port}}/guest-image.img"
212 image_checksum: "{{golden_img_md5sum.stat.md5}}"
214 - installation_phase == "provisioning-started"
216 - name: Start Baremetal deployment
219 endpoint_type: internal
223 config_drive: "{{lookup('file', '/var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}.base64')}}"
224 uuid: "{{baremetal_ironic_node_id.uuid}}"
227 image_source: "http://{{initiator_host_ip}}:{{golden_image_http_port}}/guest-image.img"
228 image_checksum: "{{golden_img_md5sum.stat.md5}}"
230 - installation_phase != "provisioning-started"
232 - name: Verify node provisioning state. Waiting for 60mins max.
234 OS_AUTH_TOKEN: "fake-token"
235 IRONIC_URL: "{{ ironic_service_adminurl }}"
236 os_node_provision_check:
239 ironic_url: "{{ ironic_service_adminurl }}"
241 - "{{baremetal_ironic_node_id}}"
242 register: baremetal_ironic_node_provisionin_results
243 until: provision_pending_list | length == 0
247 - installation_phase == "provisioning-started"
249 - name: Checking for any deployment failures
251 msg: "One or more nodes failed in deployment. {{baremetal_ironic_node_provisionin_results['ansible_facts']['provision_failed_list'] }}"
253 - installation_phase == "provisioning-started"
254 - baremetal_ironic_node_provisionin_results['ansible_facts']['provision_failed_list'] | length > 0
256 - name: Verify node provisioning state. Waiting for 60mins max.
257 os_node_provision_check:
259 endpoint_type: internal
262 - "{{baremetal_ironic_node_id}}"
263 register: baremetal_ironic_node_provisionin_results
264 until: provision_pending_list | length == 0
268 - installation_phase != "provisioning-started"
270 - name: Checking for any deployment failures
272 msg: "One or more nodes failed in deployment. {{baremetal_ironic_node_provisionin_results['ansible_facts']['provision_failed_list'] }}"
274 - installation_phase != "provisioning-started"
275 - baremetal_ironic_node_provisionin_results['ansible_facts']['provision_failed_list'] | length > 0
278 net_conn_details: "{{ ironic_node_details.driver_info.power.os_net_config | json_query('network_config[*].addresses[0].ip_netmask') | ipaddr('address') }}"
279 when: ironic_node_details.driver_info.power.os_net_config.network_config[0].type != 'ovs_bridge'
283 net_conn_details: "{{ ironic_node_details.driver_info.power.os_net_config | json_query('network_config[*].members[*].addresses[0].ip_netmask')|first | ipaddr('address') }}"
284 when: ironic_node_details.driver_info.power.os_net_config.network_config[0].type == 'ovs_bridge'
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: "{{ net_conn_details[0] }}"
292 search_regex: OpenSSH
295 register: remote_success
296 until: remote_success | success
299 - name: Wait for remote node ssh login. Waiting for 10mins max.
300 become: "{{ users.admin_user_name }}"
301 local_action: shell ssh -oBatchMode=yes -4 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null {{ net_conn_details[0] }} "echo success"
302 register: user_enabled
303 until: user_enabled.stdout.find("success") != -1