Configure CaaS SR-IOV and provider networks
[ta/infra-ansible.git] / roles / baremetal_provision / tasks / ironic_nodes_create.yml
1 ---
2
3 # Copyright 2019 Nokia
4
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
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
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.
16 - name: Write os_net_config to tmp files
17   copy:
18     content: "{{ ironic_node_details.driver_info.power.os_net_config }}"
19     dest: "/tmp/{{ironic_node_details.name}}_config.yaml"
20     mode: 0444
21
22 - name: Create baremetal ironic nodes
23   environment:
24     OS_AUTH_TOKEN: "fake-token"
25     IRONIC_URL: "{{ ironic_service_adminurl }}"
26   os_ironic_props:
27     auth:
28     auth_type: 'None'
29     ironic_url: "{{ ironic_service_adminurl }}"
30     state: present
31     name: "{{ ironic_node_details.name }}"
32     driver: "{{ ironic_node_details.driver }}"
33     nics: "{{ ironic_node_details.nics }}"
34     properties: "{{ ironic_node_details.properties }}"
35     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 ) }}"
36     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 ) }}"
37
38   register: baremetal_ironic_nodes_results
39   when: installation_phase == "provisioning-started"
40
41 - name: Create node datastructure if its not in active state and not the installation controller.
42   set_fact:
43     baremetal_ironic_node_id: {"uuid": "{{baremetal_ironic_nodes_results.uuid}}", "name": "{{ironic_node_details.name}}" }
44   when:
45     - installation_phase == "provisioning-started"
46     - hosts[ironic_node_details.name]['installation_host'] is undefined
47     - baremetal_ironic_nodes_results.provision_state != 'active'
48
49 - name: Create baremetal ironic nodes
50   os_ironic_props:
51     cloud: default
52     endpoint_type: internal
53     auth_type: password
54     state: present
55     name: "{{ ironic_node_details.name }}"
56     driver: "{{ ironic_node_details.driver }}"
57     nics: "{{ ironic_node_details.nics }}"
58     properties: "{{ ironic_node_details.properties }}"
59     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 ) }}"
60   register: baremetal_ironic_nodes_results
61   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)
62
63 - name: Create node datastructure if its not in active state and not the installation controller.
64   set_fact:
65     baremetal_ironic_node_id: {"uuid": "{{baremetal_ironic_nodes_results.uuid}}", "name": "{{ironic_node_details.name}}" }
66   when:
67     - installation_phase != "provisioning-started"
68     - (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)
69     - baremetal_ironic_nodes_results.provision_state != 'active'