From e27c6a3f291993ad5fb2b6b7ab7e1406435f4575 Mon Sep 17 00:00:00 2001 From: Marcel Mamula Date: Fri, 15 Aug 2025 15:02:06 +0200 Subject: [PATCH] compatibility fixes for ansible-core 2.19 --- roles/sap_vm_provision/tasks/common/set_etc_hosts_ha.yml | 2 +- .../platform_ansible/aws_ec2_vs/execute_setup_ha.yml | 6 +++--- .../platform_ansible/msazure_vm/execute_setup_ha.yml | 8 +++++++- roles/sap_vm_temp_vip/tasks/get_temp_vip_details.yml | 8 ++++---- roles/sap_vm_temp_vip/tasks/main.yml | 4 ++-- roles/sap_vm_temp_vip/tasks/set_temp_vip.yml | 9 ++++++--- roles/sap_vm_temp_vip/tasks/set_temp_vip_lb_listener.yml | 9 ++++++--- 7 files changed, 29 insertions(+), 17 deletions(-) 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 ed99ad92..7e28f332 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 @@ -89,7 +89,7 @@ # - "{{ sap_vm_provision_dynamic_inventory_nw_pas_ip }}\t{{ sap_vm_provision_dynamic_inventory_nw_pas_hostname }}.{{ ansible_domain }}\t{{ sap_vm_provision_dynamic_inventory_nw_pas_hostname }}" # Allows to build ASCS ERS cluster without PAS if PAS details are not provided - "{{ sap_vm_provision_dynamic_inventory_nw_pas_ip | string + '\t' + sap_vm_provision_dynamic_inventory_nw_pas_hostname + '.' + ansible_domain + '\t' + sap_vm_provision_dynamic_inventory_nw_pas_hostname - if (sap_vm_provision_dynamic_inventory_nw_pas_hostname is defined and sap_vm_provision_dynamic_inventory_nw_pas_hostname | length > 0 ) + if (sap_vm_provision_dynamic_inventory_nw_pas_hostname is defined and sap_vm_provision_dynamic_inventory_nw_pas_hostname is not none and sap_vm_provision_dynamic_inventory_nw_pas_hostname | length > 0 ) and (sap_vm_provision_dynamic_inventory_nw_pas_ip is defined and sap_vm_provision_dynamic_inventory_nw_pas_ip | length > 0) else ''}}" when: - (groups[sap_vm_provision_group_nwas_ers] is defined and (groups[sap_vm_provision_group_nwas_ers] | length>0)) diff --git a/roles/sap_vm_provision/tasks/platform_ansible/aws_ec2_vs/execute_setup_ha.yml b/roles/sap_vm_provision/tasks/platform_ansible/aws_ec2_vs/execute_setup_ha.yml index 89332691..296db2e7 100644 --- a/roles/sap_vm_provision/tasks/platform_ansible/aws_ec2_vs/execute_setup_ha.yml +++ b/roles/sap_vm_provision/tasks/platform_ansible/aws_ec2_vs/execute_setup_ha.yml @@ -17,11 +17,11 @@ loop: "{{ (groups[sap_vm_provision_group_hana_primary] + groups[sap_vm_provision_group_hana_secondary] - if groups[sap_vm_provision_group_hana_secondary] is defined and groups[sap_vm_provision_group_hana_secondary] else []) + if groups[sap_vm_provision_group_hana_secondary] is defined and groups[sap_vm_provision_group_hana_secondary] | length > 0 else []) + (groups[sap_vm_provision_group_anydb_primary] + groups[sap_vm_provision_group_anydb_secondary] - if groups[sap_vm_provision_group_anydb_secondary] is defined and groups[sap_vm_provision_group_anydb_secondary] else []) + if groups[sap_vm_provision_group_anydb_secondary] is defined and groups[sap_vm_provision_group_anydb_secondary] | length > 0 else []) + (groups[sap_vm_provision_group_nwas_ascs] + groups[sap_vm_provision_group_nwas_ers] - if groups[sap_vm_provision_group_nwas_ers] is defined and groups[sap_vm_provision_group_nwas_ers] else []) + if groups[sap_vm_provision_group_nwas_ers] is defined and groups[sap_vm_provision_group_nwas_ers] | length > 0 else []) }}" loop_control: loop_var: host_node diff --git a/roles/sap_vm_provision/tasks/platform_ansible/msazure_vm/execute_setup_ha.yml b/roles/sap_vm_provision/tasks/platform_ansible/msazure_vm/execute_setup_ha.yml index 0f373cc9..a42fde6c 100644 --- a/roles/sap_vm_provision/tasks/platform_ansible/msazure_vm/execute_setup_ha.yml +++ b/roles/sap_vm_provision/tasks/platform_ansible/msazure_vm/execute_setup_ha.yml @@ -669,7 +669,13 @@ - name: MS Azure Load Balancer (network L4) - Define Ansible Variable of Load Balancer for Database Server ansible.builtin.set_fact: - __sap_vm_provision_task_msazure_lb1_info: "{{ __sap_vm_provision_task_msazure_lb1a_info if (groups[sap_vm_provision_group_hana_secondary] is defined and (groups[sap_vm_provision_group_hana_secondary]|length>0)) else __sap_vm_provision_task_msazure_lb1b_info if (groups[sap_vm_provision_group_anydb_secondary] is defined and (groups[sap_vm_provision_group_anydb_secondary]|length>0)) }}" + __sap_vm_provision_task_msazure_lb1_info: + "{{ __sap_vm_provision_task_msazure_lb1a_info + if (groups[sap_vm_provision_group_hana_secondary] is defined and (groups[sap_vm_provision_group_hana_secondary]|length>0)) + else __sap_vm_provision_task_msazure_lb1b_info + if (groups[sap_vm_provision_group_anydb_secondary] is defined and (groups[sap_vm_provision_group_anydb_secondary]|length>0)) + else none }}" + when: (groups[sap_vm_provision_group_hana_secondary] is defined and (groups[sap_vm_provision_group_hana_secondary]|length>0)) or (groups[sap_vm_provision_group_anydb_secondary] is defined and (groups[sap_vm_provision_group_anydb_secondary]|length>0)) - name: Set fact to hold loop variables from include_tasks when SAP HANA HA diff --git a/roles/sap_vm_temp_vip/tasks/get_temp_vip_details.yml b/roles/sap_vm_temp_vip/tasks/get_temp_vip_details.yml index 1ed03abc..8fe514d9 100644 --- a/roles/sap_vm_temp_vip/tasks/get_temp_vip_details.yml +++ b/roles/sap_vm_temp_vip/tasks/get_temp_vip_details.yml @@ -37,13 +37,13 @@ - name: Calculate prefix from IP {{ sap_vm_temp_vip_default_ip }} if sap_vm_temp_vip_default_netmask is empty ansible.builtin.set_fact: __sap_vm_temp_vip_get_prefix_ip: - "{{ (__sap_vm_temp_vip_inet[0] | basename) if __sap_vm_temp_vip_inet | length > 0 else __sap_vm_temp_vip_inet }}" + "{{ __sap_vm_temp_vip_inet[0] if __sap_vm_temp_vip_inet | length > 0 else '' }}" vars: - __sap_vm_temp_vip_inet: "{{ __sap_vm_temp_vip_get_ips.stdout | regex_search('inet ([0-9.]+/[0-9]+)', '\\1') }}" + __sap_vm_temp_vip_inet: "{{ __sap_vm_temp_vip_get_ips.stdout | regex_search('inet [0-9.]+/([0-9]+)', '\\1') }}" when: - sap_vm_temp_vip_default_prefix == '' - sap_vm_temp_vip_default_netmask == '' - - __sap_vm_temp_vip_get_ips is defined and __sap_vm_temp_vip_get_ips.stdout is defined and __sap_vm_temp_vip_get_ips.stdout | length > 0 + - __sap_vm_temp_vip_get_ips.stdout is defined and __sap_vm_temp_vip_get_ips.stdout | length > 0 changed_when: false @@ -83,7 +83,7 @@ __sap_vm_temp_vip_brd: "{{ __sap_vm_temp_vip_get_ips.stdout | regex_search('brd ([0-9.]+)', '\\1') }}" when: - sap_vm_temp_vip_default_broadcast == '' - - __sap_vm_temp_vip_get_ips is defined and __sap_vm_temp_vip_get_ips.stdout is defined and __sap_vm_temp_vip_get_ips.stdout | length > 0 + - __sap_vm_temp_vip_get_ips.stdout is defined and __sap_vm_temp_vip_get_ips.stdout | length > 0 changed_when: false # Combine final broadcast IP based on decision below: diff --git a/roles/sap_vm_temp_vip/tasks/main.yml b/roles/sap_vm_temp_vip/tasks/main.yml index 488968fb..fc792cbb 100644 --- a/roles/sap_vm_temp_vip/tasks/main.yml +++ b/roles/sap_vm_temp_vip/tasks/main.yml @@ -17,8 +17,8 @@ - name: Block to ensure that only supported groups are allowed when: - - group_names | intersect([sap_vm_temp_vip_group_hana_primary, sap_vm_temp_vip_group_hana_secondary, sap_vm_temp_vip_group_anydb_primary, - sap_vm_temp_vip_group_anydb_secondary, sap_vm_temp_vip_group_nwas_ascs, sap_vm_temp_vip_group_nwas_ers]) + - (group_names | intersect([sap_vm_temp_vip_group_hana_primary, sap_vm_temp_vip_group_hana_secondary, sap_vm_temp_vip_group_anydb_primary, + sap_vm_temp_vip_group_anydb_secondary, sap_vm_temp_vip_group_nwas_ascs, sap_vm_temp_vip_group_nwas_ers])) | length > 0 block: # - name: Identify OS Primary Network Interface diff --git a/roles/sap_vm_temp_vip/tasks/set_temp_vip.yml b/roles/sap_vm_temp_vip/tasks/set_temp_vip.yml index 50ab192c..45129e58 100644 --- a/roles/sap_vm_temp_vip/tasks/set_temp_vip.yml +++ b/roles/sap_vm_temp_vip/tasks/set_temp_vip.yml @@ -23,6 +23,7 @@ # Define VIP address based on target host group which is filtered in main.yml +# Else ensures that we always return String, not NoneType. - name: Set fact for VIP address depending on target host group ansible.builtin.set_fact: __sap_vm_temp_vip_address: >- @@ -34,6 +35,8 @@ {{ sap_vm_temp_vip_nwas_abap_ascs | regex_replace('/.*', '') }} {%- elif groups[sap_vm_temp_vip_group_nwas_ers] | d([]) | length > 0 and inventory_hostname in groups[sap_vm_temp_vip_group_nwas_ers] -%} {{ sap_vm_temp_vip_nwas_abap_ers | regex_replace('/.*', '') }} + {%- else -%} + {{ '' }} {%- endif %} # Get content of ip address show filtered by VIP @@ -41,7 +44,7 @@ ansible.builtin.shell: cmd: set -o pipefail && ip -oneline address show | grep {{ __sap_vm_temp_vip_address }} when: - - __sap_vm_temp_vip_address is defined and __sap_vm_temp_vip_address | length > 0 + - __sap_vm_temp_vip_address | length > 0 register: __sap_vm_temp_vip_get_vip changed_when: false ignore_errors: true @@ -72,7 +75,7 @@ __vip_multiple: "{{ true if __sap_vm_temp_vip_get_vip.stdout_lines | length > 1 else false }}" when: - __sap_vm_temp_vip_get_vip.stdout is defined and __sap_vm_temp_vip_get_vip.stdout | length > 0 - - __sap_vm_temp_vip_address is defined and __sap_vm_temp_vip_address | length > 0 + - __sap_vm_temp_vip_address | length > 0 # Dynamically generate IP creation command depending on values gathered before: @@ -88,7 +91,7 @@ ip address add {{ __sap_vm_temp_vip_address }}/{{ __sap_vm_temp_vip_prefix }} brd + dev {{ sap_vm_temp_vip_default_interface }} noprefixroute {%- endif -%} when: - - __sap_vm_temp_vip_address is defined and __sap_vm_temp_vip_address | length > 0 + - __sap_vm_temp_vip_address | length > 0 - __sap_vm_temp_vip_prefix | length > 0 - __sap_vm_temp_vip_get_vip.stdout is defined and __sap_vm_temp_vip_get_vip.stdout | length == 0 diff --git a/roles/sap_vm_temp_vip/tasks/set_temp_vip_lb_listener.yml b/roles/sap_vm_temp_vip/tasks/set_temp_vip_lb_listener.yml index 28edf601..64f2b01a 100644 --- a/roles/sap_vm_temp_vip/tasks/set_temp_vip_lb_listener.yml +++ b/roles/sap_vm_temp_vip/tasks/set_temp_vip_lb_listener.yml @@ -3,6 +3,7 @@ # 55550 - SAP HANA and SAP AnyDB # 55551 - SAP SAP NetWeaver ASCS # 55552 - SAP NetWeaver ERS +# Else ensures that we always return String, not NoneType. - name: Set fact for temporary listening port ansible.builtin.set_fact: __sap_vm_temp_vip_port: >- @@ -14,6 +15,8 @@ 55551 {%- elif groups[sap_vm_temp_vip_group_nwas_ers] | d([]) | length > 0 and inventory_hostname in groups[sap_vm_temp_vip_group_nwas_ers] -%} 55552 + {%- else -%} + {{ '' }} {%- endif %} @@ -24,14 +27,14 @@ cmd: ss -tulnH "sport = :{{ __sap_vm_temp_vip_port }}" register: __sap_vm_temp_vip_port_check when: - - __sap_vm_temp_vip_port is defined and __sap_vm_temp_vip_port | length > 0 + - __sap_vm_temp_vip_port | length > 0 changed_when: false - name: Block to start temporary netcat processes for Load Balancer Health Checks when: - - __sap_vm_temp_vip_address is defined and __sap_vm_temp_vip_address | length > 0 - - __sap_vm_temp_vip_port is defined and __sap_vm_temp_vip_port | length > 0 + - __sap_vm_temp_vip_address | length > 0 + - __sap_vm_temp_vip_port | length > 0 - __sap_vm_temp_vip_port_check.stdout is defined and __sap_vm_temp_vip_port_check.stdout | length == 0 - __sap_vm_temp_vip_prefix | length > 0 # Dont execute if prefix was empty during VIP creation block: