Initial commit
[ta/infra-ansible.git] / roles / baremetal_provision / tasks / main.yml
diff --git a/roles/baremetal_provision/tasks/main.yml b/roles/baremetal_provision/tasks/main.yml
new file mode 100644 (file)
index 0000000..38b4675
--- /dev/null
@@ -0,0 +1,81 @@
+---
+
+# 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.
+
+
+- include: convert_qcow_raw.yml
+
+- name: Convert baremetal_nodes.j2 Jinja2 template to json file
+  template:
+    src: 'baremetal_nodes.j2'
+    dest: '/tmp/baremetal_nodes.json'
+
+- name: Include variables from baremetal_nodes.json
+  include_vars: '/tmp/baremetal_nodes.json'
+
+- name: Remove /tmp/baremetal_nodes.json
+  file:
+    path: "/tmp/baremetal_nodes.json"
+    state: "absent"
+
+- name: Restore baremetal_ironic_nodes variable with ironic_nodes variable
+  set_fact:
+    baremetal_ironic_nodes: "{{ironic_nodes}}"
+  when: baremetal_ironic_nodes is undefined
+
+- name: Create vbmc ports for virtual hosts
+  include: vbmc_port_setup.yml
+  when: virtual_env
+
+- set_fact:
+    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')}] }}"
+  with_items: "{{ baremetal_ironic_nodes }}"
+  when: item.driver_info.power.os_net_config.network_config[0].type != 'ovs_bridge'
+  no_log: True
+
+- set_fact:
+    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')}] }}"
+  with_items: "{{ baremetal_ironic_nodes }}"
+  when: item.driver_info.power.os_net_config.network_config[0].type == 'ovs_bridge'
+  no_log: True
+
+- include: setup_http.yml
+  tags: http_provision
+
+- name: Setup tmux
+  copy:
+    src: "tmux_setup"
+    dest: "/opt/"
+
+- include: ironic_nodes_create.yml
+  tags:
+    - baremetal-ironic-nodes-create
+
+- include: start_console_logging.yml
+  tags:
+    - baremetal-ironic-nodes-deploy
+  when: virtual_env == false
+
+- include: ironic_nodes_deploy.yml
+  tags:
+    - baremetal-ironic-nodes-deploy
+
+- include: stop_console_logging.yml
+  tags:
+    - baremetal-ironic-nodes-deploy
+  when: virtual_env == false
+
+- include: teardown_http.yml
+  tags: http_provision