Skip to content

Commit 7894c9d

Browse files
authored
Refactor firewall management (#428)
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 56d8cc9 commit 7894c9d

2 files changed

Lines changed: 38 additions & 6 deletions

File tree

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

Lines changed: 6 additions & 6 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: true
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:

ansible/playbooks/sap-hana-preconfigure.yaml

Lines changed: 32 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,37 @@
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: Get service facts
87+
ansible.builtin.service_facts:
88+
89+
- name: Debug firewall status on specific OS version
90+
ansible.builtin.debug:
91+
msg:
92+
- "[OSADO][softfail] bsc#1254356"
93+
- "The firewalld service is not stopped and disabled on this system."
94+
when:
95+
- ansible_distribution_major_version == '16'
96+
- firewall_cfg != 'ignore' # avoid to hide the bug by forcing the firewall state
97+
98+
- name: Set firewall service state and enabled status
99+
ansible.builtin.set_fact:
100+
firewall_service_state: "{{ 'started' if firewall_cfg == 'enable' else 'stopped' }}"
101+
firewall_service_enabled: "{{ 'yes' if firewall_cfg == 'enable' else 'no' }}"
102+
103+
- name: Configure the firewall service state
104+
ansible.builtin.systemd:
105+
name: firewalld
106+
state: "{{ firewall_service_state }}"
107+
enabled: "{{ firewall_service_enabled }}"
108+
when: firewall_cfg != 'ignore'
109+
78110
- name: Configure sapconf based systems
79111
ansible.builtin.include_tasks: ./tasks/sapconf.yaml
80112
when: use_sapconf | bool

0 commit comments

Comments
 (0)