Skip to content

Commit e7ba258

Browse files
authored
Merge pull request sap-linuxlab#1173 from marcelmamula/hana-pre-tasks
sap_ha_pacemaker_cluster: Split off HANA pre_tasks from include_vars and add new force mode
2 parents b095893 + 0beee58 commit e7ba258

13 files changed

Lines changed: 254 additions & 158 deletions

File tree

roles/sap_ha_pacemaker_cluster/README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -969,11 +969,24 @@ sap_ha_pacemaker_cluster_resource_defaults:
969969
```
970970

971971
### sap_ha_pacemaker_cluster_saphanasr_angi_detection
972-
- _Type:_ `string`
972+
- _Type:_ `bool`
973973
- _Default:_ `true`
974974

975-
Disabling this variable enables to use Classic SAPHanaSR agents even on server, where SAPHanaSR-angi is available.<br>
976-
Value `false` (Classic) is ignored when only SAPHanaSR-angi packages are available.<br>
975+
Set to 'false' to disable auto-detection of SAP HANA Angi resource agent and use Classic agents.<br>
976+
This role does not substitute Migration procedure from Classic to Angi on existing cluster,<br>
977+
but rather new cluster setup with Angi resource agent when detected.<br>
978+
979+
### sap_ha_pacemaker_cluster_saphanasr_angi_force
980+
- _Type:_ `bool`
981+
- _Default:_ `false`
982+
983+
Set to 'true' to uninstall conflicting packages before using SAP HANA Angi.<br>
984+
This is destructive step if executed on running cluster without proper migration to SAP HANA Angi resource agent!<br>
985+
This is one-way process and it cannot be reverted by this role.<br>
986+
Reinstallation of removed packages is required to get back to the previous state.<br>
987+
Example for SAP HANA Scale-Up:<br>
988+
- RedHat: 'resource-agents-sap-hana' conflicts with SAP HANA Angi package 'sap-hana-ha'.<br>
989+
- Suse: 'SAPHanaSR' conflicts with SAP HANA Angi package 'SAPHanaSR-angi'.<br>
977990

978991
### sap_ha_pacemaker_cluster_sbd_devices
979992
- _Type:_ `list`

roles/sap_ha_pacemaker_cluster/defaults/main.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,20 @@ sap_ha_pacemaker_cluster_hana_hook_chksrv: false
180180
# SAP Hana global.ini path calculated from SID
181181
sap_ha_pacemaker_cluster_hana_global_ini_path: '' # Default: /usr/sap/<SID>/SYS/global/hdb/custom/config/global.ini
182182

183-
# Disable auto-detection of SAPHanaSR-angi package and use Classic
183+
# Set to 'false' to disable auto-detection of SAP HANA Angi resource agent and use Classic agents.
184+
# This role does not substitute Migration procedure from Classic to Angi on existing cluster,
185+
# but rather new cluster setup with Angi resource agent when detected.
184186
sap_ha_pacemaker_cluster_saphanasr_angi_detection: true
185187

188+
# Set to 'true' to uninstall conflicting packages before using SAP HANA Angi.
189+
# This is destructive step if executed on running cluster without proper migration to SAP HANA Angi resource agent!
190+
# This is one-way process and it cannot be reverted by this role.
191+
# Reinstallation of removed packages is required to get back to the previous state.
192+
# Example for SAP HANA Scale-Up:
193+
# RedHat: 'resource-agents-sap-hana' conflicts with SAP HANA Angi package 'sap-hana-ha'.
194+
# Suse: 'SAPHanaSR' conflicts with SAP HANA Angi package 'SAPHanaSR-angi'.
195+
sap_ha_pacemaker_cluster_saphanasr_angi_force: false
196+
186197
################################################################################
187198
# NetWeaver generic definitions
188199
################################################################################

roles/sap_ha_pacemaker_cluster/meta/argument_specs.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -604,11 +604,24 @@ argument_specs:
604604
- Path with location of global.ini for srHook update
605605

606606
sap_ha_pacemaker_cluster_saphanasr_angi_detection:
607+
type: bool
607608
default: true
608609
description:
609-
- Disabling this variable enables to use Classic SAPHanaSR agents even on server,
610-
where SAPHanaSR-angi is available.
611-
- Value `false` (Classic) is ignored when only SAPHanaSR-angi packages are available.
610+
- Set to 'false' to disable auto-detection of SAP HANA Angi resource agent and use Classic agents.
611+
- This role does not substitute Migration procedure from Classic to Angi on existing cluster,
612+
- but rather new cluster setup with Angi resource agent when detected.
613+
614+
sap_ha_pacemaker_cluster_saphanasr_angi_force:
615+
type: bool
616+
default: false
617+
description:
618+
- Set to 'true' to uninstall conflicting packages before using SAP HANA Angi.
619+
- This is destructive step if executed on running cluster without proper migration to SAP HANA Angi resource agent!
620+
- This is one-way process and it cannot be reverted by this role.
621+
- Reinstallation of removed packages is required to get back to the previous state.
622+
- "Example for SAP HANA Scale-Up:"
623+
- "- RedHat: 'resource-agents-sap-hana' conflicts with SAP HANA Angi package 'sap-hana-ha'."
624+
- "- Suse: 'SAPHanaSR' conflicts with SAP HANA Angi package 'SAPHanaSR-angi'."
612625

613626
##########################################################################
614627
# NetWeaver specific parameters
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
---
3+
4+
# NOTE: If list of packages is needed in future, these tasks need to be updated to assert loop results.
5+
6+
- name: Block for SAP HANA Angi detection
7+
when:
8+
- sap_ha_pacemaker_cluster_saphanasr_angi_detection
9+
- __sap_ha_pacemaker_cluster_saphanasr_angi_package_name | trim | length > 0
10+
block:
11+
12+
- name: SAP HA Prepare Pacemaker - Check if SAP HANA Angi package is available for installation
13+
ansible.builtin.command:
14+
cmd: dnf list --available {{ __sap_ha_pacemaker_cluster_saphanasr_angi_package_name }}
15+
changed_when: false
16+
check_mode: false
17+
register: __sap_ha_pacemaker_cluster_register_saphanasr_angi_exists
18+
failed_when: false
19+
20+
- name: SAP HA Prepare Pacemaker - Assert that the SAP HANA Angi package is available
21+
ansible.builtin.assert:
22+
that:
23+
- __sap_ha_pacemaker_cluster_register_saphanasr_angi_exists.rc == 0
24+
- __sap_ha_pacemaker_cluster_saphanasr_angi_package_name in __sap_ha_pacemaker_cluster_register_saphanasr_angi_exists.stdout
25+
fail_msg: |
26+
FAIL: Required package '{{ __sap_ha_pacemaker_cluster_saphanasr_angi_package_name }}' was not found in repositories.
27+
Please make sure that the package is available for installation before executing the role again.
28+
29+
30+
- name: Block for defined conflicting packages
31+
when: __sap_ha_pacemaker_cluster_saphanasr_angi_package_conflicts | length > 0
32+
block:
33+
- name: SAP HA Prepare Pacemaker - Gather installed packages facts
34+
ansible.builtin.package_facts:
35+
manager: auto
36+
37+
# Force var is part of assert because it passes only if force is enabled or conflicting package is not installed.
38+
- name: SAP HA Prepare Pacemaker - Assert that conflicting package was not found when force is not enabled
39+
ansible.builtin.assert:
40+
that:
41+
- sap_ha_pacemaker_cluster_saphanasr_angi_force
42+
or (__sap_ha_pacemaker_cluster_saphanasr_angi_package_conflicts | d([]) | intersect(ansible_facts.packages | list) | length == 0)
43+
fail_msg: |
44+
FAIL: Conflicting packages '{{ __sap_ha_pacemaker_cluster_saphanasr_angi_package_conflicts | join(", ") }}' are installed.
45+
Uninstall these packages or set 'sap_ha_pacemaker_cluster_saphanasr_angi_force' to 'true' before executing the role again.
46+
47+
48+
- name: SAP HA Prepare Pacemaker - Show information about upcoming removal of conflicting packages when force is enabled
49+
ansible.builtin.debug:
50+
msg: |
51+
INFO: Conflicting packages '{{ __sap_ha_pacemaker_cluster_saphanasr_angi_package_conflicts | d([])| intersect(ansible_facts.packages | list)
52+
| join(", ") }}' are installed, but 'sap_ha_pacemaker_cluster_saphanasr_angi_force' is set to 'true'.
53+
The role will attempt to remove these packages during execution.
54+
when:
55+
- sap_ha_pacemaker_cluster_saphanasr_angi_force
56+
- __sap_ha_pacemaker_cluster_saphanasr_angi_package_conflicts | d([]) | intersect(ansible_facts.packages | list) | length > 0
57+
58+
- name: SAP HA Prepare Pacemaker - Set fact that SAP HANA Angi is available if asserts passed
59+
ansible.builtin.set_fact:
60+
__sap_ha_pacemaker_cluster_saphanasr_angi_available: true
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
---
3+
4+
# NOTE: If list of packages is needed in future, these tasks need to be updated to assert loop results.
5+
6+
- name: Block for SAP HANA Angi detection
7+
when:
8+
- sap_ha_pacemaker_cluster_saphanasr_angi_detection
9+
- __sap_ha_pacemaker_cluster_saphanasr_angi_package_name | trim | length > 0
10+
block:
11+
12+
- name: SAP HA Prepare Pacemaker - Check if SAP HANA Angi package is available for installation
13+
ansible.builtin.command:
14+
cmd: zypper search --provides --match-exact {{ __sap_ha_pacemaker_cluster_saphanasr_angi_package_name }}
15+
changed_when: false
16+
check_mode: false
17+
register: __sap_ha_pacemaker_cluster_register_saphanasr_angi_exists
18+
failed_when: false
19+
20+
- name: SAP HA Prepare Pacemaker - Assert that the SAP HANA Angi package is available
21+
ansible.builtin.assert:
22+
that:
23+
- __sap_ha_pacemaker_cluster_register_saphanasr_angi_exists.rc == 0
24+
- __sap_ha_pacemaker_cluster_saphanasr_angi_package_name in __sap_ha_pacemaker_cluster_register_saphanasr_angi_exists.stdout
25+
fail_msg: |
26+
FAIL: Required package '{{ __sap_ha_pacemaker_cluster_saphanasr_angi_package_name }}' was not found in repositories.
27+
Please make sure that the package is available for installation before executing the role again.
28+
29+
30+
- name: Block for defined conflicting packages
31+
when: __sap_ha_pacemaker_cluster_saphanasr_angi_package_conflicts | length > 0
32+
block:
33+
# Reason for noqa: rpm is used directly instead of ansible package facts to remove 'rpm' library dependency.
34+
- name: SAP HA Prepare Pacemaker - Check the availability of conflicting package 'SAPHanaSR' # noqa: command-instead-of-module
35+
ansible.builtin.command:
36+
cmd: rpm -q {{ conflict_item }}
37+
loop: "{{ __sap_ha_pacemaker_cluster_saphanasr_angi_package_conflicts }}"
38+
loop_control:
39+
loop_var: conflict_item
40+
register: __sap_ha_pacemaker_cluster_register_saphanasr_conflict
41+
changed_when: false
42+
check_mode: false
43+
failed_when: false # avoid failure in logs if package is not installed
44+
45+
# Force var is part of assert because it passes only if force is enabled or conflicting package is not installed.
46+
- name: SAP HA Prepare Pacemaker - Assert that conflicting package was not found when force is not enabled
47+
ansible.builtin.assert:
48+
that:
49+
- sap_ha_pacemaker_cluster_saphanasr_angi_force
50+
or (__sap_ha_pacemaker_cluster_register_saphanasr_conflict.results | selectattr('rc', 'equalto', 0) | list | length == 0)
51+
fail_msg: |
52+
FAIL: Conflicting packages '{{ __sap_ha_pacemaker_cluster_saphanasr_angi_package_conflicts | join(", ") }}' are installed.
53+
Uninstall these packages or set 'sap_ha_pacemaker_cluster_saphanasr_angi_force' to 'true' before executing the role again.
54+
55+
56+
- name: SAP HA Prepare Pacemaker - Show information about upcoming removal of conflicting packages when force is enabled
57+
ansible.builtin.debug:
58+
msg: |
59+
INFO: Conflicting packages '{{ __sap_ha_pacemaker_cluster_register_saphanasr_conflict.results | selectattr('rc', 'equalto', 0)
60+
| map(attribute='conflict_item') | list | join(", ") }}' are installed, but 'sap_ha_pacemaker_cluster_saphanasr_angi_force' is set to 'true'.
61+
The role will attempt to remove these packages during execution.
62+
when:
63+
- sap_ha_pacemaker_cluster_saphanasr_angi_force
64+
- __sap_ha_pacemaker_cluster_register_saphanasr_conflict.results | selectattr('rc', 'equalto', 0) | list | length > 0
65+
66+
- name: SAP HA Prepare Pacemaker - Set fact that SAP HANA Angi is available if asserts passed
67+
ansible.builtin.set_fact:
68+
__sap_ha_pacemaker_cluster_saphanasr_angi_available: true

roles/sap_ha_pacemaker_cluster/tasks/include_vars/detect_sap_landscape.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
Conflicting host types found!
4747
There can only be max. 1 HANA and/or 1 NWAS (A)SCS/ERS type in the same definition.
4848
49+
4950
- name: "SAP HA Prepare Pacemaker - Include HANA specific variables"
5051
ansible.builtin.include_tasks:
5152
file: include_vars/include_hana.yml

roles/sap_ha_pacemaker_cluster/tasks/include_vars/include_hana.yml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
# SPDX-License-Identifier: Apache-2.0
22
---
3-
# Detect presence of SAPHanaSR-angi package before loading HANA variables
4-
# Detection of package availability was chosen instead of OS version check.
5-
# SAPHanaSR-angi will be retrofitted to older SP repositories in future.
6-
# NOTE: This task is doing changes and should not be run in variable section!
7-
# TODO: Split and move to pre-tasks.
8-
- name: "SAP HA Install Pacemaker - Include HANA pre-tasks"
3+
4+
# Detect presence of SAP HANA packages before loading HANA variables.
5+
# This is used to populate accurate value of '__sap_ha_pacemaker_cluster_saphanasr_angi_available' used in set_facts.
6+
- name: "SAP HA Install Pacemaker - Detect SAP HANA packages"
97
ansible.builtin.include_tasks:
10-
# We cannot use full path as long as this task is in wrong place.
11-
file: "../{{ __task_file }}"
8+
file: "{{ __task_file }}"
9+
apply:
10+
tags: pre_ha_cluster
1211
vars:
13-
__task_file: "pre_tasks/{{ ansible_facts['os_family'] }}/pre_hana.yml"
14-
__task_file_path: "{{ role_path }}/tasks/{{ __task_file }}"
12+
__task_file: "{{ ansible_facts['os_family'] }}/detect_hana.yml"
13+
__task_file_path: "{{ role_path }}/tasks/include_vars/{{ __task_file }}"
1514
when:
1615
- __task_file_path is file
17-
- sap_ha_pacemaker_cluster_host_type | select('search', 'hana') | length > 0
1816

1917

2018
- name: "SAP HA Prepare Pacemaker - Include HANA landscape specific variables"
Lines changed: 17 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,20 @@
11
# SPDX-License-Identifier: Apache-2.0
22
---
3-
# Identify if 'sap-hana-ha' package is available for installation.
4-
# sap-hana-ha replaces resource-agents-sap-hana and resource-agents-sap-hana-scaleout.
53

6-
- name: "SAP HA Prepare Pacemaker - Block for detection of 'SAPHanaSR-angi'"
7-
when: (sap_ha_pacemaker_cluster_saphanasr_angi_detection | bool)
8-
block:
9-
10-
- name: "SAP HA Prepare Pacemaker - Gather installed packages facts"
11-
ansible.builtin.package_facts:
12-
manager: auto
13-
14-
- name: "SAP HA Prepare Pacemaker - Check the availability of 'sap-hana-ha'"
15-
ansible.builtin.command:
16-
cmd: dnf provides sap-hana-ha
17-
changed_when: false
18-
check_mode: false
19-
register: __sap_ha_pacemaker_cluster_saphanasr_angi_check
20-
failed_when:
21-
- __sap_ha_pacemaker_cluster_saphanasr_angi_check.rc != 0
22-
- __sap_ha_pacemaker_cluster_saphanasr_angi_check.rc != 1
23-
24-
# The provision role should not fix packages if run against systems that
25-
# were previously installed with the conflicting packages. System state is
26-
# unclear at this moment and the role should rather fail early.
27-
- name: "SAP HA Prepare Pacemaker - Fail if there are package conflicts"
28-
ansible.builtin.assert:
29-
that:
30-
- "'resource-agents-sap-hana' not in packages or
31-
__sap_ha_pacemaker_cluster_saphanasr_angi_check.rc == 0"
32-
fail_msg: |
33-
34-
ERROR: Conflicting packages.
35-
36-
Package available and to be installed: sap-hana-ha
37-
38-
Conflicting packages are installed:
39-
{% for finding in (packages | select('match', 'resource-agents-sap.*')) %}
40-
- {{ finding }}
41-
{% endfor %}
42-
43-
Remove the conflicting packages to continue the setup with the
44-
detected resource agent package.
45-
Alternatively: Disable the package detection
46-
(sap_ha_pacemaker_cluster_saphanasr_angi_detection = false)
47-
to continue the setup using the installed resource agents.
48-
when:
49-
- __sap_ha_pacemaker_cluster_saphanasr_angi_check is defined
50-
- __sap_ha_pacemaker_cluster_saphanasr_angi_check.rc == 0
51-
52-
- name: "SAP HA Prepare Pacemaker - Set fact angi_available"
53-
ansible.builtin.set_fact:
54-
__sap_ha_pacemaker_cluster_saphanasr_angi_available: true
55-
when:
56-
- __sap_ha_pacemaker_cluster_saphanasr_angi_check is defined
57-
- __sap_ha_pacemaker_cluster_saphanasr_angi_check.rc == 0
4+
# This task does not use the variable 'sap_ha_pacemaker_cluster_saphanasr_angi_force' directly,
5+
# because it will always fail in include_vars assert section if it is in wrong state 'false'.
6+
- name: SAP HA Prepare Pacemaker - Remove packages conflicting with SAP HANA Angi
7+
ansible.builtin.package:
8+
name: "{{ package_item }}"
9+
state: absent
10+
loop: "{{ __sap_ha_pacemaker_cluster_saphanasr_angi_package_conflicts | intersect(ansible_facts.packages | list) }}"
11+
loop_control:
12+
loop_var: package_item
13+
when:
14+
- sap_ha_pacemaker_cluster_saphanasr_angi_detection
15+
- __sap_ha_pacemaker_cluster_saphanasr_angi_available
16+
- __sap_ha_pacemaker_cluster_saphanasr_angi_package_conflicts | length > 0
17+
18+
# NOTE: Removal of SAP HANA Angi was removed from pre tasks.
19+
# Migration from Classic to Angi should be considered one-way process and it cannot be reverted by this role.
20+
# Reinstallation of removed packages is required to get back to the previous state.

0 commit comments

Comments
 (0)