diff --git a/roles/virt_vm/tasks/create_vm.yml b/roles/virt_vm/tasks/create_vm.yml index 7d114a0..f7ad38f 100644 --- a/roles/virt_vm/tasks/create_vm.yml +++ b/roles/virt_vm/tasks/create_vm.yml @@ -71,23 +71,33 @@ shell: cmd: "ping -c 2 {{ ansible_host }}" register: pingcmd - retries: 12 + retries: 11 delay: 10 until: pingcmd.rc == 0 # CLOUD-INIT CLEANUP -- name: detach CI from vm - delegate_to: "{{ virt.host }}" - shell: - cmd: virsh change-media "{{ inventory_hostname }}" sda --eject - - name: shutdown VM delegate_to: "{{ virt.host }}" virt: name: "{{ inventory_hostname }}" state: shutdown +- name: wait for shutdown + delegate_to: "{{ virt.host }}" + virt: + name: "{{ inventory_hostname }}" + command: status + register: vmstate + retries: 11 + delay: 10 + until: vmstate.status == "shutdown" + +- name: detach CI from vm + delegate_to: "{{ virt.host }}" + shell: + cmd: virsh change-media "{{ inventory_hostname }}" sda --eject --config + - name: delete CI temp dir delegate_to: "{{ virt.host }}" file: