From e6af1549c2b91b5c1a4c5b027a034f79a687417c Mon Sep 17 00:00:00 2001 From: sean-freeman <1815807+sean-freeman@users.noreply.github.com> Date: Wed, 29 May 2024 08:41:52 +0100 Subject: [PATCH] sap_vm_provision: amend var handling for storage and ha on ibmcloud --- .../tasks/common/set_ansible_vars_storage.yml | 2 +- .../tasks/common/set_etc_hosts_ha.yml | 43 ++++++++++++++++--- .../ibmcloud_vs/execute_provision.yml | 4 +- 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/roles/sap_vm_provision/tasks/common/set_ansible_vars_storage.yml b/roles/sap_vm_provision/tasks/common/set_ansible_vars_storage.yml index b8925bb..8bd2674 100644 --- a/roles/sap_vm_provision/tasks/common/set_ansible_vars_storage.yml +++ b/roles/sap_vm_provision/tasks/common/set_ansible_vars_storage.yml @@ -26,7 +26,7 @@ 'value': entry.value, } ]) %} - {%- elif not "disk_type" in entry.key %} + {%- elif (not "disk_type" in entry.key) and (not "disk_iops" in entry.key) %} {%- set add_entry = new_element.extend([ { 'key': entry.key, diff --git a/roles/sap_vm_provision/tasks/common/set_etc_hosts_ha.yml b/roles/sap_vm_provision/tasks/common/set_etc_hosts_ha.yml index 87800a0..db414e4 100644 --- a/roles/sap_vm_provision/tasks/common/set_etc_hosts_ha.yml +++ b/roles/sap_vm_provision/tasks/common/set_etc_hosts_ha.yml @@ -129,10 +129,11 @@ # Ensure SAP AnyDB, SAP HANA or SAP NetWeaver hostname is not localhost in /etc/hosts. See SAP Note 1054467 - Local host name refers to loopback address. -# However, as IBM Cloud Load Balancer is a secure design using Back-end Pool servers with singular Port Number and Front-end Listener with single Port Number, -# and controls the Virtual IP from the Load Balancer. Therefore the Virtual IP is not added as a Secondary IP to the OS Network Interface, -# which causes connectivity issues due to SAP NetWeaver instance random dynamic port usage. -# As workaround, configure /etc/hosts to map Virtual Hostname to use the host IP Address instead of the Virtual IP Address +# However, as IBM Cloud Load Balancer is a secure design (using Back-end Pool servers with singular Port Number and Front-end Listener with single Port Number), +# which controls the Virtual IP from the Load Balancer - the Virtual IP is not added as a Secondary IP to the OS Network Interface. +# This causes connectivity issues due to SAP NetWeaver instance random dynamic port usage. +# As workaround, configure /etc/hosts to map Virtual Hostname to use the host IP Address instead of the Virtual IP Address, +# by appending an alias of the Virtual Hostname to the existing /etc/hosts entry for the host IP Address. - name: Ansible Play for controlling execution to an Infrastructure Platform when High Availability is used - IBM Cloud when: - (groups["hana_secondary"] is defined and (groups["hana_secondary"] | length>0)) or (groups["nwas_ers"] is defined and (groups["nwas_ers"] | length>0)) or (groups["anydb_secondary"] is defined and (groups["anydb_secondary"] | length>0)) @@ -145,7 +146,8 @@ line: "{{ item }}" state: present loop: - - "{{ sap_vm_provision_dynamic_inventory_nw_ascs_ip }}\t{{ sap_swpm_ascs_instance_hostname }}.{{ ansible_domain }}\t{{ sap_swpm_ascs_instance_hostname }}" + - "{{ sap_vm_provision_dynamic_inventory_nw_ascs_ip }}\t{{ sap_vm_provision_dynamic_inventory_nw_ascs_hostname }}.{{ ansible_domain }}\t{{ sap_vm_provision_dynamic_inventory_nw_ascs_hostname }}\t{{ sap_swpm_ascs_instance_hostname }}.{{ ansible_domain }}\t{{ sap_swpm_ascs_instance_hostname }}" + - "{{ sap_vm_provision_dynamic_inventory_nw_ers_ip }}\t{{ sap_vm_provision_dynamic_inventory_nw_ers_hostname }}.{{ ansible_domain }}\t{{ sap_vm_provision_dynamic_inventory_nw_ers_hostname }}" - "{{ (sap_ha_pacemaker_cluster_vip_nwas_abap_ers_ip_address | default('192.168.2.11/32')) | regex_replace('/.*', '') }}\t{{ sap_swpm_ers_instance_hostname }}.{{ ansible_domain }}\t{{ sap_swpm_ers_instance_hostname }}" when: - (groups["nwas_ers"] is defined and (groups["nwas_ers"] | length>0)) @@ -158,8 +160,37 @@ line: "{{ item }}" state: present loop: + - "{{ sap_vm_provision_dynamic_inventory_nw_ascs_ip }}\t{{ sap_vm_provision_dynamic_inventory_nw_ascs_hostname }}.{{ ansible_domain }}\t{{ sap_vm_provision_dynamic_inventory_nw_ascs_hostname }}" + - "{{ sap_vm_provision_dynamic_inventory_nw_ers_ip }}\t{{ sap_vm_provision_dynamic_inventory_nw_ers_hostname }}.{{ ansible_domain }}\t{{ sap_vm_provision_dynamic_inventory_nw_ers_hostname }}\t{{ sap_swpm_ers_instance_hostname }}.{{ ansible_domain }}\t{{ sap_swpm_ers_instance_hostname }}" + - "{{ (sap_ha_pacemaker_cluster_vip_nwas_abap_ascs_ip_address | default('192.168.2.10/32')) | regex_replace('/.*', '') }}\t{{ sap_swpm_ascs_instance_hostname }}.{{ ansible_domain }}\t{{ sap_swpm_ascs_instance_hostname }}" + when: + - (groups["nwas_ers"] is defined and (groups["nwas_ers"] | length>0)) + - ansible_chassis_asset_tag == 'ibmcloud' + - inventory_hostname_short in groups['nwas_ers'] + + # Remove /etc/hosts entries and then consolidate into one entry with aliases + - name: Remove /etc/hosts multiple entries for SAP NetWeaver ASCS and ASCS HA Virtual Hostname + ansible.builtin.lineinfile: + dest: /etc/hosts + line: "{{ item }}" + state: absent + loop: + - "{{ sap_vm_provision_dynamic_inventory_nw_ascs_ip }}\t{{ sap_vm_provision_dynamic_inventory_nw_ascs_hostname }}.{{ ansible_domain }}\t{{ sap_vm_provision_dynamic_inventory_nw_ascs_hostname }}" - "{{ (sap_ha_pacemaker_cluster_vip_nwas_abap_ascs_ip_address | default('192.168.2.10/32')) | regex_replace('/.*', '') }}\t{{ sap_swpm_ascs_instance_hostname }}.{{ ansible_domain }}\t{{ sap_swpm_ascs_instance_hostname }}" - - "{{ sap_vm_provision_dynamic_inventory_nw_ers_ip }}\t{{ sap_swpm_ers_instance_hostname }}.{{ ansible_domain }}\t{{ sap_swpm_ers_instance_hostname }}" + when: + - (groups["nwas_ers"] is defined and (groups["nwas_ers"] | length>0)) + - ansible_chassis_asset_tag == 'ibmcloud' + - inventory_hostname_short in groups['nwas_ascs'] + + # Remove /etc/hosts entries and then consolidate into one entry with aliases + - name: Remove /etc/hosts multiple entries for SAP NetWeaver ERS and ERS HA Virtual Hostname + ansible.builtin.lineinfile: + dest: /etc/hosts + line: "{{ item }}" + state: absent + loop: + - "{{ sap_vm_provision_dynamic_inventory_nw_ers_ip }}\t{{ sap_vm_provision_dynamic_inventory_nw_ers_hostname }}.{{ ansible_domain }}\t{{ sap_vm_provision_dynamic_inventory_nw_ers_hostname }}" + - "{{ (sap_ha_pacemaker_cluster_vip_nwas_abap_ers_ip_address | default('192.168.2.11/32')) | regex_replace('/.*', '') }}\t{{ sap_swpm_ers_instance_hostname }}.{{ ansible_domain }}\t{{ sap_swpm_ers_instance_hostname }}" when: - (groups["nwas_ers"] is defined and (groups["nwas_ers"] | length>0)) - ansible_chassis_asset_tag == 'ibmcloud' diff --git a/roles/sap_vm_provision/tasks/platform_ansible/ibmcloud_vs/execute_provision.yml b/roles/sap_vm_provision/tasks/platform_ansible/ibmcloud_vs/execute_provision.yml index cc0525e..dcb272e 100644 --- a/roles/sap_vm_provision/tasks/platform_ansible/ibmcloud_vs/execute_provision.yml +++ b/roles/sap_vm_provision/tasks/platform_ansible/ibmcloud_vs/execute_provision.yml @@ -65,7 +65,8 @@ 'definition_key': storage_item.name, 'name': storage_item.name + idx|string, 'size': storage_item.disk_size | default(0), - 'type': storage_item.disk_type | default('general-purpose') + 'type': storage_item.disk_type | default('general-purpose'), + 'iops': storage_item.disk_iops | default(omit) } ]) %} {%- endif %} @@ -83,6 +84,7 @@ name: "{{ inventory_hostname + '-vol-' + vol_item.name | replace('_', '-')}}" profile: "{{ vol_item.type }}" capacity: "{{ vol_item.size }}" + iops: "{{ vol_item.iops | default(omit) }}" ibmcloud_api_key: "{{ sap_vm_provision_ibmcloud_api_key }}" loop: "{{ storage_disks_map }}" loop_control: