Skip to content

Commit 3f1e2cc

Browse files
committed
Use virsh pool-build to create pool directory
This approach is cleaner, and doesn't assume that Ansible has access to the pool's backing directory.
1 parent 7a99665 commit 3f1e2cc

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

tasks/pools.yml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
11
---
2-
- name: Ensure libvirt dir storage pool directories exist
3-
file:
4-
path: "{{ item.path }}"
5-
owner: "{{ item.owner }}"
6-
group: "{{ item.group }}"
7-
mode: "{{ item.mode|int(base=8) }}"
8-
state: directory
9-
when: item.type == "dir"
10-
loop: "{{ libvirt_host_pools | flatten(levels=1) }}"
11-
become: True
12-
132
- name: Ensure libvirt LVM storage pool directories exist
143
lvg:
154
vg: "{{ item.source }}"
@@ -34,6 +23,27 @@
3423
loop: "{{ libvirt_host_pools | flatten(levels=1) }}"
3524
become: True
3625

26+
- name: Check libvirt directory storage pool status
27+
virt_pool:
28+
name: "{{ item.name }}"
29+
command: status
30+
uri: "{{ libvirt_host_uri | default(omit, true) }}"
31+
when: item.type == "dir"
32+
loop: "{{ libvirt_host_pools | flatten(levels=1) }}"
33+
become: True
34+
register: pool_status
35+
36+
- name: Ensure libvirt directory storage pools are built
37+
virt_pool:
38+
name: "{{ item.item.name }}"
39+
command: build
40+
uri: "{{ libvirt_host_uri | default(omit, true) }}"
41+
when:
42+
- item is not skipped
43+
- item.status != "active"
44+
loop: "{{ pool_status.results }}"
45+
become: True
46+
3747
- name: Ensure libvirt storage pools are active
3848
virt_pool:
3949
name: "{{ item.name }}"

0 commit comments

Comments
 (0)