diff --git a/ansible/playbooks/99_vm_destroy.yaml b/ansible/playbooks/99_vm_destroy.yaml index ac25d78..6102d4a 100644 --- a/ansible/playbooks/99_vm_destroy.yaml +++ b/ansible/playbooks/99_vm_destroy.yaml @@ -1,5 +1,5 @@ --- -- name: create the vms +- name: destroy the vms hosts: hv00 gather_facts: true become: true diff --git a/ansible/roles/vm_destroy/tasks/destroy.yaml b/ansible/roles/vm_destroy/tasks/destroy.yaml index e048637..26538b2 100644 --- a/ansible/roles/vm_destroy/tasks/destroy.yaml +++ b/ansible/roles/vm_destroy/tasks/destroy.yaml @@ -21,16 +21,26 @@ when: vm_name in vm_list.list_vms block: - - name: stop the vm + - name: shutdown the vm community.libvirt.virt: state: shutdown name: "{{ vm_name }}" - - name: destroy the vm + # - name: destroy the vm + # community.libvirt.virt: + # state: destroyed + # name: "{{ vm_name }}" + + - name: undefine the vm community.libvirt.virt: - state: destroyed + state: undefine name: "{{ vm_name }}" + - name: delete the firmware vars file + ansible.builtin.file: + path: "{{ firmware_vhd_pool_dir }}/{{ vm_name }}_VARS.fd" + state: absent + - name: delete the root vhd when: delete_root_vhd ansible.builtin.file: