Stop and delete VM with Ansible

mauri5hut

New Member
Jun 2, 2023
4
0
1
Hi,

I have a problem with stopping and deleting a VM with Ansible (community.general.proxmox_kvm module).
When I stop a VM, the state of the VM is immediately "stopped", although the VM is not yet shut down.
Thus I cannot delete the VM in the next step. I have to wait some time.

Is there another solution with the module to check if the VM is really shutdown?

Kind regards
mauri
 
Can you add a hookscript with [ "$2" == "post-stop" ] && nohup /usr/sbin/qm destroy "$1" &>/dev/null & to the VM using Ansible? Then you can just let it self-destruct on stop.
 
I thought there is maybe a solution within the module. But I will try it by shell line with the qm commands.

Thanks!