summaryrefslogtreecommitdiffstats
path: root/xci/playbooks/roles/create-nodes/tasks/main.yml
blob: 607ac494bef464b8af5c0a402cb9f34ac354f7ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
# baremetal_json_file could be the file coming from pdf/idf

- name: "Load distribution defaults"
  include_vars: "{{ ansible_os_family | lower }}.yml"

# From the previous list
- name: "Install required packages"
  package:
    name: "{{ required_packages }}"
    update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}"
    state: present

- include_tasks: prepare_libvirt.yml
  with_items: "{{ libvirt_networks }}"

- include_tasks: download_opnfvimage.yml

- name: create placeholder var for vm entries in JSON format
  set_fact:
    nodes_json_data: {}

# First we create the opnfv_vm
- include_tasks: create_vm.yml
  with_indexed_items: "{{ vms_to_create }}"

- include_tasks: baremetalhoststojson.yml
  with_items: "{{ baremetal_nodes }}"

- name: Start the opnfv vm
  virt:
    command: start
    name: opnfv

- name: remove previous baremetal data file
  file:
    state: absent
    path: "{{ baremetal_json_file }}"

# We got nodes_json_data from the create_vm playbook
- name: write to baremetal json file
  copy:
    dest: "{{ baremetal_json_file }}"
    content: "{{ nodes_json_data | to_nice_json }}"

- name: >
    "Set file permissions such that the baremetal data file
    can be read by the user executing Ansible"
  file:
    path: "{{ baremetal_json_file }}"
    owner: "{{ ansible_env.SUDO_USER }}"
  when: >
    ansible_env.SUDO_USER is defined and
    baremetal_json_file != ""