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!
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!