Skip to content

Commit 1b83079

Browse files
committed
guestfs: fix destroy tasks
The destroy task was failing to properly undefine VMs due to two Ansible module compatibility issues: 1. The libvirt module flags format [1] requiring underscores instead of hyphens in flag names. This lead to failures with "Got no match for: snapshots-metadata" errors. 2. Undefined variable in storage volume cleanup. This caused volume deletion to fail, leaving storage files behind after VM destruction. These failures resulted in VMs remaining in 'shut off' state instead of being completely removed. Link: https://docs.ansible.com/ansible/latest/collections/community/libvirt/virt_module.html#parameter-flags [1] Fixes error: 27 - name: Undefine each stopped target node ^ column 3 fatal: [debian13-xfs-reflink-4k -> localhost]: FAILED! => {"changed": true, "msg": "value of flags must be one or more of: managed_save, snapshots_metadata, nvram, keep_nvram, checkpoints_metadata, delete_volumes. Got no match for: snapshots-metadata, checkpoints-metadata"} ... TASK [guestfs : Clean up storage volumes for target nodes] task path: /media/tarkir/dagomez/src/linux-kdevops/kdevops/playbooks/roles/guestfs/ tasks/destroy.yml:41 [ERROR]: Task failed: Finalization of task args for 'ansible.builtin.shell' failed: Error while resolving value for '_raw_params': 'kdevops_storage_pool' is undefined Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Gomez <[email protected]>
1 parent d0f577f commit 1b83079

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

playbooks/roles/guestfs/tasks/destroy.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
command: "undefine"
3030
flags:
3131
- "nvram"
32-
- "snapshots-metadata"
33-
- "checkpoints-metadata"
32+
- "snapshots_metadata"
33+
- "checkpoints_metadata"
3434
name: "{{ inventory_hostname }}"
3535
uri: "{{ libvirt_uri }}"
3636
changed_when: true
@@ -40,8 +40,8 @@
4040

4141
- name: Clean up storage volumes for target nodes
4242
ansible.builtin.shell: |
43-
virsh -c {{ libvirt_uri }} vol-delete --pool {{ kdevops_storage_pool }} {{ inventory_hostname }}/root.raw 2>/dev/null || true
44-
virsh -c {{ libvirt_uri }} vol-delete --pool {{ kdevops_storage_pool }} {{ inventory_hostname }}.raw 2>/dev/null || true
43+
virsh -c {{ libvirt_uri }} vol-delete --pool {{ kdevops_storage_pool_path }} {{ inventory_hostname }}/root.raw 2>/dev/null || true
44+
virsh -c {{ libvirt_uri }} vol-delete --pool {{ kdevops_storage_pool_path }} {{ inventory_hostname }}.raw 2>/dev/null || true
4545
changed_when: false
4646
ignore_errors: true
4747

0 commit comments

Comments
 (0)