1 # Create a libvirt volume pool. This is where we'll be creating
3 # Note: the virt_pool module is not working properly on rhel-7.2
4 # https://bugs.launchpad.net/tripleo-quickstart/+bug/1597905
5 - name: ensure libvirt volume path exists
8 path: "{{ libvirt_volume_path }}"
12 - name: Check volume pool
14 virsh pool-uuid "{{ libvirt_volume_pool }}"
19 LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
21 - name: create the volume pool xml file
23 src: volume_pool.xml.j2
24 dest: "{{ working_dir }}/volume_pool.xml"
25 when: pool_check is failed
27 - name: Define volume pool
28 command: "virsh pool-define {{ working_dir }}/volume_pool.xml"
29 when: pool_check is failed
31 LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
33 - name: Start volume pool
37 name: "{{ libvirt_volume_pool }}"
38 uri: "{{ libvirt_uri }}"
40 # In some cases the pool_check can pass and the pool xml config is absent
41 # In this case it is required to dump the xml and redefine the pool.
42 - name: ensure tripleo-quickstart volume pool is defined
44 virsh pool-dumpxml {{ libvirt_volume_pool }} |
45 virsh pool-define /dev/stdin
48 LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
50 - name: Mark volume pool for autostart
52 name: "{{ libvirt_volume_pool }}"
54 uri: "{{ libvirt_uri }}"
58 LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
61 # Create libvirt volumes for the vm hosts.
62 - name: Check if vm volumes exist
64 virsh vol-info --pool '{{ libvirt_volume_pool }}' '{{ item.name }}.qcow2'
65 register: vm_vol_check
67 with_items: "{{ vm_nodes }}"
69 - name: Create vm vm storage
71 virsh vol-create-as '{{ libvirt_volume_pool }}'
72 '{{ item.item.name }}'.qcow2 '{{ flavors[item.item.flavor].disk }}'G
76 with_items: "{{ vm_vol_check.results }}"
78 # Define (but do not start) the vm nodes. These will be
79 # booted later by ironic during the provisioning process.
82 name: "{{ item.name }}"
84 xml: "{{ lookup('template', 'baremetalvm.xml.j2') }}"
85 uri: "{{ libvirt_uri }}"
86 with_items: "{{ vm_nodes }}"
88 # Create additional blockdevices for each objectstorage flavor node
89 # These are sparse files, not using space if unused
90 - name: Create additional blockdevice for objectstorage nodes
92 dd if=/dev/zero of={{ libvirt_volume_path }}/{{ item[0].name }}_{{ item[1] }}.img bs=1 count=0 seek={{ extradisks_size }}
93 when: flavors[item[0].flavor].extradisks|default(false)
96 - "{{ extradisks_list }}"
98 - name: Check if additional blockdevices are attached
100 virsh domblkinfo {{ item[0].name }} {{ libvirt_volume_path }}/{{ item[0].name }}_{{ item[1] }}.img
101 when: flavors[item[0].flavor].extradisks|default(false)
104 register: vm_extradisks_check
107 - "{{ extradisks_list }}"
109 - name: Attach additional blockdevices to vm objectstorage VMs
111 virsh attach-disk --config {{ item.item[0].name }} {{ libvirt_volume_path }}/{{ item.item[0].name }}_{{ item.item[1] }}.img {{ item.item[1] }}
113 with_items: "{{ vm_extradisks_check.results }}"
115 # Generate the ironic node inventory files. Note that this
116 # task *must* occur after the above vm tasks, because if
117 # `vm_nodes` is defined the template depends on the
118 # `node_mac_map` variable.
119 - name: Write ironic node json files
121 src: ../templates/ironic_nodes.json.j2
122 dest: "{{ working_dir }}/ironic_nodes.json"