This repository has been archived by the owner on Feb 29, 2024. It is now read-only.
/
main.yml
52 lines (46 loc) · 1.52 KB
/
main.yml
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
# Create a libvirt volume pool. This is where we'll be creating
# images for the undercloud and overcloud.
# Note: the virt_pool module is not working properly on rhel-7.2
# https://bugs.launchpad.net/tripleo-quickstart/+bug/1597905
- name: ensure libvirt volume path exists
file:
path: "{{ libvirt_volume_path }}"
state: directory
- name: Check volume pool
command: >
virsh pool-uuid "{{ libvirt_volume_pool }}"
register: pool_check
ignore_errors: true
changed_when: false
environment:
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
- name: create the volume pool xml file
template:
src: volume_pool.xml.j2
dest: "{{ working_dir }}/volume_pool.xml"
when: pool_check|failed
- name: Define volume pool
command: "virsh pool-define {{ working_dir }}/volume_pool.xml"
when: pool_check|failed
environment:
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
- name: Start volume pool
virt_pool:
command: start
state: active
name: "{{ libvirt_volume_pool }}"
uri: "{{ libvirt_uri }}"
# In some cases the pool_check can pass and the pool xml config is absent
# In this case it is required to dump the xml and redefine the pool.
- name: ensure tripleo-quickstart volume pool is defined
shell: >
virsh pool-dumpxml {{ libvirt_volume_pool }} |
virsh pool-define /dev/stdin
changed_when: true
environment:
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
- name: Mark volume pool for autostart
virt_pool:
name: "{{ libvirt_volume_pool }}"
autostart: "yes"
uri: "{{ libvirt_uri }}"