File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed
roles/version_update_single_node/tasks Expand file tree Collapse file tree 2 files changed +51
-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+ - name : Show unique VM power states
9+ ansible.builtin.debug :
10+ msg : Unique VM power states {{ version_update_vms.records | map(attribute='power_state') | unique }}
11+
12+ # HyperCore states
13+ # RUNNING Currently running
14+ # BLOCKED Blocked on a resource
15+ # PAUSED Paused by the user
16+ # SHUTDOWN Shutting down
17+ # SHUTOFF Shut off
18+ # CRASHED Crashed
19+ # In ansible we have power_state (see FROM_HYPERCORE_TO_ANSIBLE_POWER_STATE):
20+ # RUNNING="started",
21+ # SHUTOFF="stopped",
22+ # BLOCKED="blocked",
23+ # PAUSED="paused",
24+ # SHUTDOWN="shutdown",
25+ # CRASHED="crashed",
26+ # Do not include 'shutdown' - it means "shutting_down"
27+ # States paused, blocked - might be safe to include, might not. Do not include yet.
28+ - name : Set fact version_update_all_vms_stopped
29+ ansible.builtin.set_fact :
30+ version_update_all_vms_stopped : |
31+ {{
32+ (
33+ version_update_vms.records | map(attribute='power_state') | unique) |
34+ ansible.builtin.difference(['stopped', 'crashed']
35+ ) == []
36+ }}
37+
38+ - name : Are all VMs stopped?
39+ ansible.builtin.debug :
40+ var : version_update_all_vms_stopped
41+
42+ - name : Wait if VMs are still running
43+ when : not version_update_all_vms_stopped
44+ ansible.builtin.pause :
45+ seconds : 10
You can’t perform that action at this time.
0 commit comments