Skip to content

Commit 213cd96

Browse files
authored
Merge pull request #1159 from berndfinger/issue-1146
sap_swpm: Sanitize conditions for 2.19
2 parents fc76540 + 3b30cb6 commit 213cd96

5 files changed

Lines changed: 40 additions & 28 deletions

File tree

roles/sap_swpm/tasks/post_install.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454
become: true
5555
become_user: "{{ sap_swpm_sid | lower }}adm"
5656
when:
57-
- sap_swpm_install_saphostagent is defined and sap_swpm_install_saphostagent
57+
- sap_swpm_install_saphostagent is defined
58+
- sap_swpm_install_saphostagent
5859
- __sap_swpm_post_install_register_hdbuserstore_exists.stat.exists
5960
register: __sap_swpm_post_install_register_hdbuserstore_connection
6061
changed_when: __sap_swpm_post_install_register_hdbuserstore_connection is succeeded

roles/sap_swpm/tasks/post_install/firewall.yml

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,31 @@
2020
enabled: yes
2121
tags: sap_swpm_configure_firewall
2222

23-
- name: SAP SWPM Post Install - Firewall Setup
23+
- name: SAP SWPM Post Install - Firewall tasks if 'sap_swpm_wd_instance_nr' is configured
2424
when:
2525
- sap_swpm_wd_instance_nr is defined
26-
- sap_swpm_wd_instance_nr | length
27-
ansible.builtin.set_fact:
28-
__sap_swpm_fact_sap_nw_firewall_ports:
29-
- "3200-3399"
30-
- "36{{ sap_swpm_pas_instance_nr }}"
31-
- "80{{ sap_swpm_pas_instance_nr }}"
32-
- "443{{ sap_swpm_pas_instance_nr }}"
33-
- "36{{ sap_swpm_ascs_instance_nr }}"
34-
- "80{{ sap_swpm_ascs_instance_nr }}"
35-
- "443{{ sap_swpm_ascs_instance_nr }}"
36-
- "8090"
37-
- "44390"
38-
- "443{{ sap_swpm_wd_instance_nr }}"
39-
40-
- name: SAP SWPM Post Install - Add Ports Based on NR - {{ sap_swpm_pas_instance_nr }}
41-
ansible.builtin.include_tasks: update_firewall.yml
42-
loop: "{{ __sap_swpm_fact_sap_nw_firewall_ports }}"
43-
loop_control:
44-
loop_var: passed_port
26+
- sap_swpm_wd_instance_nr | length > 0
27+
block:
28+
29+
- name: SAP SWPM Post Install - Firewall Setup
30+
ansible.builtin.set_fact:
31+
__sap_swpm_fact_sap_nw_firewall_ports:
32+
- "3200-3399"
33+
- "36{{ sap_swpm_pas_instance_nr }}"
34+
- "80{{ sap_swpm_pas_instance_nr }}"
35+
- "443{{ sap_swpm_pas_instance_nr }}"
36+
- "36{{ sap_swpm_ascs_instance_nr }}"
37+
- "80{{ sap_swpm_ascs_instance_nr }}"
38+
- "443{{ sap_swpm_ascs_instance_nr }}"
39+
- "8090"
40+
- "44390"
41+
- "443{{ sap_swpm_wd_instance_nr }}"
42+
43+
- name: SAP SWPM Post Install - Add Ports Based on NR - {{ sap_swpm_pas_instance_nr }}
44+
ansible.builtin.include_tasks: update_firewall.yml
45+
loop: "{{ __sap_swpm_fact_sap_nw_firewall_ports }}"
46+
loop_control:
47+
loop_var: passed_port
4548

4649
# Reason for noqa: We currently do not determine if reloading the firewall changes anything
4750
- name: SAP SWPM Post Install - Reload Firewall # noqa no-changed-when

roles/sap_swpm/tasks/pre_install.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,14 @@
184184
- sap_swpm_generate_inifile
185185
- sap_swpm_sapinst_commandline
186186

187+
- name: SAP SWPM Pre Install - Assert 'sap_swpm_install_saphostagent' is a boolean if it is defined
188+
ansible.builtin.assert:
189+
that: sap_swpm_install_saphostagent is boolean
190+
fail_msg: "FAIL: 'sap_swpm_install_saphostagent' is not a boolean!"
191+
success_msg: "PASS: 'sap_swpm_install_saphostagent' is a boolean."
192+
when:
193+
- sap_swpm_install_saphostagent is defined
194+
187195
- name: SAP SWPM Pre Install - Assert the hostname compliance with SAP note 611361
188196
ansible.builtin.include_tasks:
189197
file: pre_install/assert_hostname.yml

roles/sap_swpm/tasks/pre_install/install_type.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@
8484

8585
- name: SAP SWPM Pre Install - Assert that necessary variable for HA is defined
8686
ansible.builtin.assert:
87-
that: sap_swpm_virtual_hostname is defined and sap_swpm_virtual_hostname
88-
fail_msg: "FAIL: {{ sap_swpm_virtual_hostname }} is not defined!"
89-
success_msg: "PASS: The variable 'sap_swpm_virtual_hostname' is defined, as '{{ sap_swpm_virtual_hostname }}'."
87+
that: sap_swpm_virtual_hostname is defined and sap_swpm_virtual_hostname | length > 0
88+
fail_msg: "FAIL: 'sap_swpm_virtual_hostname' is not defined or is defined with an empty string!"
89+
success_msg: "PASS: 'sap_swpm_virtual_hostname' is defined, as '{{ sap_swpm_virtual_hostname }}'."
9090
when:
9191
- sap_swpm_swpm_installation_type is search('ha')
9292

roles/sap_swpm/templates/inifile_params.j2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ ERROR:FAIL: Variable 'sap_swpm_ascs_instance_nr' is empty!
11571157
# - Java Gateway (GW) and
11581158
# - Java Internal Web Dispatcher (WD).
11591159
###################################################################
1160-
{% if sap_swpm_java_scs_instance_hostname | string | trim | length > 0 %}
1160+
{% if sap_swpm_java_scs_instance_hostname | trim | length > 0 %}
11611161
NW_CI_Instance.scsVirtualHostname = {{ sap_swpm_java_scs_instance_hostname }}
11621162
{% else %}
11631163
ERROR:FAIL: Variable 'sap_swpm_java_scs_instance_hostname' is empty!
@@ -1167,7 +1167,7 @@ NW_CI_Instance.scsInstanceNumber = {{ sap_swpm_java_scs_instance_nr }}
11671167
{% else %}
11681168
ERROR:FAIL: Variable 'sap_swpm_java_scs_instance_nr' is empty!
11691169
{% endif %}
1170-
{% if sap_swpm_java_scs_instance_hostname | string | trim | length > 0 %}
1170+
{% if sap_swpm_java_scs_instance_hostname | trim | length > 0 %}
11711171
NW_SCS_Instance.scsVirtualHostname = {{ sap_swpm_java_scs_instance_hostname }}
11721172
{% else %}
11731173
ERROR:FAIL: Variable 'sap_swpm_java_scs_instance_hostname' is empty!
@@ -1244,7 +1244,7 @@ NW_DI_Instance.virtualHostname = {{ sap_swpm_aas_instance_hostname }}
12441244
###################################################################
12451245
# BEGIN section nw_config_ers #
12461246
# #
1247-
{% if sap_swpm_ers_instance_hostname | string | trim | length > 0 %}
1247+
{% if sap_swpm_ers_instance_hostname | trim | length > 0 %}
12481248
nw_instance_ers.ersVirtualHostname = {{ sap_swpm_ers_instance_hostname }}
12491249
{% else %}
12501250
ERROR:FAIL: Variable 'sap_swpm_ers_instance_hostname' is empty!
@@ -1317,7 +1317,7 @@ ERROR: Inifile Parameter: 'UmeConfiguration.sapjsfPassword'
13171317
{% endif %}
13181318
{% endif %}
13191319
UmeConfiguration.umeClient = {{ sap_swpm_ume_client_nr }}
1320-
{% if sap_swpm_pas_instance_hostname | string | trim | length > 0 %}
1320+
{% if sap_swpm_pas_instance_hostname | trim | length > 0 %}
13211321
UmeConfiguration.umeHost = {{ sap_swpm_pas_instance_hostname }}
13221322
{% else %}
13231323
ERROR:FAIL: Variable 'sap_swpm_pas_instance_hostname' is empty!

0 commit comments

Comments
 (0)