Skip to content

fix: VMs are destroyed on nox_cleanup_state=true #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading