Skip to content

Commit a739706

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.
1 parent fd8bea6 commit a739706

3 files changed

Lines changed: 29 additions & 7 deletions

File tree

ansible/playbooks/roles/sap_hana_install/README.md

Lines changed: 2 additions & 1 deletion
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 `yes` (default is `no`, 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

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
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+
# Controlled by sap-hana-preconfigure.yaml playbook
4+
#- name: SAP HANA Post Install - Enable and start the firewalld service
5+
# ansible.builtin.systemd:
6+
# name: firewalld
7+
# state: started
8+
# enabled: yes
9+
# tags: sap_hana_install_configure_firewall
910

1011
- name: SAP HANA Post Install - Set LogDenied to all in firewalld.conf
1112
ansible.builtin.lineinfile:

ansible/playbooks/sap-hana-preconfigure.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use_connecttimeout: 10
2525
saptune_solution: HANA
2626
cluster_node: true
27+
firewall_cfg: 'ignore'
2728

2829
tasks:
2930
# Ensure required installation of required packages
@@ -75,6 +76,25 @@
7576
state: present
7677
when: cluster_node | bool
7778

79+
- name: Validate firewall_cfg:
80+
ansible.builtin.assert:
81+
that:
82+
- firewall_cfg is defined
83+
- firewall_cfg in ['ignore', 'enable', 'disable']
84+
fail_msg: "Variable 'firewall_cfg' must be 'ignore', 'enable' or 'disable'. Found '{{ firewall_cfg }}'"
85+
86+
- name: Set firewall service state and enabled status
87+
ansible.builtin.set_fact:
88+
firewall_service_state: "{{ 'started' if firewall_cfg == 'enable' else 'stopped' }}"
89+
firewall_service_enabled: "{{ 'yes' if firewall_cfg == 'enable' else 'no' }}"
90+
91+
- name: Configure the firewall service state
92+
ansible.builtin.systemd:
93+
name: firewalld
94+
state: "{{ firewall_service_state }}"
95+
enabled: "{{ firewall_service_enabled }}"
96+
when: firewall_cfg != 'ignore'
97+
7898
- name: Configure sapconf based systems
7999
ansible.builtin.include_tasks: ./tasks/sapconf.yaml
80100
when: use_sapconf | bool

0 commit comments

Comments
 (0)