Skip to content

Commit ac58058

Browse files
committed
WIP: Rework firewall management.
1 parent 215eef7 commit ac58058

File tree

9 files changed

+27
-68
lines changed

9 files changed

+27
-68
lines changed

roles/agent/README.md

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,10 @@ See [this link](https://docs.checkmk.com/latest/en/agent_linux.html#registration
131131

132132
checkmk_agent_configure_firewall: 'true'
133133

134-
Automatically configure the firewall (*currently only on RedHat and Debian derivatives*) to allow access to the Checkmk agent.
135-
136-
checkmk_agent_configure_firewall_zone: 'public'
137-
138-
When checkmk_agent_configure_firewall is set to `true` then configure the firewall zone on RedHat derivatives. Defaults to 'public'.
139-
140-
checkmk_agent_server_ips: []
141-
142-
A list of IP addresses, that will be whitelisted in the firewall for agent access on `checkmk_agent_port`.
143-
The `checkmk_agent_server` will automatically be added, but only if it is an IP address.
144-
This parameter also does **not** take care of any agent-side whitelisting!
134+
Automatically configure the firewall to allow access to the Checkmk agent.
135+
**This is a very rudamentary configration!**
136+
It only opens port 6556. Everything else uses defaults of the respective platform.
137+
If you need more elaborate configuration, use your own firewall management!
145138

146139
checkmk_agent_force_install: 'false'
147140

roles/agent/defaults/main.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ checkmk_agent_force_foreign_changes: 'false'
2424
checkmk_agent_update: 'false'
2525
checkmk_agent_tls: 'false'
2626
checkmk_agent_configure_firewall: 'true'
27-
checkmk_agent_configure_firewall_zone: 'public'
28-
checkmk_agent_server_ips: []
2927
checkmk_agent_force_install: 'false'
3028
checkmk_agent_prep_legacy: 'false'
3129
checkmk_agent_delegate_api_calls: 'localhost'

roles/agent/meta/argument_specs.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,6 @@ argument_specs:
145145
description:
146146
- Refer to the README for details.
147147

148-
checkmk_agent_server_ips:
149-
type: "list"
150-
elements: "str"
151-
description:
152-
- Refer to the README for details.
153-
154148
checkmk_agent_force_install:
155149
type: "bool"
156150
default: false

roles/agent/molecule/2.2.0/group_vars/all.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ checkmk_agent_discover_max_parallel_tasks: 2
3131
checkmk_agent_update: 'false'
3232
checkmk_agent_tls: 'true'
3333
checkmk_agent_configure_firewall: 'true'
34-
checkmk_agent_configure_firewall_zone: 'public'
35-
checkmk_agent_server_ips:
36-
- 10.10.10.10
37-
- 172.16.16.16
38-
- 192.168.1.1
3934
checkmk_agent_force_install: 'false'
4035
checkmk_agent_prep_legacy: 'false'
4136
checkmk_agent_delegate_api_calls: "{{ inventory_hostname }}"

roles/agent/molecule/2.3.0/group_vars/all.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ checkmk_agent_discover_max_parallel_tasks: 2
3131
checkmk_agent_update: 'false'
3232
checkmk_agent_tls: 'true'
3333
checkmk_agent_configure_firewall: 'true'
34-
checkmk_agent_configure_firewall_zone: 'public'
35-
checkmk_agent_server_ips:
36-
- 10.10.10.10
37-
- 172.16.16.16
38-
- 192.168.1.1
3934
checkmk_agent_force_install: 'false'
4035
checkmk_agent_prep_legacy: 'false'
4136
checkmk_agent_delegate_api_calls: "{{ inventory_hostname }}"

roles/agent/molecule/2.4.0/group_vars/all.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ checkmk_agent_discover_max_parallel_tasks: 2
3131
checkmk_agent_update: 'false'
3232
checkmk_agent_tls: 'true'
3333
checkmk_agent_configure_firewall: 'true'
34-
checkmk_agent_configure_firewall_zone: 'public'
35-
checkmk_agent_server_ips:
36-
- 10.10.10.10
37-
- 172.16.16.16
38-
- 192.168.1.1
3934
checkmk_agent_force_install: 'false'
4035
checkmk_agent_prep_legacy: 'false'
4136
checkmk_agent_delegate_api_calls: "{{ inventory_hostname }}"

roles/agent/tasks/Debian.yml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,11 @@
4444
tags:
4545
- install-package
4646

47-
- name: "{{ ansible_os_family }} Derivatives: Configure Firewall for Agent."
47+
- name: "{{ ansible_os_family }} Derivatives: Allow Checkmk services access to the agent."
4848
when: checkmk_agent_configure_firewall | bool and "ufw.service" in ansible_facts.services
49-
block:
50-
- name: "{{ ansible_os_family }} Derivatives: Add Checkmk Server to Firewall Whitelist if it is an IP address."
51-
when: checkmk_agent_server | ansible.utils.ipaddr()
52-
ansible.builtin.set_fact:
53-
checkmk_agent_server_ips: "{{ checkmk_agent_server_ips + [checkmk_agent_server] }}"
54-
55-
- name: "{{ ansible_os_family }} Derivatives: Allow Checkmk services access to the agent."
56-
when: checkmk_agent_server_ips is defined
57-
community.general.ufw:
58-
rule: allow
59-
proto: tcp
60-
src: "{{ item }}"
61-
port: '6556'
62-
comment: Allow Checkmk
63-
loop: "{{ checkmk_agent_server_ips }}"
64-
become: true
49+
community.general.ufw:
50+
rule: allow
51+
proto: tcp
52+
port: '6556'
53+
comment: "Allow Checkmk Agent access from anywhere."
54+
become: true

roles/agent/tasks/RedHat.yml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,11 @@
4444
tags:
4545
- install-package
4646

47-
- name: "{{ ansible_os_family }} Derivatives: Configure Firewall for Agent."
47+
- name: "{{ ansible_os_family }} Derivatives: Allow Checkmk services access to the agent."
4848
when: checkmk_agent_configure_firewall | bool and "firewalld.service" in ansible_facts.services
49-
block:
50-
- name: "{{ ansible_os_family }} Derivatives: Add Checkmk Server to Firewall Whitelist if it is an IP address."
51-
when: checkmk_agent_server | ansible.utils.ipaddr()
52-
ansible.builtin.set_fact:
53-
checkmk_agent_server_ips: "{{ checkmk_agent_server_ips + [checkmk_agent_server] }}"
54-
55-
- name: "{{ ansible_os_family }} Derivatives: Allow Checkmk services access to the agent."
56-
when: checkmk_agent_server_ips is defined
57-
ansible.posix.firewalld:
58-
permanent: 'yes'
59-
immediate: 'yes'
60-
state: enabled
61-
rich_rule: 'rule family="ipv4" source address={{ item }} port port="{{ checkmk_agent_port }}" protocol="tcp" accept'
62-
zone: "{{ checkmk_agent_configure_firewall_zone | default('public') }}"
63-
loop: "{{ checkmk_agent_server_ips }}"
64-
become: true
49+
ansible.posix.firewalld:
50+
permanent: true
51+
immediate: true
52+
port: 6556/tcp
53+
state: "enabled"
54+
become: true

roles/agent/tasks/Suse.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,12 @@
4646
when: checkmk_agent_edition | lower == "cre"
4747
tags:
4848
- install-package
49+
50+
- name: "{{ ansible_os_family }} Derivatives: Allow Checkmk services access to the agent."
51+
when: checkmk_agent_configure_firewall | bool and "firewalld.service" in ansible_facts.services
52+
ansible.posix.firewalld:
53+
permanent: true
54+
immediate: true
55+
port: 6556/tcp
56+
state: "enabled"
57+
become: true

0 commit comments

Comments
 (0)