Skip to content

Commit 105ef1e

Browse files
authored
Merge pull request #983 from marcelmamula/saptune
sap_*_preconfigure/Suse: Enhance saptune revert logic
2 parents 243b84d + 9be2c15 commit 105ef1e

File tree

4 files changed

+96
-88
lines changed

4 files changed

+96
-88
lines changed

roles/sap_general_preconfigure/tasks/sapnote/2578899/configuration.yml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,44 @@
1717
when: __sap_general_preconfigure_grub_cmdline | length > 0
1818

1919

20-
- name: Apply SAP note 2578899 using saptune
20+
# Verify SAP Note before block and revert if found invalid
21+
- name: Verify SAP note 2578899 before changes
22+
ansible.builtin.command:
23+
cmd: saptune note verify 2578899
24+
register: __sap_general_preconfigure_verify_2578899_before
25+
changed_when: false
26+
ignore_errors: true
2127
when: __sap_general_preconfigure_use_saptune | d(true)
28+
29+
- name: Apply SAP note 2578899 using saptune
30+
when:
31+
- __sap_general_preconfigure_use_saptune | d(true)
32+
- __sap_general_preconfigure_verify_2578899_before.rc != 0
2233
block:
34+
- name: Revert SAP note 2578899
35+
ansible.builtin.command:
36+
cmd: saptune note revert 2578899
37+
changed_when: true
2338

24-
- name: Apply SAP note 2578899 using saptune
39+
- name: Apply SAP note 2578899
2540
ansible.builtin.command:
2641
cmd: saptune note apply 2578899
2742
changed_when: true
2843

29-
- name: Verify SAP note 2578899 using saptune
44+
- name: Verify SAP note 2578899 after changes
3045
ansible.builtin.command:
31-
cmd: saptune note verify 2578899
32-
register: __sap_general_preconfigure_saptune_verify_2578899
46+
cmd: saptune note verify --show-non-compliant 2578899
47+
register: __sap_general_preconfigure_verify_2578899_after
3348
changed_when: false
3449
ignore_errors: true
3550

3651
- name: Display error if saptune verify failed
3752
ansible.builtin.debug:
3853
msg: |
39-
{{ __sap_general_preconfigure_saptune_verify_2578899.stdout_lines }}
40-
{{ __sap_general_preconfigure_saptune_verify_2578899.stderr_lines }}
54+
{{ __sap_general_preconfigure_verify_2578899_after.stdout_lines }}
55+
{{ __sap_general_preconfigure_verify_2578899_after.stderr_lines }}
4156
when:
42-
__sap_general_preconfigure_saptune_verify_2578899.rc != 0
57+
__sap_general_preconfigure_verify_2578899_after.rc != 0
4358

4459

4560
- name: Configuration changes without saptune

roles/sap_hana_preconfigure/tasks/SLES/configuration.yml

Lines changed: 25 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -24,54 +24,43 @@
2424
- __sap_hana_preconfigure_use_saptune
2525

2626

27-
- name: Apply saptune solution
27+
# Verify SAP Solution before block and revert if found invalid
28+
- name: Verify saptune solution before changes
29+
ansible.builtin.command:
30+
cmd: "saptune solution verify {{ sap_hana_preconfigure_saptune_solution }}"
31+
register: __sap_hana_preconfigure_register_solution_verify_before
32+
changed_when: false
33+
failed_when: false
2834
when: __sap_hana_preconfigure_use_saptune
29-
block:
30-
- name: Discover active solution
31-
ansible.builtin.command:
32-
cmd: saptune solution enabled
33-
register: __sap_hana_preconfigure_register_saptune_status
34-
changed_when: false
35-
36-
- name: Set fact for active solution
37-
ansible.builtin.set_fact:
38-
# Capture the first block on none whitespace
39-
__sap_hana_preconfigure_register_solution_configured:
40-
"{{ (__sap_hana_preconfigure_register_saptune_status.stdout | regex_search('(\\S+)', '\\1'))[0] | default('NONE') }}"
4135

42-
43-
- name: Revert solution when different to sap_hana_preconfigure_saptune_solution
36+
- name: Apply saptune solution
37+
when:
38+
- __sap_hana_preconfigure_use_saptune
39+
- __sap_hana_preconfigure_register_solution_verify_before.rc != 0
40+
block:
41+
- name: Revert saptune configuration
4442
ansible.builtin.command:
45-
cmd: "saptune solution revert {{ __sap_hana_preconfigure_register_solution_configured }}"
43+
cmd: "saptune revert all"
4644
changed_when: true
47-
when:
48-
- __sap_hana_preconfigure_register_solution_configured != 'NONE'
49-
- __sap_hana_preconfigure_register_solution_configured != sap_hana_preconfigure_saptune_solution
50-
51-
52-
- name: Verify saptune solution
53-
ansible.builtin.command:
54-
cmd: "saptune solution verify {{ sap_hana_preconfigure_saptune_solution }}"
55-
register: __sap_hana_preconfigure_register_saptune_verify
56-
changed_when: false
57-
failed_when: false
58-
when:
59-
- __sap_hana_preconfigure_register_solution_configured == sap_hana_preconfigure_saptune_solution
60-
6145

6246
- name: Ensure saptune solution is applied
6347
ansible.builtin.command:
6448
cmd: "saptune solution apply {{ sap_hana_preconfigure_saptune_solution }}"
6549
changed_when: true
66-
when:
67-
- __sap_hana_preconfigure_register_solution_configured != sap_hana_preconfigure_saptune_solution
68-
or __sap_hana_preconfigure_register_saptune_verify.rc != 0
69-
7050

71-
- name: Ensure solution was successful
51+
- name: Verify saptune solution after changes
7252
ansible.builtin.command:
73-
cmd: "saptune solution verify {{ sap_hana_preconfigure_saptune_solution }}"
53+
cmd: "saptune solution verify --show-non-compliant {{ sap_hana_preconfigure_saptune_solution }}"
7454
changed_when: false
55+
failed_when: false
56+
register: __sap_hana_preconfigure_register_solution_verify_after
57+
58+
- name: Display error if saptune verify failed
59+
ansible.builtin.fail:
60+
msg: |
61+
{{ __sap_hana_preconfigure_register_solution_verify_after.stdout_lines }}
62+
{{ __sap_hana_preconfigure_register_solution_verify_after.stderr_lines }}
63+
when: __sap_hana_preconfigure_register_solution_verify_after.rc != 0
7564

7665

7766
- name: Configure - Include configuration actions for required sapnotes

roles/sap_hana_preconfigure/tasks/sapnote/2684254/configuration.yml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,44 @@
99
when: __sap_hana_preconfigure_grub_cmdline | length > 0
1010

1111

12-
- name: Apply SAP note 2684254 using saptune
12+
# Verify SAP Note before block and revert if found invalid
13+
- name: Verify SAP note 2684254 before changes
14+
ansible.builtin.command:
15+
cmd: saptune note verify 2684254
16+
register: __sap_hana_preconfigure_verify_2684254_before
17+
changed_when: false
18+
ignore_errors: true
1319
when: __sap_hana_preconfigure_use_saptune | d(true)
20+
21+
- name: Apply SAP note 2684254 using saptune
22+
when:
23+
-__sap_hana_preconfigure_use_saptune | d(true)
24+
- __sap_hana_preconfigure_verify_2684254_before.rc != 0
1425
block:
26+
- name: Revert SAP note 2684254
27+
ansible.builtin.command:
28+
cmd: saptune note revert 2684254
29+
changed_when: true
1530

16-
- name: Apply SAP note 2684254 using saptune
31+
- name: Apply SAP note 2684254
1732
ansible.builtin.command:
1833
cmd: saptune note apply 2684254
1934
changed_when: true
2035

21-
- name: Verify SAP note 2684254 using saptune
36+
- name: Verify SAP note 2684254 after changes
2237
ansible.builtin.command:
23-
cmd: saptune note verify 2684254
24-
register: __sap_hana_preconfigure_saptune_verify_2684254
38+
cmd: saptune note verify --show-non-compliant 2684254
39+
register: __sap_hana_preconfigure_verify_2684254_after
2540
changed_when: false
2641
ignore_errors: true
2742

2843
- name: Display error if saptune verify failed
2944
ansible.builtin.debug:
3045
msg: |
31-
{{ __sap_hana_preconfigure_saptune_verify_2684254.stdout_lines }}
32-
{{ __sap_hana_preconfigure_saptune_verify_2684254.stderr_lines }}
46+
{{ __sap_hana_preconfigure_verify_2684254_after.stdout_lines }}
47+
{{ __sap_hana_preconfigure_verify_2684254_after.stderr_lines }}
3348
when:
34-
__sap_hana_preconfigure_saptune_verify_2684254.rc != 0
49+
__sap_hana_preconfigure_verify_2684254_after.rc != 0
3550

3651

3752
- name: Configuration changes without saptune

roles/sap_netweaver_preconfigure/tasks/SLES/configuration.yml

Lines changed: 25 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,43 @@
11
# SPDX-License-Identifier: Apache-2.0
22
---
33

4-
- name: Apply saptune solution
4+
# Verify SAP Solution before block and revert if found invalid
5+
- name: Verify saptune solution before changes
6+
ansible.builtin.command:
7+
cmd: "saptune solution verify {{ sap_netweaver_preconfigure_saptune_solution }}"
8+
register: __sap_netweaver_preconfigure_register_solution_verify_before
9+
changed_when: false
10+
failed_when: false
511
when: __sap_netweaver_preconfigure_use_saptune
6-
block:
7-
- name: Discover active solution
8-
ansible.builtin.command:
9-
cmd: saptune solution enabled
10-
register: __sap_netweaver_preconfigure_register_saptune_status
11-
changed_when: false
12-
13-
- name: Set fact for active solution
14-
ansible.builtin.set_fact:
15-
# Capture the first block on none whitespace
16-
__sap_netweaver_preconfigure_register_solution_configured:
17-
"{{ (__sap_netweaver_preconfigure_register_saptune_status.stdout | regex_search('(\\S+)', '\\1'))[0] | default('NONE') }}"
1812

19-
20-
- name: Revert solution when different to sap_netweaver_preconfigure_saptune_solution
13+
- name: Apply saptune solution
14+
when:
15+
- __sap_netweaver_preconfigure_use_saptune
16+
- __sap_netweaver_preconfigure_register_solution_verify_before.rc != 0
17+
block:
18+
- name: Revert saptune configuration
2119
ansible.builtin.command:
22-
cmd: "saptune solution revert {{ __sap_netweaver_preconfigure_register_solution_configured }}"
20+
cmd: "saptune revert all"
2321
changed_when: true
24-
when:
25-
- __sap_netweaver_preconfigure_register_solution_configured != 'NONE'
26-
- __sap_netweaver_preconfigure_register_solution_configured != sap_netweaver_preconfigure_saptune_solution
27-
28-
29-
- name: Verify saptune solution
30-
ansible.builtin.command:
31-
cmd: "saptune solution verify {{ sap_netweaver_preconfigure_saptune_solution }}"
32-
register: __sap_netweaver_preconfigure_register_saptune_verify
33-
changed_when: false
34-
failed_when: false
35-
when:
36-
- __sap_netweaver_preconfigure_register_solution_configured == sap_netweaver_preconfigure_saptune_solution
37-
3822

3923
- name: Ensure saptune solution is applied
4024
ansible.builtin.command:
4125
cmd: "saptune solution apply {{ sap_netweaver_preconfigure_saptune_solution }}"
4226
changed_when: true
43-
when:
44-
- __sap_netweaver_preconfigure_register_solution_configured != sap_netweaver_preconfigure_saptune_solution
45-
or __sap_netweaver_preconfigure_register_saptune_verify.rc != 0
4627

47-
48-
- name: Ensure solution was successful
28+
- name: Ensure solution was successful after changes
4929
ansible.builtin.command:
50-
cmd: "saptune solution verify {{ sap_netweaver_preconfigure_saptune_solution }}"
30+
cmd: "saptune solution verify --show-non-compliant {{ sap_netweaver_preconfigure_saptune_solution }}"
5131
changed_when: false
32+
failed_when: false
33+
register: __sap_netweaver_preconfigure_register_solution_verify_after
34+
35+
- name: Display error if saptune verify failed
36+
ansible.builtin.fail:
37+
msg: |
38+
{{ __sap_netweaver_preconfigure_register_solution_verify_after.stdout_lines }}
39+
{{ __sap_netweaver_preconfigure_register_solution_verify_after.stderr_lines }}
40+
when: __sap_netweaver_preconfigure_register_solution_verify_after.rc != 0
5241

5342

5443
- name: Warn if not enough swap space is configured

0 commit comments

Comments
 (0)