-
Notifications
You must be signed in to change notification settings - Fork 25
sap_control: Add SAP System-level Function Support with Asynchronous Status Tracking #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
c53e59f
1cecfd6
3cb3cd2
57b6a3d
89ba23e
577b25c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
minor_changes: | ||
- sap_control - add the mechanisms to handle asynchronous sapcontrol functions | ||
- sap_control - add UpdateSystem, RestartSystem, StartSystem, StopSystem functions |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,41 @@ sap_control_name_header: "initial" | |
nowait: false | ||
sap_control_start: "StartWait 180 2" | ||
sap_control_stop: "StopWait 180 2" | ||
sap_control_startsystem: "StartSystem ALL 180" # function StartSystem waittimeout | ||
sap_control_stopsystem: "StopSystem ALL 180 480" # function StopSystem waittimeout softtimeout | ||
sap_control_restartsystem: "RestartSystem ALL 180 480" # function RestartSystem waittimeout softtimeout | ||
sap_control_updatesystem: "UpdateSystem 180 480 0" # function UpdateSystem waittimeout softtimeout force | ||
sap_control_waitforstopped: "WaitforStopped 180 2" # function WaitforStopped waittimeout delay | ||
sap_control_waitforstarted: "WaitforStarted 180 2" # function WaitforStarted waittimeout delay | ||
|
||
# Parameters to handle async functions in sapcontrol_async.yml | ||
|
||
sap_control_startsystem_waitforasync: | ||
test_function: "GetSystemInstanceList" | ||
retries: 60 | ||
delay: 10 | ||
until_false: 'GRAY\s*$|RED\s*$|YELLOW\s*$' | ||
until_true: 'GREEN\s*$' | ||
|
||
sap_control_restartsystem_waitforasync: | ||
test_function: "GetSystemInstanceList" | ||
retries: 60 | ||
delay: 10 | ||
until_false: 'GRAY\s*$|RED\s*$|YELLOW\s*$' | ||
until_true: 'GREEN\s*$' | ||
|
||
sap_control_stopsystem_waitforasync: | ||
test_function: "GetSystemInstanceList" | ||
retries: 60 | ||
delay: 10 | ||
until_false: 'GREEN\s*$|RED\s*$|YELLOW\s*$' | ||
until_true: 'GRAY\s*$' | ||
|
||
sap_control_updatesystem_waitforasync: | ||
test_function: "GetSystemUpdateList" | ||
retries: 60 | ||
delay: 10 | ||
until_false: 'GRAY\s*$|RED\s*$|YELLOW\s*$|GREEN\s*$' | ||
|
||
# get_all_sap_sid_dir_nw: "/sapmnt" | ||
# get_all_sap_sid_dir_hana: "/hana/shared" | ||
|
@@ -22,6 +57,14 @@ sap_control_instance_type_sortorder: | |
|
||
# Functions | ||
sap_control_functions_list: | ||
- restartsystem_all_nw | ||
- updatesystem_all_nw | ||
- startsystem_all_nw | ||
- stopsystem_all_nw | ||
- restartsystem_sap_nw | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nbttmbrg Did you test these changes? - restartsystem_sap_nw
- updatesystem_sap_nw
- startsystem_sap_nw
- stopsystem_sap_nw fatal: [b01hana]: FAILED! =>
changed: false
msg: 'Task failed: object of type ''dict'' has no attribute ''startsystem_sap_nw_list''' |
||
- updatesystem_sap_nw | ||
- startsystem_sap_nw | ||
- stopsystem_sap_nw | ||
- restart_all_sap | ||
- stop_all_sap | ||
- start_all_sap | ||
|
@@ -38,7 +81,33 @@ sap_control_functions_list: | |
- stop_sap_hana | ||
- start_sap_hana | ||
|
||
|
||
# Functions flow | ||
restartsystem_all_nw_list: | ||
- sap_control_function_current: "nw_restartsystem" | ||
|
||
startsystem_all_nw_list: | ||
- sap_control_function_current: "nw_startsystem" | ||
|
||
stopsystem_all_nw_list: | ||
- sap_control_function_current: "nw_stopsystem" | ||
|
||
updatesystem_all_nw_list: | ||
- sap_control_function_current: "nw_startsystem" | ||
- sap_control_function_current: "nw_updatesystem" | ||
|
||
restartsystem_sap_nw_list: | ||
- sap_control_function_current: "nw_restartsystem" | ||
|
||
updatesystem_sap_nw_list: | ||
- sap_control_function_current: "nw_updatesystem" | ||
|
||
startsystem_sap_nw_list: | ||
- sap_control_function_current: "nw_startsystem" | ||
|
||
stopsystem_sap_nw_list: | ||
- sap_control_function_current: "nw_stopsystem" | ||
|
||
restart_all_sap_list: | ||
- sap_control_function_current: "nw_stop" | ||
- sap_control_function_current: "hana_stop" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,10 +112,18 @@ | |
ansible.builtin.debug: | ||
msg: | ||
- "Starting sap_control with the following parameters: " | ||
- "{{ sap_control_function }}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed this because it made little sense in my situation and couldn't figure out how to efficiently display only what was used. To be honnest I don't really get when this is useful at all |
||
- "{{ sap_control_start }}" | ||
- "{{ sap_control_stop }}" | ||
- "{{ nowait }}" | ||
- "Function: {{ sap_control_function }}" | ||
- "Standard commands:" | ||
- " Start: {{ sap_control_start }}" | ||
- " Stop: {{ sap_control_stop }}" | ||
- "System commands (if applicable):" | ||
- " StartSystem: {{ sap_control_startsystem }}" | ||
- " StopSystem: {{ sap_control_stopsystem }}" | ||
- " RestartSystem: {{ sap_control_restartsystem }}" | ||
- " UpdateSystem: {{ sap_control_updatesystem }}" | ||
- " WaitforStopped: {{ sap_control_waitforstopped }}" | ||
- " WaitforStarted: {{ sap_control_waitforstarted }}" | ||
- "NoWait: {{ nowait }}" | ||
|
||
# Start SAP Control | ||
- name: SAP Control | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
- name: Wait for status to change if using restart or update | ||
when: funct_type is match('restart|update') | ||
block: | ||
- name: SAP {{ sap_control_name_header }} - Getting current system state | ||
ansible.builtin.shell: | | ||
source ~/.profile && sapcontrol -nr {{ passed_sap_nr }} -function {{ async_function_dict.test_function }} | ||
args: | ||
executable: /bin/bash | ||
become: true | ||
become_user: "{{ passed_sap_sid | lower }}adm" | ||
register: initial_test_function_result | ||
|
||
- name: SAP {{ sap_control_name_header }} - Waiting for state to change before polling | ||
ansible.builtin.shell: | | ||
source ~/.profile && sapcontrol -nr {{ passed_sap_nr }} -function {{ async_function_dict.test_function }} | ||
args: | ||
executable: /bin/bash | ||
become: true | ||
become_user: "{{ passed_sap_sid | lower }}adm" | ||
register: wait_for_change_result | ||
retries: "{{ async_function_dict.retries | default(0) | int }}" | ||
delay: "{{ async_function_dict.delay | default(0) | int }}" | ||
until: > | ||
(wait_for_change_result.stdout | regex_findall('GREEN|YELLOW|GRAY|RED', multiline=True) | sort | join(',')) | ||
!= (initial_test_function_result.stdout | regex_findall('GREEN|YELLOW|GRAY|RED', multiline=True) | sort | join(',')) | ||
|
||
- name: Pause for 20 Seconds to ensure the async function is started | ||
ansible.builtin.wait_for: | ||
timeout: 20 | ||
|
||
- name: SAP {{ sap_control_name_header }} - Checking if Async action is over by executing sapcontrol -nr {{ passed_sap_nr }} -function {{ async_function_dict.test_function }} | ||
ansible.builtin.shell: | | ||
source ~/.profile && sapcontrol -nr {{ passed_sap_nr }} -function {{ async_function_dict.test_function }} | ||
args: | ||
executable: /bin/bash | ||
become: true | ||
become_user: "{{ passed_sap_sid | lower }}adm" | ||
register: test_function_result | ||
retries: "{{ async_function_dict.retries | default(0) | int }}" | ||
delay: "{{ async_function_dict.delay | default(0) | int }}" | ||
until: > | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
task path: /home/mmamula/ansible_collections/community/sap_operations/roles/sap_control/tasks/sapcontrol_async.yml:6
fatal: [b01hana]: FAILED! =>
changed: false
msg: 'Task failed: Conditional result was ''GREEN'' of type ''str'', which evaluates
to True. Conditionals must have a boolean result.' This is example from my recent PR where I had to deal with this: failed_when:
- __sap_ha_pacemaker_cluster_register_ers_ha_failover_config_restart.stdout | d('') | regex_search('^HAActive:\\s+FALSE$', multiline=True) is not none |
||
(async_function_dict.until_false is not defined | ||
or async_function_dict.until_false is defined | ||
and test_function_result.stdout | regex_search(async_function_dict.until_false, multiline=True) is none) and | ||
(async_function_dict.until_true is not defined or | ||
async_function_dict.until_true is defined | ||
and test_function_result.stdout | regex_search(async_function_dict.until_true, multiline=True) is not none) | ||
|
||
- name: Debug stdout | ||
ansible.builtin.debug: | ||
msg: | | ||
Async function {{ async_function_dict.test_function }} for SAP SID {{ passed_sap_sid }} | ||
is done with result: | ||
{{ test_function_result.stdout }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These waitforstarted/waitforstopped aren't used anymore, I was using these instead of the current "waitforasync".
They technically work because they loop through every instance and wait for each of them to be started or stopped, but it's not very clean.