--- # Copyright 2019 Nokia # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - name: Write os_net_config to tmp files copy: content: "{{ ironic_node_details.driver_info.power.os_net_config }}" dest: "/tmp/{{ironic_node_details.name}}_config.yaml" mode: 0444 - name: Create baremetal ironic nodes environment: OS_AUTH_TOKEN: "fake-token" IRONIC_URL: "{{ ironic_service_adminurl }}" os_ironic_props: auth: auth_type: 'None' ironic_url: "{{ ironic_service_adminurl }}" state: present name: "{{ ironic_node_details.name }}" driver: "{{ ironic_node_details.driver }}" nics: "{{ ironic_node_details.nics }}" properties: "{{ ironic_node_details.properties }}" driver_info: "{{ ironic_node_details.driver_info | combine({'power': {'os_net_config': lookup('file', '/tmp/'+ironic_node_details.name+'_config.yaml'), 'ipmi_terminal_port': hosts[ironic_node_details.name]['ipmi_terminal_port'] }}, recursive=True ) }}" driver_info: "{{ ironic_node_details.driver_info | combine({'power': {'os_net_config': lookup('file', '/tmp/'+ironic_node_details.name+'_config.yaml'), 'ipmi_terminal_port': hosts[ironic_node_details.name]['ipmi_terminal_port'], 'provisioning_server_http_port': golden_image_http_port }}, recursive=True ) }}" register: baremetal_ironic_nodes_results when: installation_phase == "provisioning-started" - name: Create node datastructure if its not in active state and not the installation controller. set_fact: baremetal_ironic_node_id: {"uuid": "{{baremetal_ironic_nodes_results.uuid}}", "name": "{{ironic_node_details.name}}" } when: - installation_phase == "provisioning-started" - hosts[ironic_node_details.name]['installation_host'] is undefined - baremetal_ironic_nodes_results.provision_state != 'active' - name: Create baremetal ironic nodes os_ironic_props: cloud: default endpoint_type: internal auth_type: password state: present name: "{{ ironic_node_details.name }}" driver: "{{ ironic_node_details.driver }}" nics: "{{ ironic_node_details.nics }}" properties: "{{ ironic_node_details.properties }}" driver_info: "{{ ironic_node_details.driver_info | combine({'power': {'os_net_config': lookup('file', '/tmp/'+ironic_node_details.name+'_config.yaml'), 'ipmi_terminal_port': hosts[ironic_node_details.name]['ipmi_terminal_port'], 'provisioning_server_http_port': golden_image_http_port }}, recursive=True ) }}" register: baremetal_ironic_nodes_results when: (installation_phase != "provisioning-started" and reinitialized_nodes is not defined and scaled_out_nodes is not defined) or (reinitialized_nodes is defined and ironic_node_details.name in reinitialized_nodes) or (scaled_out_nodes is defined and ironic_node_details.name in scaled_out_nodes) - name: Create node datastructure if its not in active state and not the installation controller. set_fact: baremetal_ironic_node_id: {"uuid": "{{baremetal_ironic_nodes_results.uuid}}", "name": "{{ironic_node_details.name}}" } when: - installation_phase != "provisioning-started" - (hosts[ironic_node_details.name]['installation_host'] is undefined and reinitialized_nodes is not defined and scaled_out_nodes is not defined) or (reinitialized_nodes is defined and ironic_node_details.name in reinitialized_nodes) or (scaled_out_nodes is defined and ironic_node_details.name in scaled_out_nodes) - baremetal_ironic_nodes_results.provision_state != 'active'