From 7aff1a3fbcaa717ef28bcc65111b374423a890a3 Mon Sep 17 00:00:00 2001 From: nicoo Date: Wed, 13 Jun 2018 03:54:52 +0200 Subject: [PATCH] vm/install: Group conditional when destroying existing VMs --- ansible/roles/vm/install/tasks/main.yml | 32 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/ansible/roles/vm/install/tasks/main.yml b/ansible/roles/vm/install/tasks/main.yml index 505ec1d..39e625f 100644 --- a/ansible/roles/vm/install/tasks/main.yml +++ b/ansible/roles/vm/install/tasks/main.yml @@ -45,23 +45,23 @@ command: info register: vmhost_info -- name: destroy exisiting vm - virt: - name: "{{ vmname }}" - state: destroyed - when: vmname in vmhost_info - -- name: wait for vm to be destroyed - wait_for_virt: - name: "{{ vmname }}" - states: shutdown,crashed - timeout: 5 - when: vmname in vmhost_info +- block: + - name: destroy exisiting vm + virt: + name: "{{ vmname }}" + state: destroyed + + - name: wait for vm to be destroyed + wait_for_virt: + name: "{{ vmname }}" + states: shutdown,crashed + timeout: 5 + + - name: undefining exisiting vm + virt: + name: "{{ vmname }}" + command: undefine -- name: undefining exisiting vm - virt: - name: "{{ vmname }}" - command: undefine when: vmname in vmhost_info - name: enable installer in VM config -- 1.7.10.4