From 2093fca5d210df88c078705dbb34d742a26ce821 Mon Sep 17 00:00:00 2001 From: michael Date: Sun, 30 Oct 2022 23:57:26 +1300 Subject: [PATCH] fixes to vm_destroy --- ansible/playbooks/99_vm_destroy.yaml | 2 +- ansible/roles/vm_destroy/tasks/destroy.yaml | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) 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: