Skip to content

Commit 577b25c

Browse files
committed
* Fix incompatibilities with Ansible 2.19
* Adds a pre-polling task for non-idempotent RestartSystem and UpdateSystem functions --------- Signed-off-by: Nicolas Bettembourg <[email protected]> Signed-off-by: nbttmbrg <[email protected]>
1 parent 89ba23e commit 577b25c

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

roles/sap_control/defaults/main.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,18 @@ updatesystem_all_nw_list:
9696
- sap_control_function_current: "nw_startsystem"
9797
- sap_control_function_current: "nw_updatesystem"
9898

99+
restartsystem_sap_nw_list:
100+
- sap_control_function_current: "nw_restartsystem"
101+
102+
updatesystem_sap_nw_list:
103+
- sap_control_function_current: "nw_updatesystem"
104+
105+
startsystem_sap_nw_list:
106+
- sap_control_function_current: "nw_startsystem"
107+
108+
stopsystem_sap_nw_list:
109+
- sap_control_function_current: "nw_stopsystem"
110+
99111
restart_all_sap_list:
100112
- sap_control_function_current: "nw_stop"
101113
- sap_control_function_current: "hana_stop"

roles/sap_control/tasks/sapcontrol_async.yml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
11
---
2+
- name: Wait for status to change if using restart or update
3+
when: funct_type is match('restart|update')
4+
block:
5+
- name: SAP {{ sap_control_name_header }} - Getting current system state
6+
ansible.builtin.shell: |
7+
source ~/.profile && sapcontrol -nr {{ passed_sap_nr }} -function {{ async_function_dict.test_function }}
8+
args:
9+
executable: /bin/bash
10+
become: true
11+
become_user: "{{ passed_sap_sid | lower }}adm"
12+
register: initial_test_function_result
13+
14+
- name: SAP {{ sap_control_name_header }} - Waiting for state to change before polling
15+
ansible.builtin.shell: |
16+
source ~/.profile && sapcontrol -nr {{ passed_sap_nr }} -function {{ async_function_dict.test_function }}
17+
args:
18+
executable: /bin/bash
19+
become: true
20+
become_user: "{{ passed_sap_sid | lower }}adm"
21+
register: wait_for_change_result
22+
retries: "{{ async_function_dict.retries | default(0) | int }}"
23+
delay: "{{ async_function_dict.delay | default(0) | int }}"
24+
until: >
25+
(wait_for_change_result.stdout | regex_findall('GREEN|YELLOW|GRAY|RED', multiline=True) | sort | join(','))
26+
!= (initial_test_function_result.stdout | regex_findall('GREEN|YELLOW|GRAY|RED', multiline=True) | sort | join(','))
27+
228
- name: Pause for 20 Seconds to ensure the async function is started
329
ansible.builtin.wait_for:
430
timeout: 20
@@ -15,9 +41,11 @@
1541
delay: "{{ async_function_dict.delay | default(0) | int }}"
1642
until: >
1743
(async_function_dict.until_false is not defined
18-
or async_function_dict.until_false is defined and not test_function_result.stdout | regex_search(async_function_dict.until_false, multiline=True)) and
44+
or async_function_dict.until_false is defined
45+
and test_function_result.stdout | regex_search(async_function_dict.until_false, multiline=True) is none) and
1946
(async_function_dict.until_true is not defined or
20-
async_function_dict.until_true is defined and test_function_result.stdout | regex_search(async_function_dict.until_true, multiline=True))
47+
async_function_dict.until_true is defined
48+
and test_function_result.stdout | regex_search(async_function_dict.until_true, multiline=True) is not none)
2149
2250
- name: Debug stdout
2351
ansible.builtin.debug:

0 commit comments

Comments
 (0)