Skip to content

Commit

Permalink
fix: VMs are destroyed on nox_cleanup_state=true (#45)
Browse files Browse the repository at this point in the history
VMs are destroyed on nox_cleanup_state=true

Co-authored-by: Aleksey Proshutinskiy <[email protected]>
Co-authored-by: folex <[email protected]>
  • Loading branch information
3 people authored Sep 18, 2024
1 parent ea391bb commit c4e36aa
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions roles/nox/tasks/01-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,30 @@
state: absent
when: nox_cleanup_state

- name: cleanup VMs if any
block:
- name: List all VMs
community.libvirt.virt:
command: list_vms
register: all_vms

- debug:
msg: "{{ item }}"
loop: "{{ all_vms.list_vms }}"

- name: "Destroy vm {{ item }}"
community.libvirt.virt:
name: "{{ item }}"
command: destroy
loop: "{{ all_vms.list_vms }}"

- name: "Undefine vm {{ item }}"
community.libvirt.virt:
name: "{{ item }}"
command: undefine
loop: "{{ all_vms.list_vms }}"
when: nox_cleanup_state

- name: create nox directories
ansible.builtin.file:
path: "{{ nox_dir }}/state"
Expand Down

0 comments on commit c4e36aa

Please sign in to comment.