Hello,
When shutting down a kvm guest using the task
name: shut down kvm guest
virt: name=kvm-guest state=shutdown
Ansible will continue when the virsh shutdown kvm-guest command is finished.
However I want it to wait for the guest to actually finnish the shutdown procedure.
Anybody who knows how to do this ?
Rob Verduijn
Were you able to figure this out? Or any suggestions??
You can use a do until loop
https://docs.ansible.com/ansible/playbooks_loops.html#do-until-loops
- action: virt name=kvm-guest command=status
register: result
until: result.status.find("shutdown") != -1
retries: 30
delay: 5
system
(system)
October 27, 2016, 9:50pm
4
Hi,
Here's a snippet that I use:
- name: wait for the vm to shut down
virt:
command: status
name: "{{ inventory_hostname }}"
register: vmstatus
until: vmstatus.status == 'shutdown'
delegate_to: "{{ vmhost }}"
retries: 1500
delay: 10
vmhost = the hypervisor on which the VM runs.
HTH,
Patrick