|
1 | 1 | # SPDX-License-Identifier: Apache-2.0 |
2 | 2 | --- |
3 | 3 |
|
4 | | -- name: SAP Control - Show command to be executed - {{ command_item['nr'] }} |
| 4 | +- name: SAP Control - Show command to be executed for instance - {{ command_item['nr'] }} |
5 | 5 | ansible.builtin.debug: |
6 | 6 | msg: | |
7 | 7 | User: {{ command_item['user'] }} |
8 | 8 | Command: {{ command_item['command'] }} |
9 | 9 |
|
10 | | -- name: SAP Control - Execute sapcontrol command # noqa command-instead-of-shell no-changed-when |
| 10 | +- name: SAP Control - Execute sapcontrol command for instance - {{ command_item['nr'] }} # noqa command-instead-of-shell no-changed-when |
11 | 11 | ansible.builtin.shell: |
12 | 12 | cmd: "{{ command_item['command'] }}" |
13 | 13 | become: true |
|
16 | 16 | ignore_errors: true |
17 | 17 |
|
18 | 18 |
|
19 | | -- name: Block to wait for status to change if using restart or update |
| 19 | +- name: SAP Control - Start asynchronous monitoring for instance - {{ command_item['nr'] }} |
| 20 | + ansible.builtin.include_tasks: |
| 21 | + file: actions/async_monitor.yml |
20 | 22 | when: |
21 | | - - sap_control_function is match('restart|update') |
22 | 23 | - command_item['async'] is defined |
23 | 24 | - command_item['async'] | length > 0 |
24 | | - block: |
25 | | - - name: SAP Control - Get current system state - {{ command_item['nr'] }} # noqa no-changed-when |
26 | | - ansible.builtin.shell: |
27 | | - cmd: >- |
28 | | - source ~/.profile && |
29 | | - sapcontrol |
30 | | - -nr {{ command_item['nr'] }} |
31 | | - -function {{ command_item['async']['test_function'] | d('GetSystemInstanceList') }} |
32 | | - become: true |
33 | | - become_user: "{{ command_item['user'] }}" |
34 | | - register: __sap_control_register_async_update_before |
35 | | - changed_when: false |
36 | 25 |
|
37 | | - - name: SAP Control - Wait for state to change for update and restart - {{ command_item['nr'] }} |
38 | | - ansible.builtin.shell: |
39 | | - cmd: >- |
40 | | - source ~/.profile && |
41 | | - sapcontrol |
42 | | - -nr {{ command_item['nr'] }} |
43 | | - -function {{ command_item['async']['test_function'] | d('GetSystemInstanceList') }} |
44 | | - become: true |
45 | | - become_user: "{{ command_item['user'] }}" |
46 | | - register: __sap_control_register_async_update_after |
47 | | - changed_when: false |
48 | | - retries: "{{ command_item['async']['retries'] | d(0) | int }}" |
49 | | - delay: "{{ command_item['async']['delay'] | d(0) | int }}" |
50 | | - until: > |
51 | | - (__sap_control_register_async_update_after.stdout |
52 | | - | regex_findall('GREEN|YELLOW|GRAY|RED', multiline=True) | sort | join(',')) |
53 | | - != (__sap_control_register_async_update_before.stdout |
54 | | - | regex_findall('GREEN|YELLOW|GRAY|RED', multiline=True) | sort | join(',')) |
55 | 26 |
|
56 | | -
|
57 | | -- name: Block for async wait |
58 | | - when: |
59 | | - - command_item['async'] is defined |
60 | | - - command_item['async'] | length > 0 |
61 | | - block: |
62 | | - - name: SAP Control - Wait for 20 Seconds to ensure the async function is started |
63 | | - ansible.builtin.wait_for: |
64 | | - timeout: 20 |
65 | | - |
66 | | - - name: SAP Control - Wait for state to change in retry loop - {{ command_item['nr'] }} |
67 | | - ansible.builtin.shell: |
68 | | - cmd: >- |
69 | | - source ~/.profile && |
70 | | - sapcontrol |
71 | | - -nr {{ command_item['nr'] }} |
72 | | - -function {{ command_item['async']['test_function'] | d('GetSystemInstanceList') }} |
73 | | - become: true |
74 | | - become_user: "{{ command_item['user'] }}" |
75 | | - register: __sap_control_register_async_command_output |
76 | | - changed_when: false |
77 | | - retries: "{{ command_item['async']['retries'] | d(0) | int }}" |
78 | | - delay: "{{ command_item['async']['delay'] | d(0) | int }}" |
79 | | - until: > |
80 | | - ( command_item['async']['until_false'] is not defined |
81 | | - or command_item['async']['until_false'] is defined |
82 | | - and __sap_control_register_async_command_output.stdout |
83 | | - | regex_search(command_item['async']['until_false'], multiline=True) is none) and |
84 | | - (command_item['async']['until_true'] is not defined or |
85 | | - command_item['async']['until_true'] is defined |
86 | | - and __sap_control_register_async_command_output.stdout |
87 | | - | regex_search(command_item['async']['until_true'], multiline=True) is not none) |
88 | | -
|
89 | | -
|
90 | | -- name: SAP Control - Execute 'cleanipc' command |
| 27 | +- name: SAP Control - Execute 'cleanipc' command for instance - {{ command_item['nr'] }} |
91 | 28 | ansible.builtin.shell: |
92 | 29 | cmd: >- |
93 | 30 | source ~/.profile && |
|
108 | 45 | | int > 0 |
109 | 46 |
|
110 | 47 |
|
111 | | -- name: SAP Control - Get final status of instance - {{ command_item['nr'] }} |
| 48 | +- name: SAP Control - Get final status for instance - {{ command_item['nr'] }} |
112 | 49 | ansible.builtin.shell: |
113 | 50 | cmd: >- |
114 | 51 | source ~/.profile && |
|
128 | 65 | if command_item['command'] is match('.*system$') |
129 | 66 | or (sap_control_function.split('_')[0] | lower) is match('.*system$') |
130 | 67 | else |
131 | | - 'GetProcessList' |
132 | | - }} |
| 68 | + 'GetProcessList' }} |
133 | 69 |
|
134 | 70 |
|
135 | 71 | - name: SAP Control - Show final status of instance - {{ command_item['nr'] }} |
|
139 | 75 | User: {{ command_item['user'] }} |
140 | 76 | Command: {{ command_item['command'] }} |
141 | 77 |
|
| 78 | + {% if sap_control_command_nowait | d(false) |
| 79 | + and (command_item['async'] is not defined or command_item['async'] | length == 0) %} |
| 80 | + This role was executed with 'sap_control_command_nowait' set to 'true', |
| 81 | + which skipped waiting for command and reported status can be inaccurate. |
| 82 | + {% endif %} |
| 83 | +
|
142 | 84 | Status: |
143 | 85 | {{ __sap_control_register_final_status.stdout }} |
0 commit comments