Skip to content

Commit d18ddde

Browse files
authored
Merge pull request #1074 from marcelmamula/remove-nic
sap_ha_pacemaker_cluster: Remove NIC parameter from IPaddr2 resource agents
2 parents e7f5388 + 233c91e commit d18ddde

10 files changed

+54
-37
lines changed

roles/sap_ha_pacemaker_cluster/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,8 @@ For RHEL System Roles for SAP, or Red Hat Automation Hub, use 'redhat.rhel_syste
10981098

10991099
OS device name of the network interface to use for the Virtual IP configuration.<br>
11001100
When there is only one interface on the system, its name will be used by default.<br>
1101+
Ensure that same network interface is present on all cluster nodes.<br>
1102+
IPaddr2 resource agent does not require network interface defined (except Google Cloud).<br>
11011103

11021104
### sap_ha_pacemaker_cluster_vip_hana_primary_ip_address
11031105
- _Type:_ `string`<br>

roles/sap_ha_pacemaker_cluster/meta/argument_specs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ argument_specs:
154154
description:
155155
- OS device name of the network interface to use for the Virtual IP configuration.
156156
- When there is only one interface on the system, its name will be used by default.
157+
- Ensure that same network interface is present on all cluster nodes.
158+
- IPaddr2 resource agent does not require network interface defined (except Google Cloud).
157159

158160
sap_ha_pacemaker_cluster_stonith_custom:
159161
type: list

roles/sap_ha_pacemaker_cluster/tasks/construct_vars_vip_resources_default.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,22 @@
1313
ansible.builtin.set_fact:
1414
__sap_ha_pacemaker_cluster_resource_primitives: "{{ __sap_ha_pacemaker_cluster_resource_primitives + [__resource_vip] }}"
1515
vars:
16+
__ipaddr_ip:
17+
- name: ip
18+
value: "{{ vip_list_item.value | quote }}"
19+
# Create separate list for nic parameter only when it is defined and not empty.
20+
__ipaddr_nic:
21+
- name: nic
22+
value: "{{ sap_ha_pacemaker_cluster_vip_client_interface | d('') }}"
23+
1624
__resource_vip:
1725
id: "{{ vip_list_item.key }}"
1826
agent: "{{ __sap_ha_pacemaker_cluster_available_vip_agents['ipaddr'].agent }}"
1927
instance_attrs:
20-
- attrs:
21-
- name: ip
22-
value: "{{ vip_list_item.value | quote }}"
23-
- name: nic
24-
value: "{{ sap_ha_pacemaker_cluster_vip_client_interface }}"
28+
# Combine both lists if sap_ha_pacemaker_cluster_vip_client_interface is defined and not empty.
29+
- attrs: "{{ __ipaddr_ip + __ipaddr_nic
30+
if sap_ha_pacemaker_cluster_vip_client_interface is defined and sap_ha_pacemaker_cluster_vip_client_interface | length > 0
31+
else __ipaddr_ip }}"
2532
when:
2633
- vip_list_item.key not in (__sap_ha_pacemaker_cluster_resource_primitives | map(attribute='id'))
2734
- sap_ha_pacemaker_cluster_vip_method == 'ipaddr' or

roles/sap_ha_pacemaker_cluster/tasks/include_vars_common.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,14 @@
88
ansible.builtin.setup:
99
gather_subset: hardware,interfaces
1010

11-
# Multi-NIC:
12-
# Find out if there is more than one interface present, this will
13-
# be used for determining the target NIC for VIP configurations.
14-
# Assumption: The local loopback "lo" is always in the list.
15-
- name: "SAP HA Prepare Pacemaker - Set multi-NIC when more than one interface is found"
16-
ansible.builtin.set_fact:
17-
__sap_ha_pacemaker_cluster_nic_multi_bool: true
18-
when:
19-
- ansible_interfaces | length > 2
2011

21-
- name: "SAP HA Prepare Pacemaker - Set interface name when only one interface is present"
12+
# Use default ipv4 interface when one interface is detected.
13+
# Assumption: The local loopback "lo" is always in the list.
14+
- name: "SAP HA Prepare Pacemaker - Set network interface name when only one interface is present"
2215
ansible.builtin.set_fact:
23-
sap_ha_pacemaker_cluster_vip_client_interface: "{{ ansible_default_ipv4.interface }}"
16+
__sap_ha_pacemaker_cluster_vip_client_interface: "{{ ansible_default_ipv4.interface }}"
2417
when:
25-
- not __sap_ha_pacemaker_cluster_nic_multi_bool
18+
- ansible_interfaces | length <= 2
2619
- sap_ha_pacemaker_cluster_vip_client_interface == ''
2720

2821

roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_aws_ec2_vs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
- name: ip
5959
value: "{{ vip_list_item.value }}"
6060
- name: interface
61-
value: "{{ sap_ha_pacemaker_cluster_vip_client_interface }}"
61+
value: "{{ __sap_ha_pacemaker_cluster_vip_client_interface | d(sap_ha_pacemaker_cluster_vip_client_interface) }}"
6262
- name: routing_table
6363
value: "{{ sap_ha_pacemaker_cluster_aws_vip_update_rt }}"
6464
when:

roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_gcp_ce_vm.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
value: "{{ vip_list_item.value }}"
2323
- name: cidr_netmask
2424
value: 32
25+
# IPaddr2 does not require 'nic' parameter, but GCP documentation includes it.
2526
- name: nic
26-
value: "{{ sap_ha_pacemaker_cluster_vip_client_interface }}"
27+
value: "{{ __sap_ha_pacemaker_cluster_vip_client_interface | d(sap_ha_pacemaker_cluster_vip_client_interface) }}"
2728
operations:
2829
- action: monitor
2930
attrs:

roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_cloud_ibmcloud_powervs.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,24 @@
66
ansible.builtin.set_fact:
77
__sap_ha_pacemaker_cluster_resource_primitives: "{{ __sap_ha_pacemaker_cluster_resource_primitives + [__resource_vip] }}"
88
vars:
9+
__ipaddr_ip_cidr:
10+
- name: ip
11+
value: "{{ vip_list_item.value | quote }}"
12+
- name: cidr_netmask
13+
value: "{{ __sap_ha_pacemaker_cluster_vip_client_interface_subnet_cidr.stdout | int }}"
14+
# Create separate list for nic parameter only when it is defined and not empty.
15+
__ipaddr_nic:
16+
- name: nic
17+
value: "{{ sap_ha_pacemaker_cluster_vip_client_interface | d('') }}"
18+
919
__resource_vip:
1020
id: "{{ vip_list_item.key }}"
1121
agent: "{{ __sap_ha_pacemaker_cluster_available_vip_agents[sap_ha_pacemaker_cluster_vip_method].agent }}"
1222
instance_attrs:
13-
- attrs:
14-
- name: ip
15-
value: "{{ vip_list_item.value }}"
16-
- name: cidr_netmask
17-
value: "{{ __sap_ha_pacemaker_cluster_vip_client_interface_subnet_cidr.stdout | int }}"
18-
- name: nic
19-
value: "{{ sap_ha_pacemaker_cluster_vip_client_interface }}"
23+
# Combine both lists if sap_ha_pacemaker_cluster_vip_client_interface is defined and not empty.
24+
- attrs: "{{ __ipaddr_ip_cidr + __ipaddr_nic
25+
if sap_ha_pacemaker_cluster_vip_client_interface is defined and sap_ha_pacemaker_cluster_vip_client_interface | length > 0
26+
else __ipaddr_ip_cidr }}"
2027
when:
2128
- vip_list_item.key not in (__sap_ha_pacemaker_cluster_resource_primitives | map(attribute='id'))
2229
- sap_ha_pacemaker_cluster_vip_method == 'ipaddr_custom' or

roles/sap_ha_pacemaker_cluster/tasks/platform/construct_vars_vip_resources_hyp_ibmpower_vm.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,22 @@
66
ansible.builtin.set_fact:
77
__sap_ha_pacemaker_cluster_resource_primitives: "{{ __sap_ha_pacemaker_cluster_resource_primitives + [__resource_vip] }}"
88
vars:
9+
__ipaddr_ip:
10+
- name: ip
11+
value: "{{ vip_list_item.value | quote }}"
12+
# Create separate list for nic parameter only when it is defined and not empty.
13+
__ipaddr_nic:
14+
- name: nic
15+
value: "{{ sap_ha_pacemaker_cluster_vip_client_interface | d('') }}"
16+
917
__resource_vip:
1018
id: "{{ vip_list_item.key }}"
1119
agent: "{{ __sap_ha_pacemaker_cluster_available_vip_agents[sap_ha_pacemaker_cluster_vip_method].agent }}"
1220
instance_attrs:
13-
- attrs:
14-
- name: ip
15-
value: "{{ vip_list_item.value }}"
16-
- name: nic
17-
value: "{{ sap_ha_pacemaker_cluster_vip_client_interface }}"
21+
# Combine both lists if sap_ha_pacemaker_cluster_vip_client_interface is defined and not empty.
22+
- attrs: "{{ __ipaddr_ip + __ipaddr_nic
23+
if sap_ha_pacemaker_cluster_vip_client_interface is defined and sap_ha_pacemaker_cluster_vip_client_interface | length > 0
24+
else __ipaddr_ip }}"
1825
when:
1926
- vip_list_item.key not in (__sap_ha_pacemaker_cluster_resource_primitives | map(attribute='id'))
2027
- (sap_ha_pacemaker_cluster_vip_method == 'ipaddr') or

roles/sap_ha_pacemaker_cluster/tasks/platform/register_sysinfo_cloud_ibmcloud_powervs.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222
- name: "SAP HA Prepare Pacemaker - IBM Cloud PowerVS - Calculate network interface subnet CIDR"
2323
ansible.builtin.shell: |
2424
set -o pipefail && ipcalc --prefix \
25-
{{ ansible_facts[sap_ha_pacemaker_cluster_vip_client_interface].ipv4.network
26-
+ '/' + ansible_facts[sap_ha_pacemaker_cluster_vip_client_interface].ipv4.netmask }} \
25+
{{ ansible_facts[__interface].ipv4.network
26+
+ '/' + ansible_facts[__interface].ipv4.netmask }} \
2727
| sed 's|PREFIX=||'
2828
register: __sap_ha_pacemaker_cluster_vip_client_interface_subnet_cidr
2929
changed_when: false
3030
check_mode: false
31+
vars:
32+
__interface: "{{ __sap_ha_pacemaker_cluster_vip_client_interface | d(sap_ha_pacemaker_cluster_vip_client_interface) }}"

roles/sap_ha_pacemaker_cluster/vars/main.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ __sap_ha_pacemaker_cluster_required_facts:
2828
# - virtualization_role # subset: virtual
2929
# - virtualization_type # subset: virtual
3030

31-
# By default assume non-multi-NIC configuration.
32-
# This is automatically adjusted during preparation tasks.
33-
__sap_ha_pacemaker_cluster_nic_multi_bool: false
34-
3531
# By default use the construction of IPaddr2 VIP resources
3632
# Platforms define different methods out of optional agents, as applicable.
3733
sap_ha_pacemaker_cluster_vip_method: ipaddr

0 commit comments

Comments
 (0)