Skip to content

Commit 543ac79

Browse files
author
Will Miller
committed
Ensure libvirt module tasks use become
Libvirt pools are created with `become` in ansible-role-libvirt-host, so the volumes created here must also use `become` to ensure they can access the created pools.
1 parent e8e3b4c commit 543ac79

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

tasks/destroy-vm.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@
66
name: "{{ libvirt_vm_name }}"
77
command: list_vms
88
register: result
9+
become: yes
910

1011
- block:
1112
- name: Ensure the VM is absent
1213
virt:
1314
name: "{{ libvirt_vm_name }}"
1415
state: destroyed
16+
become: yes
1517

1618
- name: Ensure the VM is undefined
1719
virt:
1820
name: "{{ libvirt_vm_name }}"
1921
command: undefine
22+
become: yes
2023
when: libvirt_vm_name in result.list_vms

tasks/destroy-volumes.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
changed_when:
1010
- volume_result | success
1111
- (volume_result.stdout | from_json).changed | default(True)
12+
become: yes

tasks/vm.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
name: "{{ libvirt_vm_name }}"
1515
command: define
1616
xml: "{{ lookup('template', 'vm.xml.j2') }}"
17+
become: true
1718

1819
- name: Ensure the VM is running and started at boot
1920
virt:
2021
name: "{{ libvirt_vm_name }}"
2122
autostart: true
2223
state: running
24+
become: true

tasks/volumes.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@
2828
changed_when:
2929
- volume_result | success
3030
- (volume_result.stdout | from_json).changed | default(True)
31+
become: true

0 commit comments

Comments
 (0)