From 98df7769588b67cb498ddcad3299c866ba17ca25 Mon Sep 17 00:00:00 2001 From: Janine Fuchs Date: Mon, 25 Sep 2023 17:42:21 +0200 Subject: [PATCH 1/7] sap_ha_pacemaker_cluster: enh: SAP HAlib configuration - 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 --- roles/sap_ha_pacemaker_cluster/README.md | 8 + .../defaults/main.yml | 4 + .../meta/argument_specs.yml | 7 + ...re_netweaver_ascs_ers_postinstallation.yml | 200 ++++++++++++++++++ .../configure_netweaver_postinstallation.yml | 97 --------- .../tasks/construct_vars_common.yml | 5 +- roles/sap_ha_pacemaker_cluster/tasks/main.yml | 2 +- .../vars/nwas_abap_ascs_ers.yml | 6 + .../vars/nwas_common.yml | 1 + .../sap_ha_pacemaker_cluster/vars/redhat.yml | 13 ++ roles/sap_ha_pacemaker_cluster/vars/suse.yml | 13 ++ 11 files changed, 255 insertions(+), 101 deletions(-) create mode 100644 roles/sap_ha_pacemaker_cluster/tasks/configure_netweaver_ascs_ers_postinstallation.yml delete mode 100644 roles/sap_ha_pacemaker_cluster/tasks/configure_netweaver_postinstallation.yml create mode 100644 roles/sap_ha_pacemaker_cluster/vars/suse.yml diff --git a/roles/sap_ha_pacemaker_cluster/README.md b/roles/sap_ha_pacemaker_cluster/README.md index 3e212c297..e34db31e5 100644 --- a/roles/sap_ha_pacemaker_cluster/README.md +++ b/roles/sap_ha_pacemaker_cluster/README.md @@ -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.
WARNING! This report may include sensitive details like secrets required for certain cluster resources!
+### 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`.
+Set this parameter to 'false' if the SAP HA interface should not be installed and configured.
+ ### sap_ha_pacemaker_cluster_extra_packages - _Type:_ `list` diff --git a/roles/sap_ha_pacemaker_cluster/defaults/main.yml b/roles/sap_ha_pacemaker_cluster/defaults/main.yml index 062c04aa3..760b03bd9 100644 --- a/roles/sap_ha_pacemaker_cluster/defaults/main.yml +++ b/roles/sap_ha_pacemaker_cluster/defaults/main.yml @@ -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('') }}" diff --git a/roles/sap_ha_pacemaker_cluster/meta/argument_specs.yml b/roles/sap_ha_pacemaker_cluster/meta/argument_specs.yml index eddf1b298..19e2a063a 100644 --- a/roles/sap_ha_pacemaker_cluster/meta/argument_specs.yml +++ b/roles/sap_ha_pacemaker_cluster/meta/argument_specs.yml @@ -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. diff --git a/roles/sap_ha_pacemaker_cluster/tasks/configure_netweaver_ascs_ers_postinstallation.yml b/roles/sap_ha_pacemaker_cluster/tasks/configure_netweaver_ascs_ers_postinstallation.yml new file mode 100644 index 000000000..0660a3aab --- /dev/null +++ b/roles/sap_ha_pacemaker_cluster/tasks/configure_netweaver_ascs_ers_postinstallation.yml @@ -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. diff --git a/roles/sap_ha_pacemaker_cluster/tasks/configure_netweaver_postinstallation.yml b/roles/sap_ha_pacemaker_cluster/tasks/configure_netweaver_postinstallation.yml deleted file mode 100644 index e23612358..000000000 --- a/roles/sap_ha_pacemaker_cluster/tasks/configure_netweaver_postinstallation.yml +++ /dev/null @@ -1,97 +0,0 @@ ---- -# 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 units" - 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 diff --git a/roles/sap_ha_pacemaker_cluster/tasks/construct_vars_common.yml b/roles/sap_ha_pacemaker_cluster/tasks/construct_vars_common.yml index d990853b9..f25a1504f 100644 --- a/roles/sap_ha_pacemaker_cluster/tasks/construct_vars_common.yml +++ b/roles/sap_ha_pacemaker_cluster/tasks/construct_vars_common.yml @@ -25,7 +25,6 @@ # 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: @@ -33,8 +32,8 @@ 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 diff --git a/roles/sap_ha_pacemaker_cluster/tasks/main.yml b/roles/sap_ha_pacemaker_cluster/tasks/main.yml index f13fe361a..71139b5d5 100644 --- a/roles/sap_ha_pacemaker_cluster/tasks/main.yml +++ b/roles/sap_ha_pacemaker_cluster/tasks/main.yml @@ -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 diff --git a/roles/sap_ha_pacemaker_cluster/vars/nwas_abap_ascs_ers.yml b/roles/sap_ha_pacemaker_cluster/vars/nwas_abap_ascs_ers.yml index 04197d622..46e12821a 100644 --- a/roles/sap_ha_pacemaker_cluster/vars/nwas_abap_ascs_ers.yml +++ b/roles/sap_ha_pacemaker_cluster/vars/nwas_abap_ascs_ers.yml @@ -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 }}" diff --git a/roles/sap_ha_pacemaker_cluster/vars/nwas_common.yml b/roles/sap_ha_pacemaker_cluster/vars/nwas_common.yml index e23244431..c74b238e6 100644 --- a/roles/sap_ha_pacemaker_cluster/vars/nwas_common.yml +++ b/roles/sap_ha_pacemaker_cluster/vars/nwas_common.yml @@ -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 %}" diff --git a/roles/sap_ha_pacemaker_cluster/vars/redhat.yml b/roles/sap_ha_pacemaker_cluster/vars/redhat.yml index a65619099..72ed6ca32 100644 --- a/roles/sap_ha_pacemaker_cluster/vars/redhat.yml +++ b/roles/sap_ha_pacemaker_cluster/vars/redhat.yml @@ -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" diff --git a/roles/sap_ha_pacemaker_cluster/vars/suse.yml b/roles/sap_ha_pacemaker_cluster/vars/suse.yml new file mode 100644 index 000000000..6b54f8c59 --- /dev/null +++ b/roles/sap_ha_pacemaker_cluster/vars/suse.yml @@ -0,0 +1,13 @@ +--- +__sap_ha_pacemaker_cluster_halib_package: sap-suse-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_suse_cluster_connector" + +# Cluster commands to manage resources - crmsh commands in SUSE OS family. +__sap_ha_pacemaker_cluster_command: + resource_stop: "crm resource stop" + resource_start: "crm resource start" From 05f89d3f19a9f92a1560c55937d7ca244f920f42 Mon Sep 17 00:00:00 2001 From: Janine Fuchs Date: Mon, 25 Sep 2023 18:10:23 +0200 Subject: [PATCH 2/7] sap_ha_pacemaker_cluster: moved cluster commands to rhel/sles chosen syntax --- roles/sap_ha_pacemaker_cluster/tasks/main.yml | 4 ++-- roles/sap_ha_pacemaker_cluster/vars/redhat.yml | 2 ++ roles/sap_ha_pacemaker_cluster/vars/suse.yml | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/roles/sap_ha_pacemaker_cluster/tasks/main.yml b/roles/sap_ha_pacemaker_cluster/tasks/main.yml index 71139b5d5..efcb6aed0 100644 --- a/roles/sap_ha_pacemaker_cluster/tasks/main.yml +++ b/roles/sap_ha_pacemaker_cluster/tasks/main.yml @@ -172,7 +172,7 @@ - name: "SAP HA Install Pacemaker - Check resource defaults" ansible.builtin.command: cmd: | - pcs resource defaults config + {{ __sap_ha_pacemaker_cluster_command.resource_defaults_show }} register: __sap_ha_pacemaker_cluster_check_resource_defaults run_once: true changed_when: false @@ -185,7 +185,7 @@ - __sap_ha_pacemaker_cluster_resource_defaults | length > 0 ansible.builtin.command: cmd: | - pcs resource defaults update {{ item.key }}={{ item.value }} + {{ __sap_ha_pacemaker_cluster_command.resource_defaults_update }} {{ item.key }}={{ item.value }} loop: "{{ __sap_ha_pacemaker_cluster_resource_defaults | dict2items }}" loop_control: label: "{{ item.key }}={{ item.value }}" diff --git a/roles/sap_ha_pacemaker_cluster/vars/redhat.yml b/roles/sap_ha_pacemaker_cluster/vars/redhat.yml index 72ed6ca32..e8bcccc3c 100644 --- a/roles/sap_ha_pacemaker_cluster/vars/redhat.yml +++ b/roles/sap_ha_pacemaker_cluster/vars/redhat.yml @@ -17,3 +17,5 @@ __sap_ha_pacemaker_cluster_connector_config_lines: __sap_ha_pacemaker_cluster_command: resource_stop: "pcs resource disable" resource_start: "pcs resource enable" + resource_defaults_show: "pcs resource defaults config" + resource_defaults_update: "pcs resource defaults update" diff --git a/roles/sap_ha_pacemaker_cluster/vars/suse.yml b/roles/sap_ha_pacemaker_cluster/vars/suse.yml index 6b54f8c59..33314e950 100644 --- a/roles/sap_ha_pacemaker_cluster/vars/suse.yml +++ b/roles/sap_ha_pacemaker_cluster/vars/suse.yml @@ -11,3 +11,5 @@ __sap_ha_pacemaker_cluster_connector_config_lines: __sap_ha_pacemaker_cluster_command: resource_stop: "crm resource stop" resource_start: "crm resource start" + resource_defaults_show: "crm configure show type:rsc_defaults" + resource_defaults_update: "crm configure rsc_defaults" From e85c390d0c9ddae472c567e1a9961420cfa11f82 Mon Sep 17 00:00:00 2001 From: Janine Fuchs Date: Tue, 26 Sep 2023 09:41:38 +0200 Subject: [PATCH 3/7] sap_ha_pacemaker_cluster: updated hana sample and added nw sample playbook --- ...-sap-ha-deployment-hana-2-node-cluster.yml | 5 +- ...ample-sap-nwas-ascs-ers-2-node-cluster.yml | 77 +++++++++++++++++++ 2 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 playbooks/sample-sap-nwas-ascs-ers-2-node-cluster.yml diff --git a/playbooks/sample-sap-ha-deployment-hana-2-node-cluster.yml b/playbooks/sample-sap-ha-deployment-hana-2-node-cluster.yml index db15fcb50..46d6166a6 100644 --- a/playbooks/sample-sap-ha-deployment-hana-2-node-cluster.yml +++ b/playbooks/sample-sap-ha-deployment-hana-2-node-cluster.yml @@ -48,10 +48,9 @@ node_role: secondary hana_site: DC02 - sap_hana_vip: - primary: 192.168.1.100 + sap_ha_pacemaker_cluster_vip_hana_primary_ip_address: 192.168.1.100 - ha_cluster_fence_agent_packages: + sap_ha_pacemaker_cluster_fence_agent_packages: - fence-agents-rhevm sap_ha_pacemaker_cluster_stonith_custom: diff --git a/playbooks/sample-sap-nwas-ascs-ers-2-node-cluster.yml b/playbooks/sample-sap-nwas-ascs-ers-2-node-cluster.yml new file mode 100644 index 000000000..7363a3350 --- /dev/null +++ b/playbooks/sample-sap-nwas-ascs-ers-2-node-cluster.yml @@ -0,0 +1,77 @@ +--- +# This playbook will +# - install and configure a basic pacemaker cluster +# - configure the SAP NetWeaver ASCS/ERS resource groups with each +# - an instance filesystem +# - the instance resource +# - an instance service VIP + +# To use this playbook in your test environment +# please update the "vars" parameters with values +# corresponding to your individual naming standards +# and infrastructure (e.g. IP definitions matching your network). +# +# NOTE: +# For simplicity the sample password values are plain text. Please make sure to +# apply security measures to any credentials, for instance using ansible-vault +# encryption. + +- name: "Install and Configure a Pacemaker Cluster on 2 NetWeaver ASCS/ERS nodes" + hosts: ascs-node, ers-node + become: true +# any_error_fatal: true + + vars: + ############################################################################ + ### MANDATORY parameter definitions for a NetWeaver ASCS/ERS cluster setup. + ############################################################################ + + ### General minimum pacemaker cluster definitions. + sap_ha_pacemaker_cluster_cluster_name: ascs-ers-cluster + sap_ha_pacemaker_cluster_hacluster_password: my-hacluster-vault-password + + ### NetWeaver specific definitions + sap_ha_pacemaker_cluster_storage_nfs_server: "nfs-server1.example.com:/" + + # Underlying filesystems are derived from the parent "/usr/sap" definition. + sap_ha_pacemaker_cluster_storage_definition: + - name: usr_sap + mountpoint: /usr/sap + nfs_path: /usr/sap + nfs_server: "{{ sap_ha_pacemaker_cluster_storage_nfs_server }}" + + - name: usr_sap_trans + mountpoint: /usr/sap/trans + nfs_path: /usr/sap/trans + nfs_server: "{{ sap_ha_pacemaker_cluster_storage_nfs_server }}" + + - name: sapmnt + mountpoint: /sapmnt + nfs_path: /sapmnt + nfs_server: "{{ sap_ha_pacemaker_cluster_storage_nfs_server }}" + + # SID and Instance Numbers for ASCS and ERS. + sap_ha_pacemaker_cluster_netweaver_sid: ABC + sap_ha_pacemaker_cluster_netweaver_abap_ascs_instance_number: "02" + sap_ha_pacemaker_cluster_netweaver_abap_ers_instance_number: "12" + + # Profile name created by the installer, for example: _ASCS_ + sap_ha_pacemaker_cluster_netweaver_abap_ascs_sapinstance_instance_name: ABC_ASCS02_ascs-node-ha + sap_ha_pacemaker_cluster_netweaver_abap_ascs_sapinstance_start_profile_string: /sapmnt/ABC/profile/ABC_ASCS02_ascs-node-ha + + sap_ha_pacemaker_cluster_netweaver_abap_ers_sapinstance_instance_name: ABC_ERS12_ers-node-ha + sap_ha_pacemaker_cluster_netweaver_abap_ers_sapinstance_start_profile_string: /sapmnt/ABC/profile/ABC_ERS12_ers-node-ha + + # Required to go through the configuration flow for a NetWeaver ASCS/ERS cluster. + sap_ha_pacemaker_cluster_host_type: + - nwas_abap_ascs_ers + + # Virtual IP addresses, one per instance. + # These IPs will switch between the nodes together with the instance. + sap_ha_pacemaker_cluster_vip_netweaver_ascs_ip_address: 192.168.10.102 + sap_ha_pacemaker_cluster_vip_netweaver_ers_ip_address: 192.168.10.112 + + + roles: + + - name: sap_ha_pacemaker_cluster From 80a4bf87faf8871e53ff7679389ef81793c6930f Mon Sep 17 00:00:00 2001 From: Janine Fuchs Date: Tue, 26 Sep 2023 11:31:19 +0200 Subject: [PATCH 4/7] sap_ha_pacemaker_cluster: fix: avoid optional parameter reference in defaults --- playbooks/sample-sap-nwas-ascs-ers-2-node-cluster.yml | 5 +++++ roles/sap_ha_pacemaker_cluster/defaults/main.yml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/playbooks/sample-sap-nwas-ascs-ers-2-node-cluster.yml b/playbooks/sample-sap-nwas-ascs-ers-2-node-cluster.yml index 7363a3350..4d97ea022 100644 --- a/playbooks/sample-sap-nwas-ascs-ers-2-node-cluster.yml +++ b/playbooks/sample-sap-nwas-ascs-ers-2-node-cluster.yml @@ -27,6 +27,11 @@ ############################################################################ ### General minimum pacemaker cluster definitions. + + # Cluster name is optional, the default of the 'ha_cluster' Linux System Role + # would be applied when missing. + # However, for convenience it is defined along with the rest of the mandatory + # parameters in this example. sap_ha_pacemaker_cluster_cluster_name: ascs-ers-cluster sap_ha_pacemaker_cluster_hacluster_password: my-hacluster-vault-password diff --git a/roles/sap_ha_pacemaker_cluster/defaults/main.yml b/roles/sap_ha_pacemaker_cluster/defaults/main.yml index 760b03bd9..5d84e32c3 100644 --- a/roles/sap_ha_pacemaker_cluster/defaults/main.yml +++ b/roles/sap_ha_pacemaker_cluster/defaults/main.yml @@ -21,7 +21,7 @@ sap_ha_pacemaker_cluster_system_roles_collection: 'fedora.linux_system_roles' # config file. # Useful for parameter review or re-use with the 'ha_cluster' LSR. sap_ha_pacemaker_cluster_create_config_varfile: false -sap_ha_pacemaker_cluster_create_config_dest: "{{ sap_ha_pacemaker_cluster_cluster_name }}_resource_config.yml" +sap_ha_pacemaker_cluster_create_config_dest: "review_resource_config.yml" # Inherit SAP common (global synonyms) parameters when defined. From 4a69fe88e9549ac131c2eb44c5c99ebb9c11a9a4 Mon Sep 17 00:00:00 2001 From: Janine Fuchs Date: Tue, 26 Sep 2023 11:53:41 +0200 Subject: [PATCH 5/7] sap_ha_pacemaker_cluster: improve search logic --- .../tasks/ascertain_sap_landscape.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/roles/sap_ha_pacemaker_cluster/tasks/ascertain_sap_landscape.yml b/roles/sap_ha_pacemaker_cluster/tasks/ascertain_sap_landscape.yml index aa4afc90b..a01cf87e0 100644 --- a/roles/sap_ha_pacemaker_cluster/tasks/ascertain_sap_landscape.yml +++ b/roles/sap_ha_pacemaker_cluster/tasks/ascertain_sap_landscape.yml @@ -10,12 +10,12 @@ # 2 nodes are also valid for other scenarios. # TODO: collect possible rules for target landscapes -- name: SAP HA Prepare Pacemaker - Fail if there is only 1 target host +- name: "SAP HA Prepare Pacemaker - Fail if there is only 1 target host" ansible.builtin.assert: that: - ansible_play_hosts | length > 1 -- name: SAP HA Prepare Pacemaker - Make sure the 'type' parameter is a list +- name: "SAP HA Prepare Pacemaker - Make sure the 'type' parameter is a list" ansible.builtin.set_fact: sap_ha_pacemaker_cluster_host_type: | {% if sap_ha_pacemaker_cluster_host_type | type_debug != 'list' -%} @@ -24,21 +24,21 @@ {{ sap_ha_pacemaker_cluster_host_type }} {%- endif %} -- name: SAP HA Prepare Pacemaker - Verify that for 'hana_scaleup' types 2 nodes are used +- name: "SAP HA Prepare Pacemaker - Verify that for 'hana_scaleup' types 2 nodes are used" ansible.builtin.assert: that: - ansible_play_hosts | length == 2 when: - - "'hana_scaleup' in sap_ha_pacemaker_cluster_host_type[0]" + - sap_ha_pacemaker_cluster_host_type | select('search', 'hana_scaleup') | length > 0 -- name: SAP HA Prepare Pacemaker - Include HANA specific variables +- name: "SAP HA Prepare Pacemaker - Include HANA specific variables" ansible.builtin.include_tasks: file: include_vars_hana.yml when: - - "'hana' in sap_ha_pacemaker_cluster_host_type[0]" + - sap_ha_pacemaker_cluster_host_type | select('search', 'hana_scaleup') | length > 0 -- name: SAP HA Prepare Pacemaker - Include NETWEAVER specific variables +- name: "SAP HA Prepare Pacemaker - Include NETWEAVER specific variables" ansible.builtin.include_tasks: file: include_vars_netweaver.yml when: - - "'nwas' in sap_ha_pacemaker_cluster_host_type[0]" + - sap_ha_pacemaker_cluster_host_type | select('search', 'nwas') | length > 0 From 8162ef6d33cbbd9adcc4e204946aa55b90218c36 Mon Sep 17 00:00:00 2001 From: Janine Fuchs Date: Tue, 26 Sep 2023 12:51:33 +0200 Subject: [PATCH 6/7] sap_ha_pacemaker_cluster: fix: removed storage definition options and refer to storage role instead --- .../meta/argument_specs.yml | 33 ++----------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/roles/sap_ha_pacemaker_cluster/meta/argument_specs.yml b/roles/sap_ha_pacemaker_cluster/meta/argument_specs.yml index 19e2a063a..f2756a8a6 100644 --- a/roles/sap_ha_pacemaker_cluster/meta/argument_specs.yml +++ b/roles/sap_ha_pacemaker_cluster/meta/argument_specs.yml @@ -389,38 +389,9 @@ argument_specs: description: - List of filesystem definitions used for filesystem cluster resources. - Uses `sap_storage_setup_definition` when defined. + - For all options, see documentation of role `sap_storage_setup`. + - Options relevant for the HA setup, see below example. elements: dict - options: - name: - description: - - Unique name of the filesystem definition entry. - required: true - - mountpoint: - description: - - Path under which the filesystem will be mounted. - - Mandatory for all filesystems that have a mountpoint. - - Special treatment for a generic "/usr/sap" which will automatically be duplicated into the 2 standard sub-directories "/usr/sap//" and "/usr/sap//SYS". - required: false # for compatibility with definitions that contain swap filesystems as well (sap_storage_setup role input) - - nfs_filesystem_type: - default: - description: - - NFS filesystem type used to mount this filesystem. - - nfs_mount_options: - default: - description: - - Mount options to be used for this specific filesystem. - - nfs_path: - description: - - Path to the filesystem source directory on the NFS server. - - nfs_server: - default: - description: - - Name of the NFS server for this particular filesystem. example: sap_ha_pacemaker_cluster_storage_definition: From 000f7e366271bd0b6228172486c2e4de783168dd Mon Sep 17 00:00:00 2001 From: Janine Fuchs Date: Wed, 27 Sep 2023 11:19:02 +0200 Subject: [PATCH 7/7] sap_ha_pacemaker_cluster: improved arg specs explanation for storage definition --- roles/sap_ha_pacemaker_cluster/README.md | 23 +++++-------------- .../meta/argument_specs.yml | 9 +++++--- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/roles/sap_ha_pacemaker_cluster/README.md b/roles/sap_ha_pacemaker_cluster/README.md index e34db31e5..f26e5a3e7 100644 --- a/roles/sap_ha_pacemaker_cluster/README.md +++ b/roles/sap_ha_pacemaker_cluster/README.md @@ -692,23 +692,12 @@ sap_ha_pacemaker_cluster_stonith_custom: - _Type:_ `list` List of filesystem definitions used for filesystem cluster resources.
-Uses `sap_storage_setup_definition` when defined.
- -- **mountpoint**
- Path under which the filesystem will be mounted.
Mandatory for all filesystems that have a mountpoint.
Special treatment for a generic "/usr/sap" which will automatically be duplicated into the 2 standard sub-directories "/usr/sap//" and "/usr/sap//SYS". -- **name**
- Unique name of the filesystem definition entry. -- **nfs_filesystem_type**
- _Default:_ ``
- NFS filesystem type used to mount this filesystem. -- **nfs_mount_options**
- _Default:_ ``
- Mount options to be used for this specific filesystem. -- **nfs_path**
- Path to the filesystem source directory on the NFS server. -- **nfs_server**
- _Default:_ ``
- Name of the NFS server for this particular filesystem. +Options relevant, see example.
+Mandatory for SAP NetWeaver HA cluster configurations.
+Reuse `sap_storage_setup_definition` if defined.
+Reuse `sap_storage_setup_definition` will extract values 'mountpoint', 'nfs_filesystem_type', 'nfs_mount_options', 'nfs_path', 'nfs_server'.
+Reuse `sap_storage_setup_definition` all options are documented under Ansible Role `sap_storage_setup`.
+Note! For this variable, the argument specification does not list options, to avoid errors during reuse of `sap_storage_setup_definition` if defined.
Example: diff --git a/roles/sap_ha_pacemaker_cluster/meta/argument_specs.yml b/roles/sap_ha_pacemaker_cluster/meta/argument_specs.yml index f2756a8a6..84ff1487b 100644 --- a/roles/sap_ha_pacemaker_cluster/meta/argument_specs.yml +++ b/roles/sap_ha_pacemaker_cluster/meta/argument_specs.yml @@ -388,9 +388,12 @@ argument_specs: type: list description: - List of filesystem definitions used for filesystem cluster resources. - - Uses `sap_storage_setup_definition` when defined. - - For all options, see documentation of role `sap_storage_setup`. - - Options relevant for the HA setup, see below example. + - Options relevant, see example. + - Mandatory for SAP NetWeaver HA cluster configurations. + - Reuse `sap_storage_setup_definition` if defined. + - Reuse `sap_storage_setup_definition` will extract values 'mountpoint', 'nfs_filesystem_type', 'nfs_mount_options', 'nfs_path', 'nfs_server'. + - Reuse `sap_storage_setup_definition` all options are documented under Ansible Role `sap_storage_setup`. + - Note! For this variable, the argument specification does not list options, to avoid errors during reuse of `sap_storage_setup_definition` if defined. elements: dict example: