From 7787ddc2da75e7e0507332e4dad5729dbc75531b Mon Sep 17 00:00:00 2001 From: Janine Fuchs Date: Tue, 12 Sep 2023 18:52:41 +0200 Subject: [PATCH 1/6] sap_ha_pacemaker_cluster: feat: multi-NIC first tasks --- roles/sap_ha_pacemaker_cluster/README.md | 2 +- .../defaults/main.yml | 2 +- .../meta/argument_specs.yml | 2 +- .../construct_vars_vip_resources_default.yml | 4 +++ .../tasks/include_vars_common.yml | 17 ++++++++++ ...ct_vars_vip_resources_cloud_aws_ec2_vs.yml | 4 +++ ...s_vip_resources_cloud_ibmcloud_powervs.yml | 4 +++ ...ct_vars_vip_resources_cloud_msazure_vm.yml | 4 +++ ...uct_vars_vip_resources_hyp_ibmpower_vm.yml | 4 +++ roles/sap_ha_pacemaker_cluster/vars/main.yml | 31 +++---------------- 10 files changed, 44 insertions(+), 30 deletions(-) diff --git a/roles/sap_ha_pacemaker_cluster/README.md b/roles/sap_ha_pacemaker_cluster/README.md index 6cf0c731a..eb5a60660 100644 --- a/roles/sap_ha_pacemaker_cluster/README.md +++ b/roles/sap_ha_pacemaker_cluster/README.md @@ -427,9 +427,9 @@ sap_ha_pacemaker_cluster_resource_defaults: ### sap_ha_pacemaker_cluster_vip_client_interface - _Type:_ `str` -- _Default:_ `eth0` OS device name of the network interface to use for the Virtual IP configuration.
+When there is only one interface on the system, its name will be used by default.
### sap_ha_pacemaker_cluster_vip_hana_primary_ip_address diff --git a/roles/sap_ha_pacemaker_cluster/defaults/main.yml b/roles/sap_ha_pacemaker_cluster/defaults/main.yml index 9b208d45a..a95e171b8 100644 --- a/roles/sap_ha_pacemaker_cluster/defaults/main.yml +++ b/roles/sap_ha_pacemaker_cluster/defaults/main.yml @@ -98,7 +98,7 @@ sap_ha_pacemaker_cluster_fence_options: ### VIP resource default patterns sap_ha_pacemaker_cluster_vip_resource_agent: "ocf:heartbeat:IPaddr2" -sap_ha_pacemaker_cluster_vip_client_interface: eth0 +sap_ha_pacemaker_cluster_vip_client_interface: '' # Multiple VIP parameters can be defined and will be combined. # See tasks/include_construct_vip_resources.yml diff --git a/roles/sap_ha_pacemaker_cluster/meta/argument_specs.yml b/roles/sap_ha_pacemaker_cluster/meta/argument_specs.yml index a2035e47a..5a394c0ae 100644 --- a/roles/sap_ha_pacemaker_cluster/meta/argument_specs.yml +++ b/roles/sap_ha_pacemaker_cluster/meta/argument_specs.yml @@ -325,9 +325,9 @@ argument_specs: # type: str sap_ha_pacemaker_cluster_vip_client_interface: - default: eth0 description: - OS device name of the network interface to use for the Virtual IP configuration. + - When there is only one interface on the system, its name will be used by default. required: false type: str diff --git a/roles/sap_ha_pacemaker_cluster/tasks/construct_vars_vip_resources_default.yml b/roles/sap_ha_pacemaker_cluster/tasks/construct_vars_vip_resources_default.yml index 5217de9e8..3d680387f 100644 --- a/roles/sap_ha_pacemaker_cluster/tasks/construct_vars_vip_resources_default.yml +++ b/roles/sap_ha_pacemaker_cluster/tasks/construct_vars_vip_resources_default.yml @@ -13,5 +13,9 @@ - attrs: - name: ip value: "{{ vip_list_item.value | quote }}" + - name: cidr_netmask + value: "{{ sap_ha_pacemaker_cluster_vip_cidr_netmask }}" + - name: nic + value: "{{ sap_ha_pacemaker_cluster_vip_client_interface }}" when: - __sap_ha_pacemaker_cluster_vip_resource_id not in (__sap_ha_pacemaker_cluster_resource_primitives | map(attribute='id')) diff --git a/roles/sap_ha_pacemaker_cluster/tasks/include_vars_common.yml b/roles/sap_ha_pacemaker_cluster/tasks/include_vars_common.yml index ab3e1bb74..eaac65324 100644 --- a/roles/sap_ha_pacemaker_cluster/tasks/include_vars_common.yml +++ b/roles/sap_ha_pacemaker_cluster/tasks/include_vars_common.yml @@ -7,6 +7,23 @@ ansible.builtin.setup: gather_subset: hardware,interfaces +# Multi-NIC: +# Find out if there is more than one interface present, this will +# be used for determining the target NIC for VIP configurations. +- name: "SAP HA Prepare Pacemaker - Set multi-NIC when more than one interface is found" + ansible.builtin.set_fact: + __sap_ha_pacemaker_cluster_nic_multi_bool: true + when: + - ansible_interfaces | length > 2 + +- name: "SAP HA Pacemaker - Set interface name and netmask when only one interface is present" + ansible.builtin.set_fact: + sap_ha_pacemaker_cluster_vip_client_interface: "{{ ansible_default_ipv4.interface }}" + sap_ha_pacemaker_cluster_vip_cidr_netmask: "{{ ansible_default_ipv4.prefix }}" + when: + - not __sap_ha_pacemaker_cluster_nic_multi_bool + - sap_ha_pacemaker_cluster_vip_client_interface == '' + # Include vars files based on the environment. # Respect order for potential variable precedence. - name: "SAP HA Prepare Pacemaker - Include environment specific variables" diff --git a/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_aws_ec2_vs.yml b/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_aws_ec2_vs.yml index 7cec51de1..4bd66f5bd 100644 --- a/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_aws_ec2_vs.yml +++ b/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_aws_ec2_vs.yml @@ -12,6 +12,10 @@ - attrs: - name: ip value: "{{ vip_list_item.value }}" + - name: cidr_netmask + value: "{{ sap_ha_pacemaker_cluster_vip_cidr_netmask }}" + - name: nic + value: "{{ sap_ha_pacemaker_cluster_vip_client_interface }}" when: - vip_list_item.key not in (__sap_ha_pacemaker_cluster_resource_primitives | map(attribute='id')) - (sap_ha_pacemaker_cluster_vip_method == 'ipaddr') or diff --git a/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_ibmcloud_powervs.yml b/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_ibmcloud_powervs.yml index da995eae2..917ef21b1 100644 --- a/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_ibmcloud_powervs.yml +++ b/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_ibmcloud_powervs.yml @@ -12,6 +12,10 @@ - attrs: - name: ip value: "{{ vip_list_item.value }}" + - name: cidr_netmask + value: "{{ sap_ha_pacemaker_cluster_vip_cidr_netmask }}" + - name: nic + value: "{{ sap_ha_pacemaker_cluster_vip_client_interface }}" when: - vip_list_item.key not in (__sap_ha_pacemaker_cluster_resource_primitives | map(attribute='id')) - (sap_ha_pacemaker_cluster_vip_method == 'ipaddr') or diff --git a/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_msazure_vm.yml b/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_msazure_vm.yml index 34982f29b..4d1d5c4ea 100644 --- a/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_msazure_vm.yml +++ b/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_msazure_vm.yml @@ -12,6 +12,10 @@ - attrs: - name: ip value: "{{ vip_list_item.value }}" + - name: cidr_netmask + value: "{{ sap_ha_pacemaker_cluster_vip_cidr_netmask }}" + - name: nic + value: "{{ sap_ha_pacemaker_cluster_vip_client_interface }}" when: - vip_list_item.key not in (__sap_ha_pacemaker_cluster_resource_primitives | map(attribute='id')) - (sap_ha_pacemaker_cluster_vip_method == 'ipaddr') or diff --git a/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_hyp_ibmpower_vm.yml b/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_hyp_ibmpower_vm.yml index da995eae2..917ef21b1 100644 --- a/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_hyp_ibmpower_vm.yml +++ b/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_hyp_ibmpower_vm.yml @@ -12,6 +12,10 @@ - attrs: - name: ip value: "{{ vip_list_item.value }}" + - name: cidr_netmask + value: "{{ sap_ha_pacemaker_cluster_vip_cidr_netmask }}" + - name: nic + value: "{{ sap_ha_pacemaker_cluster_vip_client_interface }}" when: - vip_list_item.key not in (__sap_ha_pacemaker_cluster_resource_primitives | map(attribute='id')) - (sap_ha_pacemaker_cluster_vip_method == 'ipaddr') or diff --git a/roles/sap_ha_pacemaker_cluster/vars/main.yml b/roles/sap_ha_pacemaker_cluster/vars/main.yml index c96a08fbf..27b93aee8 100644 --- a/roles/sap_ha_pacemaker_cluster/vars/main.yml +++ b/roles/sap_ha_pacemaker_cluster/vars/main.yml @@ -27,37 +27,14 @@ __sap_ha_pacemaker_cluster_required_facts: # - virtualization_role # subset: virtual # - virtualization_type # subset: virtual +# By default assume non-multi-NIC configuration. +# This is automatically adjusted during preparation tasks. +__sap_ha_pacemaker_cluster_nic_multi_bool: false + # Define empty parameters to avoid undefined input variables. # The arguments_spec check complains. # The actual values must be empty, they are set by various tasks! -__sap_ha_pacemaker_cluster_hana_primary_synonyms: - - primary - - hana_primary - - promoted - - rw - -__sap_ha_pacemaker_cluster_hana_secondary_synonyms: - - secondary - - hana_secondary - - unpromoted - - ro - -__sap_ha_pacemaker_cluster_nwas_ascs_synonyms: - - ascs - - nwas_ascs - - nwas_abap_ascs - -__sap_ha_pacemaker_cluster_nwas_ers_synonyms: - - ers - - nwas_ers - - nwas_abap_ers - -__sap_ha_pacemaker_cluster_nwas_pas_synonyms: - - pas - - nwas_pas - - nwas_abap_pas - # (cloud) platform helper variable - leave empty for default = not cloud __sap_ha_pacemaker_cluster_platform: '' __sap_ha_pacemaker_cluster_supported_platforms: From d89fe8109a537df72368494efe9b36598285f920 Mon Sep 17 00:00:00 2001 From: Janine Fuchs Date: Tue, 12 Sep 2023 19:08:48 +0200 Subject: [PATCH 2/6] sap_ha_pacemaker_cluster: enh: treat cidr_netmask separately --- .../sap_ha_pacemaker_cluster/tasks/include_vars_common.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/roles/sap_ha_pacemaker_cluster/tasks/include_vars_common.yml b/roles/sap_ha_pacemaker_cluster/tasks/include_vars_common.yml index eaac65324..3ca69983b 100644 --- a/roles/sap_ha_pacemaker_cluster/tasks/include_vars_common.yml +++ b/roles/sap_ha_pacemaker_cluster/tasks/include_vars_common.yml @@ -16,14 +16,17 @@ when: - ansible_interfaces | length > 2 -- name: "SAP HA Pacemaker - Set interface name and netmask when only one interface is present" +- name: "SAP HA Pacemaker - Set interface name when only one interface is present" ansible.builtin.set_fact: sap_ha_pacemaker_cluster_vip_client_interface: "{{ ansible_default_ipv4.interface }}" - sap_ha_pacemaker_cluster_vip_cidr_netmask: "{{ ansible_default_ipv4.prefix }}" when: - not __sap_ha_pacemaker_cluster_nic_multi_bool - sap_ha_pacemaker_cluster_vip_client_interface == '' +- name: "SAP HA Pacemaker - Set cidr netmask of the defined interface" + ansible.builtin.set_fact: + sap_ha_pacemaker_cluster_vip_cidr_netmask: "{{ vars['ansible_' + sap_ha_pacemaker_cluster_vip_client_interface].ipv4.prefix }}" + # Include vars files based on the environment. # Respect order for potential variable precedence. - name: "SAP HA Prepare Pacemaker - Include environment specific variables" From f14c378c00defc6984f30505d93554a813e3c3a7 Mon Sep 17 00:00:00 2001 From: Janine Fuchs Date: Wed, 13 Sep 2023 10:12:06 +0200 Subject: [PATCH 3/6] sap_ha_pacemaker_cluster: enh: verify user-defined NIC and fail early --- .../tasks/validate_input_parameters.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/roles/sap_ha_pacemaker_cluster/tasks/validate_input_parameters.yml b/roles/sap_ha_pacemaker_cluster/tasks/validate_input_parameters.yml index 2ae0ed659..5c5f5a58d 100644 --- a/roles/sap_ha_pacemaker_cluster/tasks/validate_input_parameters.yml +++ b/roles/sap_ha_pacemaker_cluster/tasks/validate_input_parameters.yml @@ -28,3 +28,11 @@ or sap_ha_pacemaker_cluster_netweaver_sid is defined - sap_ha_pacemaker_cluster_hana_sid | length > 0 or sap_ha_pacemaker_cluster_netweaver_sid | length > 0 + + +# Verify that the user-defined VIP NIC device name exists on the system. +- name: "SAP HA Pacemaker - Verify that the custom NIC name exists" + ansible.builtin.assert: + that: + - sap_ha_pacemaker_cluster_vip_client_interface in ansible_interfaces + fail_msg: "The defined 'sap_ha_pacemaker_cluster_vip_client_interface' does not exist on this system!" From cd1f62b891550beaf301ba20c7f3101466349af3 Mon Sep 17 00:00:00 2001 From: Janine Fuchs Date: Wed, 13 Sep 2023 15:01:54 +0200 Subject: [PATCH 4/6] sap_ha_pacemaker_cluster: enh: improved SID and VIP/NIC input validation --- .../tasks/include_vars_common.yml | 7 +- .../tasks/validate_input_parameters.yml | 76 ++++++++++++++----- 2 files changed, 64 insertions(+), 19 deletions(-) diff --git a/roles/sap_ha_pacemaker_cluster/tasks/include_vars_common.yml b/roles/sap_ha_pacemaker_cluster/tasks/include_vars_common.yml index 3ca69983b..68e5fbac8 100644 --- a/roles/sap_ha_pacemaker_cluster/tasks/include_vars_common.yml +++ b/roles/sap_ha_pacemaker_cluster/tasks/include_vars_common.yml @@ -10,22 +10,25 @@ # Multi-NIC: # Find out if there is more than one interface present, this will # be used for determining the target NIC for VIP configurations. +# Assumption: The local loopback "lo" is always in the list. - name: "SAP HA Prepare Pacemaker - Set multi-NIC when more than one interface is found" ansible.builtin.set_fact: __sap_ha_pacemaker_cluster_nic_multi_bool: true when: - ansible_interfaces | length > 2 -- name: "SAP HA Pacemaker - Set interface name when only one interface is present" +- name: "SAP HA Prepare Pacemaker - Set interface name when only one interface is present" ansible.builtin.set_fact: sap_ha_pacemaker_cluster_vip_client_interface: "{{ ansible_default_ipv4.interface }}" when: - not __sap_ha_pacemaker_cluster_nic_multi_bool - sap_ha_pacemaker_cluster_vip_client_interface == '' -- name: "SAP HA Pacemaker - Set cidr netmask of the defined interface" +- name: "SAP HA Prepare Pacemaker - Set cidr netmask of the defined interface" ansible.builtin.set_fact: sap_ha_pacemaker_cluster_vip_cidr_netmask: "{{ vars['ansible_' + sap_ha_pacemaker_cluster_vip_client_interface].ipv4.prefix }}" + when: + - sap_ha_pacemaker_cluster_vip_client_interface != '' # Include vars files based on the environment. # Respect order for potential variable precedence. diff --git a/roles/sap_ha_pacemaker_cluster/tasks/validate_input_parameters.yml b/roles/sap_ha_pacemaker_cluster/tasks/validate_input_parameters.yml index 5c5f5a58d..dd946859c 100644 --- a/roles/sap_ha_pacemaker_cluster/tasks/validate_input_parameters.yml +++ b/roles/sap_ha_pacemaker_cluster/tasks/validate_input_parameters.yml @@ -1,38 +1,80 @@ --- # The SAP ID must follow a strict format and not use reserved special values # TODO: This check may be better placed in a SAP role earlier in the chain... -- name: "SAP HA Prepare Pacemaker - Validate SAP System ID (SAP HANA)" +- name: "SAP HA Prepare Pacemaker - (SAP HANA) Validate SAP System ID" ansible.builtin.assert: that: - sap_ha_pacemaker_cluster_hana_sid | length == 3 - sap_ha_pacemaker_cluster_hana_sid not in __sap_sid_prohibited + fail_msg: | + Host type = {{ sap_ha_pacemaker_cluster_host_type }} + Requires 'sap_ha_pacemaker_cluster_hana_sid' to be defined! when: - - "'hana' in sap_ha_pacemaker_cluster_host_type" - - sap_ha_pacemaker_cluster_hana_sid is defined - - sap_ha_pacemaker_cluster_hana_sid | length > 0 + - sap_ha_pacemaker_cluster_host_type | select('search', 'hana') | length > 0 -- name: "SAP HA Prepare Pacemaker - Validate SAP System ID (SAP Netweaver)" +- name: "SAP HA Prepare Pacemaker - (SAP NetWeaver) Validate SAP System ID" ansible.builtin.assert: that: - sap_ha_pacemaker_cluster_netweaver_sid | length == 3 - sap_ha_pacemaker_cluster_netweaver_sid not in __sap_sid_prohibited + fail_msg: | + Host type = {{ sap_ha_pacemaker_cluster_host_type }} + Requires 'sap_ha_pacemaker_cluster_netweaver_sid' to be defined! when: - - "'nwas' in sap_ha_pacemaker_cluster_host_type" - - sap_ha_pacemaker_cluster_netweaver_sid is defined - - sap_ha_pacemaker_cluster_netweaver_sid | length > 0 + - sap_ha_pacemaker_cluster_host_type | select('search', 'nwas') | length > 0 -- name: "SAP HA Prepare Pacemaker - Verify that a SID is defined" + +# Verify that the user-defined VIP NIC device name exists on the system. +- name: "SAP HA Prepare Pacemaker - Verify that the custom NIC name exists" ansible.builtin.assert: that: - - sap_ha_pacemaker_cluster_hana_sid is defined - or sap_ha_pacemaker_cluster_netweaver_sid is defined - - sap_ha_pacemaker_cluster_hana_sid | length > 0 - or sap_ha_pacemaker_cluster_netweaver_sid | length > 0 + - sap_ha_pacemaker_cluster_vip_client_interface in ansible_interfaces + fail_msg: "The interface '{{ sap_ha_pacemaker_cluster_vip_client_interface }}' does not exist on this system!" + when: + - sap_ha_pacemaker_cluster_vip_client_interface | length > 0 +# Verify that an IP address for the VIP of the defined host type is defined. +- name: "SAP HA Prepare Pacemaker - (HANA primary) Verify that the VIP is defined" + ansible.builtin.assert: + that: + - sap_ha_pacemaker_cluster_vip_hana_primary_ip_address is defined + - sap_ha_pacemaker_cluster_vip_hana_primary_ip_address | length > 0 + fail_msg: "Host type = '{{ sap_ha_pacemaker_cluster_host_type }}', but 'sap_ha_pacemaker_cluster_vip_hana_primary_ip_address' is not defined." + when: + - sap_ha_pacemaker_cluster_host_type | select('search', 'hana') | length > 0 -# Verify that the user-defined VIP NIC device name exists on the system. -- name: "SAP HA Pacemaker - Verify that the custom NIC name exists" +- name: "SAP HA Prepare Pacemaker - (NetWeaver ASCS) Verify that the VIP is defined" ansible.builtin.assert: that: - - sap_ha_pacemaker_cluster_vip_client_interface in ansible_interfaces - fail_msg: "The defined 'sap_ha_pacemaker_cluster_vip_client_interface' does not exist on this system!" + - sap_ha_pacemaker_cluster_vip_netweaver_ascs_ip_address is defined + - sap_ha_pacemaker_cluster_vip_netweaver_ascs_ip_address | length > 0 + fail_msg: "Host type = '{{ sap_ha_pacemaker_cluster_host_type }}', but 'sap_ha_pacemaker_cluster_vip_netweaver_ascs_ip_address' is not defined." + when: + - sap_ha_pacemaker_cluster_host_type | select('search', 'nwas_abap_ascs') | length > 0 + +- name: "SAP HA Prepare Pacemaker - (NetWeaver ERS) Verify that the VIP is defined" + ansible.builtin.assert: + that: + - sap_ha_pacemaker_cluster_vip_netweaver_ers_ip_address is defined + - sap_ha_pacemaker_cluster_vip_netweaver_ers_ip_address | length > 0 + fail_msg: "Host type = '{{ sap_ha_pacemaker_cluster_host_type }}', but 'sap_ha_pacemaker_cluster_vip_netweaver_ers_ip_address' is not defined." + when: + - sap_ha_pacemaker_cluster_host_type | select('search', 'nwas_abap_ascs_ers') | length > 0 + +- name: "SAP HA Prepare Pacemaker - (NetWeaver PAS) Verify that the VIP is defined" + ansible.builtin.assert: + that: + - sap_ha_pacemaker_cluster_vip_netweaver_pas_ip_address is defined + - sap_ha_pacemaker_cluster_vip_netweaver_pas_ip_address | length > 0 + fail_msg: "Host type = '{{ sap_ha_pacemaker_cluster_host_type }}', but 'sap_ha_pacemaker_cluster_vip_netweaver_pas_ip_address' is not defined." + when: + - sap_ha_pacemaker_cluster_host_type | select('search', 'nwas_abap_pas') | length > 0 + +- name: "SAP HA Prepare Pacemaker - (NetWeaver AAS) Verify that the ERS VIP is defined" + ansible.builtin.assert: + that: + - sap_ha_pacemaker_cluster_vip_netweaver_aas_ip_address is defined + - sap_ha_pacemaker_cluster_vip_netweaver_aas_ip_address | length > 0 + fail_msg: "Host type = '{{ sap_ha_pacemaker_cluster_host_type }}', but 'sap_ha_pacemaker_cluster_vip_netweaver_aas_ip_address' is not defined." + when: + - sap_ha_pacemaker_cluster_host_type | select('search', 'nwas_abap_pas_aas') | length > 0 From c94ed5c3303c22ea1bdb013d0f85187acfa2537f Mon Sep 17 00:00:00 2001 From: Janine Fuchs Date: Wed, 13 Sep 2023 15:16:56 +0200 Subject: [PATCH 5/6] sap_ha_pacemaker_cluster: validation improvements --- .../tasks/validate_input_parameters.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/roles/sap_ha_pacemaker_cluster/tasks/validate_input_parameters.yml b/roles/sap_ha_pacemaker_cluster/tasks/validate_input_parameters.yml index dd946859c..6d77a1c67 100644 --- a/roles/sap_ha_pacemaker_cluster/tasks/validate_input_parameters.yml +++ b/roles/sap_ha_pacemaker_cluster/tasks/validate_input_parameters.yml @@ -1,6 +1,5 @@ --- # The SAP ID must follow a strict format and not use reserved special values -# TODO: This check may be better placed in a SAP role earlier in the chain... - name: "SAP HA Prepare Pacemaker - (SAP HANA) Validate SAP System ID" ansible.builtin.assert: that: @@ -23,8 +22,21 @@ when: - sap_ha_pacemaker_cluster_host_type | select('search', 'nwas') | length > 0 +# NIC definition validation +- name: "SAP HA Prepare Pacemaker - Verify that a custom NIC name is defined when multiple NICs exist" + ansible.builtin.assert: + that: + - sap_ha_pacemaker_cluster_vip_client_interface is defined + - sap_ha_pacemaker_cluster_vip_client_interface | length > 0 + fail_msg: + Multiple interfaces are found on the system. + + {{ ansible_interfaces | to_nice_yaml }} + + In this case 'sap_ha_pacemaker_cluster_vip_client_interface' must be defined. + when: + - ansible_interfaces | length > 2 -# Verify that the user-defined VIP NIC device name exists on the system. - name: "SAP HA Prepare Pacemaker - Verify that the custom NIC name exists" ansible.builtin.assert: that: @@ -33,7 +45,7 @@ when: - sap_ha_pacemaker_cluster_vip_client_interface | length > 0 -# Verify that an IP address for the VIP of the defined host type is defined. +# VIP definition validation - name: "SAP HA Prepare Pacemaker - (HANA primary) Verify that the VIP is defined" ansible.builtin.assert: that: From e61368469124e09927e23e9294285ce7be778d58 Mon Sep 17 00:00:00 2001 From: Janine Fuchs Date: Wed, 13 Sep 2023 15:56:15 +0200 Subject: [PATCH 6/6] sap_ha_pacemaker_cluster: remove cidr_netmask from IPaddr2 resource definitions and leave it to the agent --- .../tasks/construct_vars_vip_resources_default.yml | 2 -- roles/sap_ha_pacemaker_cluster/tasks/include_vars_common.yml | 5 ----- .../construct_vars_vip_resources_cloud_aws_ec2_vs.yml | 2 -- .../construct_vars_vip_resources_cloud_ibmcloud_powervs.yml | 2 -- .../construct_vars_vip_resources_cloud_msazure_vm.yml | 2 -- .../construct_vars_vip_resources_hyp_ibmpower_vm.yml | 2 -- 6 files changed, 15 deletions(-) diff --git a/roles/sap_ha_pacemaker_cluster/tasks/construct_vars_vip_resources_default.yml b/roles/sap_ha_pacemaker_cluster/tasks/construct_vars_vip_resources_default.yml index 3d680387f..98a49b57c 100644 --- a/roles/sap_ha_pacemaker_cluster/tasks/construct_vars_vip_resources_default.yml +++ b/roles/sap_ha_pacemaker_cluster/tasks/construct_vars_vip_resources_default.yml @@ -13,8 +13,6 @@ - attrs: - name: ip value: "{{ vip_list_item.value | quote }}" - - name: cidr_netmask - value: "{{ sap_ha_pacemaker_cluster_vip_cidr_netmask }}" - name: nic value: "{{ sap_ha_pacemaker_cluster_vip_client_interface }}" when: diff --git a/roles/sap_ha_pacemaker_cluster/tasks/include_vars_common.yml b/roles/sap_ha_pacemaker_cluster/tasks/include_vars_common.yml index 68e5fbac8..f132a6738 100644 --- a/roles/sap_ha_pacemaker_cluster/tasks/include_vars_common.yml +++ b/roles/sap_ha_pacemaker_cluster/tasks/include_vars_common.yml @@ -24,11 +24,6 @@ - not __sap_ha_pacemaker_cluster_nic_multi_bool - sap_ha_pacemaker_cluster_vip_client_interface == '' -- name: "SAP HA Prepare Pacemaker - Set cidr netmask of the defined interface" - ansible.builtin.set_fact: - sap_ha_pacemaker_cluster_vip_cidr_netmask: "{{ vars['ansible_' + sap_ha_pacemaker_cluster_vip_client_interface].ipv4.prefix }}" - when: - - sap_ha_pacemaker_cluster_vip_client_interface != '' # Include vars files based on the environment. # Respect order for potential variable precedence. diff --git a/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_aws_ec2_vs.yml b/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_aws_ec2_vs.yml index 4bd66f5bd..c34cfac8f 100644 --- a/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_aws_ec2_vs.yml +++ b/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_aws_ec2_vs.yml @@ -12,8 +12,6 @@ - attrs: - name: ip value: "{{ vip_list_item.value }}" - - name: cidr_netmask - value: "{{ sap_ha_pacemaker_cluster_vip_cidr_netmask }}" - name: nic value: "{{ sap_ha_pacemaker_cluster_vip_client_interface }}" when: diff --git a/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_ibmcloud_powervs.yml b/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_ibmcloud_powervs.yml index 917ef21b1..97b662d67 100644 --- a/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_ibmcloud_powervs.yml +++ b/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_ibmcloud_powervs.yml @@ -12,8 +12,6 @@ - attrs: - name: ip value: "{{ vip_list_item.value }}" - - name: cidr_netmask - value: "{{ sap_ha_pacemaker_cluster_vip_cidr_netmask }}" - name: nic value: "{{ sap_ha_pacemaker_cluster_vip_client_interface }}" when: diff --git a/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_msazure_vm.yml b/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_msazure_vm.yml index 4d1d5c4ea..244532aeb 100644 --- a/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_msazure_vm.yml +++ b/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_msazure_vm.yml @@ -12,8 +12,6 @@ - attrs: - name: ip value: "{{ vip_list_item.value }}" - - name: cidr_netmask - value: "{{ sap_ha_pacemaker_cluster_vip_cidr_netmask }}" - name: nic value: "{{ sap_ha_pacemaker_cluster_vip_client_interface }}" when: diff --git a/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_hyp_ibmpower_vm.yml b/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_hyp_ibmpower_vm.yml index 917ef21b1..97b662d67 100644 --- a/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_hyp_ibmpower_vm.yml +++ b/roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_hyp_ibmpower_vm.yml @@ -12,8 +12,6 @@ - attrs: - name: ip value: "{{ vip_list_item.value }}" - - name: cidr_netmask - value: "{{ sap_ha_pacemaker_cluster_vip_cidr_netmask }}" - name: nic value: "{{ sap_ha_pacemaker_cluster_vip_client_interface }}" when: