File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
roles/version_update_single_node/tasks Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1515 register : vm_shutdown_result
1616 ignore_errors : true # if VMs fail to shut down without force, error will occur, so we skip and try on to shut down with force
1717
18+ # Wait up to 300 sec (30*10)
19+ - name : Wait until VMs shutdown
20+ include_tasks : wait_vm_shutdown.yml
21+ loop : " {{ range(0, 30) | list }}"
22+ when : version_update_all_vms_stopped | default(true)
23+
1824- name : Show shutdown results
1925 ansible.builtin.debug :
2026 var : vm_shutdown_result
Original file line number Diff line number Diff line change 1+ ---
2+ - name : Wait on VMs to shutdown
3+ block :
4+ - name : Get all available running VMs
5+ scale_computing.hypercore.vm_info :
6+ register : version_update_vms
7+
8+ - ansible.builtin.debug :
9+ msg : Unique VM power states {{ version_update_vms.records | map(attribute='power_state') | unique }}
10+
11+ # HyperCore states
12+ # RUNNING Currently running
13+ # BLOCKED Blocked on a resource
14+ # PAUSED Paused by the user
15+ # SHUTDOWN Shutting down
16+ # SHUTOFF Shut off
17+ # CRASHED Crashed
18+ # In ansible we have power_state (see FROM_HYPERCORE_TO_ANSIBLE_POWER_STATE):
19+ # RUNNING="started",
20+ # SHUTOFF="stopped",
21+ # BLOCKED="blocked",
22+ # PAUSED="paused",
23+ # SHUTDOWN="shutdown",
24+ # CRASHED="crashed",
25+ # Do not include 'shutdown' - it means "shutting_down"
26+ # States paused, blocked - might be safe to include, might not. Do not include yet.
27+ - name : Set fact version_update_all_vms_stopped
28+ ansible.builtin.set_fact :
29+ version_update_all_vms_stopped : |
30+ {{
31+ (
32+ version_update_vms.records | map(attribute='power_state') | unique) |
33+ ansible.builtin.difference(['stopped', 'crashed']
34+ ) == []
35+ }}
36+
37+ - ansible.builtin.debug :
38+ var : version_update_all_vms_stopped
39+
40+ - name : Wait if VMs are still running
41+ when : not version_update_all_vms_stopped
42+ ansible.builtin.pause :
43+ seconds : 10
You can’t perform that action at this time.
0 commit comments