diff --git a/roles/shutdown_env/tasks/main.yml b/roles/shutdown_env/tasks/main.yml index 8b6db1e6..ca728665 100644 --- a/roles/shutdown_env/tasks/main.yml +++ b/roles/shutdown_env/tasks/main.yml @@ -104,8 +104,20 @@ when: "item.origin != 'managed_hosted_engine'" with_items: - "{{ vm_result.ovirt_vms }}" + async: 300 + poll: 0 + register: _alias_vmshutdown_0 failed_when: false + - name: Wait for all VMs to shutdown + async_status: + jid: "{{ item.ansible_job_id }}" + register: _jobs_alias_vmshutdown_0 + retries: 60 + delay: 5 + until: _jobs_alias_vmshutdown_0.finished + loop: "{{_alias_vmshutdown_0.results}}" + - name: Refresh VM list ovirt_vm_info: auth: "{{ ovirt_auth }}" @@ -122,6 +134,18 @@ when: "item.origin != 'managed_hosted_engine' and item.status != 'down'" with_items: - "{{ vm_result.ovirt_vms }}" + async: 300 + poll: 0 + register: _alias_vmshutdown_1 + + - name: Wait for all remaining VMs to shutdown + async_status: + jid: "{{ item.ansible_job_id }}" + register: _jobs_alias_vmshutdown_1 + retries: 60 + delay: 5 + until: _jobs_alias_vmshutdown_1.finished + loop: "{{_alias_vmshutdown_1.results}}" - name: Shutdown hosts, except HE ones, via IPMI (if configured) ovirt_host: