Skip to content

Commit e4a0353

Browse files
committed
Refactor firewall management
Introduces a new variable `firewall_cfg` in the `sap-hana-preconfigure` playbook to provide more explicit control over the firewalld service. This new variable allows to 'enable', 'disable', or 'ignore' the firewall configuration. The `sap_hana_install` role is updated to delegate the firewall service management to the preconfigure playbook, avoiding conflicts and centralizing the configuration. The documentation has been updated to reflect these changes. Softfail for bsc#1254356 in 16.0
1 parent 602ea78 commit e4a0353

7 files changed

Lines changed: 111 additions & 79 deletions

File tree

ansible/playbooks/roles/sap_hana_install/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ or if it will add further hosts to an existing SAP HANA system as specified by v
140140
`sap_hana_install_addhosts`. Default is `yes` for a fresh SAP HANA installation.
141141
142142
The role can be configured to also set the required firewall ports for SAP HANA. If this is desired, set
143-
the variable `sap_hana_install_update_firewall` to `yes` (default is `no`). The firewall ports are defined
143+
the variable `sap_hana_install_update_firewall` to `true` (default is `false` that means the role will not touch
144+
any firewall related system settings, leaving whatever the system has unchanged). The firewall ports are defined
144145
in a variable which is compatible with the variable structure used by Linux System Role `firewall`.
145146
The firewall ports for SAP HANA are defined in member `port` of the first field of variable
146147
`sap_hana_install_firewall` (`sap_hana_install_firewall[0].port`), see file `defaults/main.yml`. If the
@@ -257,7 +258,7 @@ You can find more complex playbooks in directory `playbooks` of the collection `
257258
- Extract all SAR files into `sap_hana_install_software_extract_directory`.
258259

259260
Note: For each SAPCAR or SAR file called or used by the role, if variable `sap_hana_install_verify_checksums`
260-
is set to `yes`, the role will perform a checksum verification against a specific or global checksum file.
261+
is set to `true`, the role will perform a checksum verification against a specific or global checksum file.
261262

262263
- Check existence of `hdblcm` in `SAP_HANA_DATABASE` directory from the extracted SAR files.
263264

@@ -327,7 +328,7 @@ With the following tags, the role can be called to perform certain activities on
327328
with `--skip-tags`, to skip modifying these directories. This can be useful when using tag
328329
`sap_hana_install_preinstall`.
329330
- tag `sap_hana_install_configure_firewall`: Use this flag to only configure the firewall ports for
330-
SAP HANA. Note: The role variable `sap_hana_install_update_firewall` has to be set to `yes` as
331+
SAP HANA. Note: The role variable `sap_hana_install_update_firewall` has to be set to `true` as
331332
well.
332333
- tag `sap_hana_install_extract_sarfiles`: Use this flag with `--skip-tags` to run the SAR file
333334
preparation steps of tag `sap_hana_install_prepare_sarfiles` without extracting the SAR files.

ansible/playbooks/roles/sap_hana_install/defaults/main.yml

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,39 @@ sap_hana_install_software_directory: '/software/hana'
1111
# created again before the extraction starts.
1212
sap_hana_install_software_extract_directory: "{{ sap_hana_install_software_directory }}/extracted"
1313

14-
# Set this variabe to `yes` if you want to copy the SAR files from `sap_hana_install_software_directory`
14+
# Set this variabe to `true` if you want to copy the SAR files from `sap_hana_install_software_directory`
1515
# to `sap_hana_install_software_extract_directory/sarfiles` before extracting.
1616
# This might be useful if the SAR files are on a slow fileshare.
17-
sap_hana_install_copy_sarfiles: no
17+
sap_hana_install_copy_sarfiles: false
1818

19-
# Set the following variable to `yes` if you want to keep the copied SAR files. By default, the SAR files will be
19+
# Set the following variable to `true` if you want to keep the copied SAR files. By default, the SAR files will be
2020
# removed after extraction.
21-
sap_hana_install_keep_copied_sarfiles: no
21+
sap_hana_install_keep_copied_sarfiles: false
2222

2323
# File name of SAPCAR*EXE in the software directory. If the variable is not set and there is more than one SAPCAR executable
2424
# in the software directory, the latest SAPCAR executable for the CPU architecture will be selected automatically.
25-
#sap_hana_install_sapcar_filename: SAPCAR_1115-70006178.EXE
25+
# sap_hana_install_sapcar_filename: SAPCAR_1115-70006178.EXE
2626

2727
# List of file names of SAR files to extract. Can be set in case there are more SAR files in the software directory
2828
# than needed or desired for the HANA installation.
29-
#sap_hana_install_sarfiles:
30-
# - SAPHOSTAGENT54_54-80004822.SAR
31-
# - IMDB_SERVER20_060_0-80002031.SAR
29+
# sap_hana_install_sarfiles:
30+
# - SAPHOSTAGENT54_54-80004822.SAR
31+
# - IMDB_SERVER20_060_0-80002031.SAR
3232

33-
# Set the following variable to `yes` to let the role abort if checksum verification fails for any SAPCAR or SAR file
33+
# Set the following variable to `true` to let the role abort if checksum verification fails for any SAPCAR or SAR file
3434
# called or used by the role.
35-
sap_hana_install_verify_checksums: no
35+
sap_hana_install_verify_checksums: false
3636

3737
# Checksum algorithm for checksum verification. Default is sha256, for which a checksum is available in the SAP software
3838
# download pages.
3939
sap_hana_install_checksum_algorithm: sha256
4040

4141
# In case a global checksum file is present, use the following variable to specify the full path to this file:
42-
#sap_hana_install_global_checksum_file: "{{ sap_hana_install_software_directory }}/SHA256"
42+
# sap_hana_install_global_checksum_file: "{{ sap_hana_install_software_directory }}/SHA256"
4343

44-
# Set the following variable to `yes` to let hdbclm verify SAR file signatures. This corresponds to the hdblcm command line
44+
# Set the following variable to `true` to let hdbclm verify SAR file signatures. This corresponds to the hdblcm command line
4545
# argument `--verify_signature`.
46-
sap_hana_install_verify_signature: no
46+
sap_hana_install_verify_signature: false
4747

4848
# hdblcm configfile related variables:
4949
# Directory where to store the hdblcm configfile template and the Jinja2 template:
@@ -57,31 +57,31 @@ sap_hana_install_local_configfile_directory: '/tmp'
5757

5858
# If you would like to perform an installation check after the installation, set the following variable to 'yes'.
5959
# Note: This only works if there is no static configfile available in sap_hana_install_configfile_directory.
60-
sap_hana_install_check_installation: no
60+
sap_hana_install_check_installation: false
6161

62-
# Only if sap_hana_install_check_installation (above) is set to 'yes', you can select which command to use by setting the
63-
# following variable to `yes` or `no`.
62+
# Only if sap_hana_install_check_installation (above) is set to 'true', you can select which command to use by setting the
63+
# following variable to `true` or `false`.
6464
# yes: use the command 'hdbcheck', with parameters `--remote_execution=ssh` and `--scope=system`
6565
# no: use the command `hdblcm --action=check_installation`
66-
sap_hana_install_use_hdbcheck: yes
66+
sap_hana_install_use_hdbcheck: true
6767

68-
# If the following variable is set to `no`, the role will attempt to install SAP HANA even if there is already a sidadm user.
69-
# Default is `yes`.
70-
sap_hana_install_check_sidadm_user: yes
68+
# If the following variable is set to `false`, the role will attempt to install SAP HANA even if there is already a sidadm user.
69+
# Default is `true`.
70+
sap_hana_install_check_sidadm_user: true
7171

72-
# If the following variable is undefined or set to `yes`, the role will perform a fresh SAP HANA installation.
73-
# If set to `no`, additional hosts as specified by variable sap_hana_install_addhosts will be added to
72+
# If the following variable is undefined or set to `true`, the role will perform a fresh SAP HANA installation.
73+
# If set to `false`, additional hosts as specified by variable sap_hana_install_addhosts will be added to
7474
# an existing HANA system.
75-
sap_hana_install_new_system: yes
75+
sap_hana_install_new_system: true
7676

7777
# The first tenant database is using a port range not within the range of the ports of additional tenant databases.
7878
# In case this is not desired, you can set the following parameter to `yes` to recreate the initial tenant database.
79-
sap_hana_install_recreate_tenant_database: no
79+
sap_hana_install_recreate_tenant_database: false
8080

8181
# The following parameter controls if the log_mode should be set to overwrite following the installation of the database.
8282
# log_mode overwrite is useful in non-prod testing as log backups are not created and disk use is kept low
8383
# However, log_mode overwrite disabled to ability to do point-in-time restores and is not supported in production
84-
sap_hana_set_log_mode_overwrite: no
84+
sap_hana_install_set_log_mode_overwrite: false
8585

8686
################
8787
# Parameters for hdblcm:
@@ -91,8 +91,8 @@ sap_hana_set_log_mode_overwrite: no
9191
sap_hana_install_components: 'all'
9292

9393
# Pass some extra arguments to hdblcm, see some examples below.
94-
#sap_hana_install_hdblcm_extraargs: '--verify_signature'
95-
#sap_hana_install_hdblcm_extraargs: '--ignore=check_diskspace,check_min_mem'
94+
# sap_hana_install_hdblcm_extraargs: '--verify_signature'
95+
# sap_hana_install_hdblcm_extraargs: '--ignore=check_diskspace,check_min_mem'
9696

9797
# Instance details
9898
sap_hana_install_sid:
@@ -105,25 +105,25 @@ sap_hana_install_restrict_max_mem: 'n'
105105
sap_hana_install_max_mem:
106106

107107
# hdblcm will use default ids if blank
108-
sap_hana_install_userid:
108+
sap_hana_install_userid:
109109
sap_hana_install_groupid:
110110

111111
# Passwords
112112
# Setting master password to 'y' will use that master password for all passwords - recommended
113113
sap_hana_install_use_master_password: 'y'
114114
# Set one or more of the following password variables in your playbook or inventory.
115-
#sap_hana_install_master_password:
116-
#sap_hana_install_sidadm_password:
117-
#sap_hana_install_db_system_password:
118-
#sap_hana_install_lss_user_password:
119-
#sap_hana_install_lss_backup_password:
120-
#sap_hana_install_ase_user_password:
121-
#sap_hana_install_root_password:
122-
#sap_hana_install_sapadm_password:
123-
#sap_hana_install_xs_org_password:
115+
# sap_hana_install_master_password:
116+
# sap_hana_install_sidadm_password:
117+
# sap_hana_install_db_system_password:
118+
# sap_hana_install_lss_user_password:
119+
# sap_hana_install_lss_backup_password:
120+
# sap_hana_install_ase_user_password:
121+
# sap_hana_install_root_password:
122+
# sap_hana_install_sapadm_password:
123+
# sap_hana_install_xs_org_password:
124124

125125
# Optional steps
126-
sap_hana_install_update_firewall: no
126+
sap_hana_install_update_firewall: false
127127

128128
# List of firewall ports for SAP HANA. Note: The structure of the variable is compatible
129129
# with the variable `firewall` of Linux System Role `firewall`.
@@ -149,16 +149,16 @@ sap_hana_install_firewall:
149149
state: 'enabled' }
150150

151151
# The following variable is no longer used. Setting /etc/hosts entries is done in role sap_general_preconfigure.
152-
#sap_hana_install_update_etchosts: yes
152+
# sap_hana_install_update_etchosts: yes
153153

154154
# Post install parameters
155155
sap_hana_install_hdbuserstore_key: 'HDB_SYSTEMDB'
156156
sap_hana_install_nw_input_location: '/tmp'
157157

158158
# License
159-
sap_hana_install_apply_license: no
160-
#sap_hana_install_license_path:
161-
#sap_hana_install_license_file_name:
159+
sap_hana_install_apply_license: false
160+
# sap_hana_install_license_path:
161+
# sap_hana_install_license_file_name:
162162

163163
# Misc
164164

@@ -178,7 +178,7 @@ sap_hana_install_create_initial_tenant: 'y'
178178
# hosts to an existing HANA system.
179179
# Corresponding hdblcm parameter: addhosts
180180
# Example:
181-
#sap_hana_install_addhosts: 'host2:role=worker,host3:role=worker:group=g02,host4:role=standby:group=g02'
181+
# sap_hana_install_addhosts: 'host2:role=worker,host3:role=worker:group=g02,host4:role=standby:group=g02'
182182

183183
# The hostname is set by 'hdblcm --dump_configfile_template' during the preinstall phase but can also
184184
# be set to a different value in your playbook or hostvars:

ansible/playbooks/roles/sap_hana_install/tasks/main.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
- name: Rename some variables used by hdblcm configfile
44
ansible.builtin.set_fact:
5-
sap_hana_install_sid: "{{ sap_hana_sid|d(sap_hana_install_sid)|d('') }}"
6-
sap_hana_install_number: "{{ sap_hana_instance_number|d(sap_hana_install_instance_number|d(sap_hana_install_number)|d('')) }}"
7-
sap_hana_install_master_password: "{{ sap_hana_install_common_master_password|d(sap_hana_install_master_password) }}"
8-
sap_hana_install_system_usage: "{{ sap_hana_install_env_type|d(sap_hana_install_system_usage) }}"
9-
sap_hana_install_restrict_max_mem: "{{ sap_hana_install_mem_restrict|d(sap_hana_install_restrict_max_mem) }}"
10-
sap_hana_set_log_mode_overwrite: "{{ sap_hana_set_log_mode_overwrite|default (true)}}"
5+
sap_hana_install_sid: "{{ sap_hana_sid | d(sap_hana_install_sid) | d('') }}"
6+
sap_hana_install_number: "{{ sap_hana_instance_number | d(sap_hana_install_instance_number | d(sap_hana_install_number) | d('')) }}"
7+
sap_hana_install_master_password: "{{ sap_hana_install_common_master_password | d(sap_hana_install_master_password) }}"
8+
sap_hana_install_system_usage: "{{ sap_hana_install_env_type | d(sap_hana_install_system_usage) }}"
9+
sap_hana_install_restrict_max_mem: "{{ sap_hana_install_mem_restrict | d(sap_hana_install_restrict_max_mem) }}"
10+
sap_hana_install_set_log_mode_overwrite: "{{ sap_hana_install_set_log_mode_overwrite | default(true) }}"
1111
tags:
1212
- sap_hana_install_preinstall
1313
- sap_hana_install_set_log_mode

ansible/playbooks/roles/sap_hana_install/tasks/post_install/firewall.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22

3-
- name: SAP HANA Post Install - Enable and start the firewalld service
4-
ansible.builtin.systemd:
5-
name: firewalld
6-
state: started
7-
enabled: yes
8-
tags: sap_hana_install_configure_firewall
3+
# - name: SAP HANA Post Install - Enable and start the firewalld service
4+
# ansible.builtin.systemd:
5+
# name: firewalld
6+
# state: started
7+
# enabled: true
8+
# tags: sap_hana_install_configure_firewall
99

1010
- name: SAP HANA Post Install - Construct the argument list for 'firewall-cmd --add-port'
1111
ansible.builtin.set_fact:
@@ -37,12 +37,12 @@
3737
# of the no-changed-when rule, we just set changed_when to true here.
3838
- name: SAP HANA Post Install - Enable the required ports immediately
3939
ansible.builtin.command: "{{ __sap_hana_install_fact_firewall_cmd_command }}"
40-
changed_when: yes
40+
changed_when: true
4141
tags: sap_hana_install_configure_firewall
4242

4343
- name: SAP HANA Post Install - Get the current firewall configuration of the default zone
4444
ansible.builtin.command: firewall-cmd --list-all
45-
changed_when: no
45+
changed_when: false
4646
register: __sap_hana_install_register_current_firewall_ports
4747
tags: sap_hana_install_configure_firewall
4848

@@ -56,12 +56,12 @@
5656
# of the no-changed-when rule, we just set changed_when to true here.
5757
- name: SAP HANA Post Install - Enable the required ports permanently
5858
ansible.builtin.command: "{{ __sap_hana_install_fact_firewall_cmd_command }} --permanent"
59-
changed_when: yes
59+
changed_when: true
6060
tags: sap_hana_install_configure_firewall
6161

6262
- name: SAP HANA Post Install - Get the permanent firewall configuration of the default zone
6363
ansible.builtin.command: firewall-cmd --list-all
64-
changed_when: no
64+
changed_when: false
6565
register: __sap_hana_install_register_permanent_firewall_ports
6666
tags: sap_hana_install_configure_firewall
6767

ansible/playbooks/roles/sap_hana_install/tasks/post_install/log_mode.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
executable: /bin/bash
1919
become: true
2020
become_user: "{{ sap_hana_install_sid | lower }}adm"
21-
when:
21+
when:
2222
- not ansible_check_mode
23-
- sap_hana_set_log_mode_overwrite
24-
changed_when: no
23+
- sap_hana_install_set_log_mode_overwrite
24+
changed_when: false
2525
register: __sap_hana_install_hdbsql_logmode
2626
tags: sap_hana_install_set_log_mode
2727

2828
- name: SAP HANA Post Install - Display the output of hdbsql
2929
ansible.builtin.debug:
3030
var: __sap_hana_install_hdbsql_logmode.stdout_lines
3131
tags: sap_hana_install_set_log_mode
32-
when: sap_hana_set_log_mode_overwrite
32+
when: sap_hana_install_set_log_mode_overwrite

ansible/playbooks/roles/sap_hana_install/tasks/pre_install/prepare_sarfiles.yml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,35 @@
1616
when: sap_hana_install_sarfiles is defined
1717

1818
- name: SAP HANA hdblcm prepare - Find all SAR files if 'sap_hana_install_sarfiles' is undefined
19+
when: sap_hana_install_sarfiles is not defined
1920
block:
20-
2121
- name: SAP HANA hdblcm prepare - Find all SAR files in '{{ sap_hana_install_software_directory }}'
2222
ansible.builtin.find:
2323
paths: "{{ sap_hana_install_software_directory }}"
24-
recurse: no
24+
recurse: false
2525
file_type: file
2626
patterns: '*.SAR'
2727
register: __sap_hana_install_register_find_sarfiles
2828

2929
- name: SAP HANA hdblcm prepare - Create list of file names from the find result
3030
ansible.builtin.set_fact:
31-
__sap_hana_install_fact_sarfiles: "{{ __sap_hana_install_fact_sarfiles|d([]) + [ item.path | basename ] }}"
31+
__sap_hana_install_fact_sarfiles: "{{ __sap_hana_install_fact_sarfiles | d([]) + [item.path | basename] }}"
3232
loop: "{{ __sap_hana_install_register_find_sarfiles.files }}"
3333

3434
- name: Display the resulting list of file names after find
3535
ansible.builtin.debug:
3636
var: __sap_hana_install_fact_sarfiles
3737

38-
when: sap_hana_install_sarfiles is not defined
39-
40-
- name: Copy SAR files to final destination if 'sap_hana_install_copy_sarfiles' is 'yes'
38+
- name: Copy SAR files to final destination if 'sap_hana_install_copy_sarfiles' is 'true'
39+
when: sap_hana_install_copy_sarfiles
4140
block:
42-
43-
- name: SAP HANA hdblcm prepare - Create directory '{{ sap_hana_install_software_extract_directory }}/sarfiles'
41+
- name: SAP HANA hdblcm prepare - Create directory ./sarfiles
4442
ansible.builtin.file:
4543
path: "{{ sap_hana_install_software_extract_directory }}/sarfiles"
4644
state: directory
4745
mode: '0755'
4846

49-
- name: SAP HANA hdblcm prepare - Copy SAR files to '{{ sap_hana_install_software_extract_directory }}/sarfiles'
47+
- name: SAP HANA hdblcm prepare - Copy SAR files to ./sarfiles
5048
ansible.builtin.copy:
5149
src: "{{ sap_hana_install_software_directory }}/{{ item }}"
5250
dest: "{{ sap_hana_install_software_extract_directory }}/sarfiles/{{ item }}"
@@ -60,11 +58,10 @@
6058
ansible.builtin.set_fact:
6159
__sap_hana_install_fact_sar_dir: "{{ sap_hana_install_software_extract_directory }}/sarfiles"
6260

63-
when: sap_hana_install_copy_sarfiles
6461

6562
- name: SAP HANA hdblcm prepare - Fill list of dicts containing dir, file, and global checksum file
6663
ansible.builtin.set_fact:
67-
__sap_hana_install_fact_sarfiles_dict: "{{ __sap_hana_install_fact_sarfiles_dict|d([]) + [ __sap_hana_install_tmp_sarfiles_dict ] }}"
64+
__sap_hana_install_fact_sarfiles_dict: "{{ __sap_hana_install_fact_sarfiles_dict | d([]) + [__sap_hana_install_tmp_sarfiles_dict] }}"
6865
with_items: "{{ __sap_hana_install_fact_sarfiles }}"
6966
vars:
7067
__sap_hana_install_tmp_sarfiles_dict:
@@ -75,7 +72,7 @@
7572

7673
- name: SAP HANA hdblcm prepare - Fill list of dicts containing dir, file, and specific checksum file
7774
ansible.builtin.set_fact:
78-
__sap_hana_install_fact_sarfiles_dict: "{{ __sap_hana_install_fact_sarfiles_dict|d([]) + [ __sap_hana_install_tmp_sarfiles_dict ] }}"
75+
__sap_hana_install_fact_sarfiles_dict: "{{ __sap_hana_install_fact_sarfiles_dict | d([]) + [__sap_hana_install_tmp_sarfiles_dict] }}"
7976
with_items: "{{ __sap_hana_install_fact_sarfiles }}"
8077
vars:
8178
__sap_hana_install_tmp_sarfiles_dict:
@@ -104,7 +101,7 @@
104101
- not ansible_check_mode
105102
tags: sap_hana_install_extract_sarfiles
106103

107-
- name: SAP HANA hdblcm prepare - Remove temporary SAR file directory '{{ sap_hana_install_software_extract_directory }}/sarfiles'
104+
- name: SAP HANA hdblcm prepare - Remove temporary SAR file directory ./sarfiles
108105
ansible.builtin.file:
109106
path: "{{ sap_hana_install_software_extract_directory }}/sarfiles/"
110107
state: absent

0 commit comments

Comments
 (0)