From 6aadbb5ee98d737945c5e472846be799622d4524 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Wed, 15 Aug 2018 17:09:41 +0100 Subject: [PATCH] MNAIO: Use virt module to shut VM's down when saving images It's better to shut the VM's down cleanly instead of just turning them off, so we change 'destroy' to 'shutdown' and use the virt module for this action instead of the command module. Change-Id: I896b7794328b91dc59726bf1d5366eeb7112ca21 --- multi-node-aio/playbooks/save-vms.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/multi-node-aio/playbooks/save-vms.yml b/multi-node-aio/playbooks/save-vms.yml index 7ef0782d..d7303b09 100644 --- a/multi-node-aio/playbooks/save-vms.yml +++ b/multi-node-aio/playbooks/save-vms.yml @@ -37,8 +37,9 @@ register: _virt_pools - name: Stop running VMs - command: "virsh destroy {{ hostvars[item]['server_hostname'] }}" - failed_when: false + virt: + name: "{{ hostvars[item]['server_hostname'] }}" + state: shutdown when: - hostvars[item]['server_vm'] | default(false) | bool with_items: "{{ groups['pxe_servers'] }}"