-
Notifications
You must be signed in to change notification settings - Fork 4
/
version_update_single_node.yml
66 lines (52 loc) · 2.99 KB
/
version_update_single_node.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
--- #
- name: Update a HyperCore single-node system
hosts: all
connection: local
gather_facts: true
environment: # if set here - hypercore modules will automatically use this for each remote cluster - avoiding need to specify cluster_instance for each test
SC_HOST: "https://{{ inventory_hostname }}"
SC_USERNAME: "{{ scale_user }}"
SC_PASSWORD: "{{ scale_pass }}"
SC_TIMEOUT: 600
vars:
version_update_single_node_shutdown_wait_time: 30 #workaround for issue https://github.com/ScaleComputing/HyperCoreAnsibleCollection/issues/257
tasks:
- name: get all available updates
scale_computing.hypercore.version_update_info:
register: version_update
- name: determine next available update #TODO - these fail if no update available
ansible.builtin.set_fact:
next_update: "{{ ( version_update.records | from_yaml | sort(attribute='revision' ) | sort(attribute='minor_version' ) | sort(attribute='major_version' ) | first ).uuid }}"
when: version_update.records | length > 0
- name: determine newest available update
ansible.builtin.set_fact:
newest_update: "{{ ( version_update.records | from_yaml | sort(attribute='revision' ) | sort(attribute='minor_version' ) | sort(attribute='major_version' ) | last ).uuid }}"
when: version_update.records | length > 0
#TODO - add way to get latest wihin current or specific major or minor version - try next, last, some flag to ignore different minor version?
- name: Get cluster local timezone setting
scale_computing.hypercore.time_zone_info:
register: timezone
#TODO - update below to use https://github.com/ScaleComputing/HyperCoreAnsibleCollection/tree/main/roles/check_local_time
- name: get remote hour of day (using remote cluster) timezone # runs data command locally with TZ of remote cluster set
command: "date '+%H'"
register: hour_remote
environment:
TZ: "{{ timezone.record.zone }}"
changed_when: false
- name: debug remote timezone
debug:
msg: remote time in "{{ timezone.record.zone }}" is "{{ hour_remote.stdout }}" local hour is "{{ ansible_date_time.hour }}"
- name: Update HyperCore single-node system to a desired version with VM shutdown and restart
include_role:
name: scale_computing.hypercore.version_update_single_node
vars:
version_update_single_node_desired_version: "{{ hypercore_desired_version }}" #"{{ next_update }}" #
when: hour_remote.stdout | int >= 13 or hour_remote.stdout | int <= 10
- name: Get version update status
scale_computing.hypercore.version_update_status_info:
register: version_update_status
- name: Report failed when update status is TERMINATING (vs. COMPLETED)
ansible.builtin.debug:
var: version_update_status
failed_when: version_update_status.record.update_status == "TERMINATING"
# when: ansible_date_time.hour|int >= 17 or ansible_date_time.hour|int <= 5 #this uses local time fact