|
1 | 1 | --- |
| 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 | +
|
2 | 28 | - name: Pause for 20 Seconds to ensure the async function is started |
3 | 29 | ansible.builtin.wait_for: |
4 | 30 | timeout: 20 |
|
15 | 41 | delay: "{{ async_function_dict.delay | default(0) | int }}" |
16 | 42 | until: > |
17 | 43 | (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 |
19 | 46 | (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) |
21 | 49 |
|
22 | 50 | - name: Debug stdout |
23 | 51 | ansible.builtin.debug: |
|
0 commit comments