Initial commit
[ta/infra-ansible.git] / roles / baremetal_provision / tasks / main.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
17
18 - include: convert_qcow_raw.yml
19
20 - name: Convert baremetal_nodes.j2 Jinja2 template to json file
21   template:
22     src: 'baremetal_nodes.j2'
23     dest: '/tmp/baremetal_nodes.json'
24
25 - name: Include variables from baremetal_nodes.json
26   include_vars: '/tmp/baremetal_nodes.json'
27
28 - name: Remove /tmp/baremetal_nodes.json
29   file:
30     path: "/tmp/baremetal_nodes.json"
31     state: "absent"
32
33 - name: Restore baremetal_ironic_nodes variable with ironic_nodes variable
34   set_fact:
35     baremetal_ironic_nodes: "{{ironic_nodes}}"
36   when: baremetal_ironic_nodes is undefined
37
38 - name: Create vbmc ports for virtual hosts
39   include: vbmc_port_setup.yml
40   when: virtual_env
41
42 - set_fact:
43     net_conn_details: "{{net_conn_details + [{'node_name': item.name, 'node_ip': item.driver_info.power.os_net_config | json_query('network_config[*].addresses[0].ip_netmask') |  ipaddr('address')}] }}"
44   with_items: "{{ baremetal_ironic_nodes }}"
45   when: item.driver_info.power.os_net_config.network_config[0].type != 'ovs_bridge'
46   no_log: True
47
48 - set_fact:
49     net_conn_details: "{{net_conn_details + [{'node_name': item.name, 'node_ip': item.driver_info.power.os_net_config | json_query('network_config[*].members[*].addresses[0].ip_netmask')|first | ipaddr('address')}] }}"
50   with_items: "{{ baremetal_ironic_nodes }}"
51   when: item.driver_info.power.os_net_config.network_config[0].type == 'ovs_bridge'
52   no_log: True
53
54 - include: setup_http.yml
55   tags: http_provision
56
57 - name: Setup tmux
58   copy:
59     src: "tmux_setup"
60     dest: "/opt/"
61
62 - include: ironic_nodes_create.yml
63   tags:
64     - baremetal-ironic-nodes-create
65
66 - include: start_console_logging.yml
67   tags:
68     - baremetal-ironic-nodes-deploy
69   when: virtual_env == false
70
71 - include: ironic_nodes_deploy.yml
72   tags:
73     - baremetal-ironic-nodes-deploy
74
75 - include: stop_console_logging.yml
76   tags:
77     - baremetal-ironic-nodes-deploy
78   when: virtual_env == false
79
80 - include: teardown_http.yml
81   tags: http_provision