Skip to content

Commit

Permalink
Shutting down VMs done asynchronously:
Browse files Browse the repository at this point in the history
Send shutdown command to all VMs simultaneously and
wait until they finish.
If there are a lot of VMs in the cluster,
this can help to speed up the shutdown proccess:
for 50 VMs infrastructure it takes 3 minutes instead of 40.
  • Loading branch information
xe-leon committed Apr 9, 2024
1 parent 18107de commit ea19d54
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions roles/shutdown_env/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand All @@ -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:
Expand Down

0 comments on commit ea19d54

Please sign in to comment.