Skip to content

Commit

Permalink
sap_ha_pacemaker_cluster: enh: SAP HAlib configuration
Browse files Browse the repository at this point in the history
- new: cluster command definition for RHEL and SLES
- new: SAP HAlib components defined for RHEL and SLES
- file rename: added ASCS/ERS words to postinstallation file name for clarity
  • Loading branch information
ja9fuchs committed Sep 25, 2023
1 parent 621bad6 commit 98df776
Show file tree
Hide file tree
Showing 11 changed files with 255 additions and 101 deletions.
8 changes: 8 additions & 0 deletions roles/sap_ha_pacemaker_cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,14 @@ This allows using the output file later as input file for additional custom step
When enabled this parameters file is also created when the playbook is run in check_mode (`--check`) and can be used to review the configuration parameters without executing actual changes on the target nodes.<br>
WARNING! This report may include sensitive details like secrets required for certain cluster resources!<br>

### sap_ha_pacemaker_cluster_enable_cluster_connector

- _Type:_ `bool`
- _Default:_ `True`

Enables/Disables the SAP HA Interface for SAP ABAP application server instances, also known as `sap_cluster_connector`.<br>
Set this parameter to 'false' if the SAP HA interface should not be installed and configured.<br>

### sap_ha_pacemaker_cluster_extra_packages

- _Type:_ `list`
Expand Down
4 changes: 4 additions & 0 deletions roles/sap_ha_pacemaker_cluster/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ sap_ha_pacemaker_cluster_vip_hana_secondary_resource_name: "vip_{{ sap_ha_pacema
# set this parameter to 'true'.
sap_ha_pacemaker_cluster_netweaver_ascs_ers_ensa1: false

# Enable/Disable sap_cluster_connector.
# Ref.: https://access.redhat.com/solutions/3606101
sap_ha_pacemaker_cluster_enable_cluster_connector: true

# Inherit common synonym NetWeaver parameters when defined.
sap_ha_pacemaker_cluster_netweaver_sid: "{{ sap_swpm_sid | default('') }}"
sap_ha_pacemaker_cluster_netweaver_abap_ascs_instance_number: "{{ sap_swpm_ascs_instance_nr | default('') }}"
Expand Down
7 changes: 7 additions & 0 deletions roles/sap_ha_pacemaker_cluster/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,13 @@ argument_specs:
- The standard NetWeaver ASCS/ERS cluster will be set up as ENSA2.
- Set this parameter to 'true' to configure it as ENSA1.

sap_ha_pacemaker_cluster_enable_cluster_connector:
type: bool
default: true
description:
- Enables/Disables the SAP HA Interface for SAP ABAP application server instances, also known as `sap_cluster_connector`.
- Set this parameter to 'false' if the SAP HA interface should not be installed and configured.

sap_ha_pacemaker_cluster_netweaver_sid:
description:
- SID of the NetWeaver instances.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
---
# After NetWeaver ASCS/ERS instances were configured in the cluster,
# they must be disabled from automatically (re)starting outside of
# cluster control.

- name: "SAP HA Pacemaker - (ASCS profile) Prevent automatic restart of enqueue server"
ansible.builtin.replace:
path: "{{ sap_ha_pacemaker_cluster_netweaver_abap_ascs_sapinstance_start_profile_string }}"
backup: true
regexp: 'Restart_Program_01'
replace: 'Start_Program_01'

- name: "SAP HA Pacemaker - (ERS profile) Prevent automatic restart"
ansible.builtin.replace:
path: "{{ sap_ha_pacemaker_cluster_netweaver_abap_ers_sapinstance_start_profile_string }}"
backup: true
regexp: 'Restart_Program_00'
replace: 'Start_Program_00'

# Comment out lines in /usr/sap/sapservices, which
# - contain the target instance profile names
# - are not commented out yet
- name: "SAP HA Pacemaker - Update /usr/sap/sapservices"
ansible.builtin.replace:
path: /usr/sap/sapservices
backup: true
regexp: '^([^#\n].+{{ sapserv_item }}.+)$'
replace: '# \1'
loop:
- "{{ sap_ha_pacemaker_cluster_netweaver_abap_ascs_sapinstance_instance_name }}"
- "{{ sap_ha_pacemaker_cluster_netweaver_abap_ers_sapinstance_instance_name }}"
loop_control:
loop_var: sapserv_item

- name: "SAP HA Pacemaker - (systemd) Check for ASCS/ERS services"
ansible.builtin.stat:
path: "/etc/systemd/system/SAP{{ sap_ha_pacemaker_cluster_netweaver_sid }}_{{ systemd_item }}.service"
loop:
- "{{ sap_ha_pacemaker_cluster_netweaver_abap_ascs_instance_number }}"
- "{{ sap_ha_pacemaker_cluster_netweaver_abap_ers_instance_number }}"
loop_control:
loop_var: systemd_item
label: "SAP{{ sap_ha_pacemaker_cluster_netweaver_sid }}_{{ systemd_item }}.service"
register: __sap_ha_pacemaker_cluster_register_instance_service

- name: "SAP HA Pacemaker - (systemd) Save found ASCS/ERS services"
ansible.builtin.set_fact:
sap_ha_pacemaker_cluster_instance_services_fact: "{{
__sap_ha_pacemaker_cluster_register_instance_service.results
| selectattr('stat.exists')
| map(attribute='stat.path')
| regex_replace('/etc/systemd/system/', '')
}}"

# BLOCK:
# When the systemd based SAP startup framework is used, make sure that the
# instance services do not auto-start.
- name: "SAP HA Pacemaker - Block to disable systemd auto-start of instances"
when:
- sap_ha_pacemaker_cluster_instance_services_fact is defined
- sap_ha_pacemaker_cluster_instance_services_fact | length > 0
block:

- name: "SAP HA Pacemaker - (systemd) Disable ASCS/ERS instance service"
ansible.builtin.service:
name: "{{ instance_srv_item }}"
enabled: false
loop: "{{ sap_ha_pacemaker_cluster_instance_services_fact }}"
loop_control:
loop_var: instance_srv_item

# Creates a config file for the services.
# Parent directories will be created when missing.
- name: "SAP HA Pacemaker - (systemd) Create ASCS/ERS instance unit config file"
ansible.builtin.lineinfile:
create: true
path: "/etc/systemd/system/{{ dropfile_item }}.d/HA.conf"
line: "[Service]"
owner: root
group: root
mode: '0644'
loop: "{{ sap_ha_pacemaker_cluster_instance_services_fact }}"
loop_control:
loop_var: dropfile_item

- name: "SAP HA Pacemaker - (systemd) Disable ASCS/ERS instance unit auto-restart"
ansible.builtin.lineinfile:
path: "/etc/systemd/system/{{ dropfile_item }}.d/HA.conf"
regex: '^Restart\s*=\s*no'
insertafter: '^[Service]$'
line: "Restart=no"
owner: root
group: root
mode: '0644'
loop: "{{ sap_ha_pacemaker_cluster_instance_services_fact }}"
loop_control:
loop_var: dropfile_item

### END of BLOCK for systemd setup.


# Block for configuring the SAP HA Interface (sap_cluster_connector).
#
# The 'sap-cluster-connector' package is already optionally added to
# '__sap_ha_pacemaker_cluster_sap_extra_packages'.
- name: "SAP HA Pacemaker - (SAP HAlib) Configure SAP HA Interface"
when:
- sap_ha_pacemaker_cluster_enable_cluster_connector
block:

- name: "SAP HA Pacemaker - (SAP HAlib) Add {{sap_ha_pacemaker_cluster_netweaver_sid | lower }}adm user to 'haclient' group"
ansible.builtin.user:
name: "{{ sap_ha_pacemaker_cluster_netweaver_sid | lower }}adm"
groups: haclient
append: true
state: present

# Using 'lineinfile' with a nested loop to avoid duplicate entries for existing configuration.
- name: "SAP HA Pacemaker - (SAP HAlib) Add connector to start profiles"
ansible.builtin.lineinfile:
backup: true
path: "{{ nwas_profile_item.0 }}"
line: "{{ nwas_profile_item.1 }}"
loop: "{{ __sap_ha_pacemaker_cluster_netweaver_abap_ascs_ers_profile_paths
| product(__sap_ha_pacemaker_cluster_connector_config_lines)
}}"
loop_control:
loop_var: nwas_profile_item
label: "{{ nwas_profile_item.0 }} -> {{ nwas_profile_item.1 }}"

- name: "SAP HA Pacemaker - (SAP HAlib) Check where ASCS is running"
become_user: "{{ sap_ha_pacemaker_cluster_netweaver_sid | lower }}adm"
register: __sap_ha_pacemaker_cluster_register_where_ascs
ansible.builtin.shell: |
/usr/sap/hostctrl/exe/sapcontrol -nr {{ sap_ha_pacemaker_cluster_netweaver_abap_ascs_instance_number }} -function GetProcessList
changed_when: false
failed_when: false

- name: "SAP HA Pacemaker - (SAP HAlib) Check where ERS is running"
become_user: "{{ sap_ha_pacemaker_cluster_netweaver_sid | lower }}adm"
register: __sap_ha_pacemaker_cluster_register_where_ers
ansible.builtin.shell: |
/usr/sap/hostctrl/exe/sapcontrol -nr {{ sap_ha_pacemaker_cluster_netweaver_abap_ers_instance_number }} -function GetProcessList
changed_when: false
failed_when: false

- name: "SAP HA Pacemaker - (SAP HAlib) Restart the ASCS service"
when:
- __sap_ha_pacemaker_cluster_register_where_ascs.rc == 3
become_user: "{{ sap_ha_pacemaker_cluster_netweaver_sid | lower }}adm"
register: __sap_ha_pacemaker_cluster_register_restart_ascs
ansible.builtin.shell: |
/usr/sap/hostctrl/exe/sapcontrol -nr {{ sap_ha_pacemaker_cluster_netweaver_abap_ascs_instance_number }} -function RestartService
changed_when: __sap_ha_pacemaker_cluster_register_restart_ascs.rc == 0

- name: "SAP HA Pacemaker - (SAP HAlib) Restart the ERS service"
when:
- __sap_ha_pacemaker_cluster_register_where_ers.rc == 3
become_user: "{{ sap_ha_pacemaker_cluster_netweaver_sid | lower }}adm"
register: __sap_ha_pacemaker_cluster_register_restart_ers
ansible.builtin.shell: |
/usr/sap/hostctrl/exe/sapcontrol -nr {{ sap_ha_pacemaker_cluster_netweaver_abap_ers_instance_number }} -function RestartService
changed_when: __sap_ha_pacemaker_cluster_register_restart_ers.rc == 0

- name: "SAP HA Pacemaker - (SAP HAlib) Run HA check for ASCS"
when:
- __sap_ha_pacemaker_cluster_register_where_ascs.rc == 3
become_user: "{{ sap_ha_pacemaker_cluster_netweaver_sid | lower }}adm"
register: __sap_ha_pacemaker_cluster_register_ascs_ha
ansible.builtin.shell: |
/usr/sap/hostctrl/exe/sapcontrol -nr {{ sap_ha_pacemaker_cluster_netweaver_abap_ascs_instance_number }} -function HACheckConfig
changed_when: false

- name: "SAP HA Pacemaker - (SAP HAlib) Run HA check for ERS"
when:
- __sap_ha_pacemaker_cluster_register_where_ers.rc == 3
become_user: "{{ sap_ha_pacemaker_cluster_netweaver_sid | lower }}adm"
register: __sap_ha_pacemaker_cluster_register_ers_ha
ansible.builtin.shell: |
/usr/sap/hostctrl/exe/sapcontrol -nr {{ sap_ha_pacemaker_cluster_netweaver_abap_ers_instance_number }} -function HACheckConfig
changed_when: false

- name: "SAP HA Pacemaker - (SAP HAlib) Display HA check results for ASCS"
when:
- __sap_ha_pacemaker_cluster_register_where_ascs.rc == 3
ansible.builtin.debug:
msg: |
{{ __sap_ha_pacemaker_cluster_register_ascs_ha.stdout }}
- name: "SAP HA Pacemaker - (SAP HAlib) Display HA check results for ERS"
when:
- __sap_ha_pacemaker_cluster_register_where_ers.rc == 3
ansible.builtin.debug:
msg: |
{{ __sap_ha_pacemaker_cluster_register_ers_ha.stdout }}
# TODO: verification checks that the instances are running and HAlib is enabled

### END of BLOCK for sap_cluster_connector.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@
# sap_ha_pacemaker_cluster_extra_packages -> user-defined, empty by global default
# __sap_ha_pacemaker_cluster_sap_extra_packages -> included from vars/*
# __sap_ha_pacemaker_cluster_platform_extra_packages -> included from vars/platform*
# Empty defaults defined here for optional non-user-facing parameters.

- name: "SAP HA Prepare Pacemaker - Combine extra packages lists"
ansible.builtin.set_fact:
__sap_ha_pacemaker_cluster_extra_packages: "{{ (
sap_ha_pacemaker_cluster_extra_packages
+ __sap_ha_pacemaker_cluster_sap_extra_packages
+ __sap_ha_pacemaker_cluster_platform_extra_packages
) | unique }}"

) | unique | select() }}"
# remove duplicates and empty elements

# sap_ha_pacemaker_cluster_fence_agent_minimal_packages -> global default
# sap_ha_pacemaker_cluster_fence_agent_packages -> global default
Expand Down
2 changes: 1 addition & 1 deletion roles/sap_ha_pacemaker_cluster/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@

- name: "SAP HA Install Pacemaker - Include NetWeaver ASCS/ERS post installation"
ansible.builtin.include_tasks:
file: configure_netweaver_postinstallation.yml
file: configure_netweaver_ascs_ers_postinstallation.yml
apply:
tags: nwas_postinst
tags: nwas_postinst
Expand Down
6 changes: 6 additions & 0 deletions roles/sap_ha_pacemaker_cluster/vars/nwas_abap_ascs_ers.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
---
#sap_ha_pacemaker_cluster_vip_resource_name: "vip_{{ sap_ha_pacemaker_cluster_netweaver_sid }}"

# List of ASCS/ERS profile names.
# Used in tasks/configure_netweaver_postinstallation.yml for sap_cluster_connector setup.
__sap_ha_pacemaker_cluster_netweaver_abap_ascs_ers_profile_paths:
- "{{ sap_ha_pacemaker_cluster_netweaver_abap_ascs_sapinstance_start_profile_string }}"
- "{{ sap_ha_pacemaker_cluster_netweaver_abap_ers_sapinstance_start_profile_string }}"
1 change: 1 addition & 0 deletions roles/sap_ha_pacemaker_cluster/vars/nwas_common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@

__sap_ha_pacemaker_cluster_sap_extra_packages:
- resource-agents-sap
- "{% if sap_ha_pacemaker_cluster_enable_cluster_connector %}{{ __sap_ha_pacemaker_cluster_halib_package }}{% endif %}"
13 changes: 13 additions & 0 deletions roles/sap_ha_pacemaker_cluster/vars/redhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,16 @@
__sap_ha_pacemaker_cluster_repos:
- id: "rhel-{{ ansible_distribution_major_version }}-for-{{ ansible_architecture }}-highavailability-e4s-rpms"
name: High Availability

__sap_ha_pacemaker_cluster_halib_package: sap-cluster-connector

# List of configuration lines that must be added to the instance profiles.
# Used in tasks/configure_netweaver_ascs_ers_postinstallation.yml for SAP HAlib setup.
__sap_ha_pacemaker_cluster_connector_config_lines:
- "service/halib = $(DIR_EXECUTABLE)/saphascriptco.so"
- "service/halib_cluster_connector = /usr/bin/sap_cluster_connector"

# Cluster command to manage resources - pcs commands in Redhat OS family.
__sap_ha_pacemaker_cluster_command:
resource_stop: "pcs resource disable"
resource_start: "pcs resource enable"
Loading

0 comments on commit 98df776

Please sign in to comment.