host_firewall: FireHOL level1 as its own set firehol_v4 next to Spamhaus, daily updater and firewall.firehol opt-out

This commit is contained in:
2026-10-24 17:31:45 +00:00
parent 312be161b9
commit c55a96c0ea
6 changed files with 238 additions and 5 deletions
+54 -1
View File
@@ -43,7 +43,7 @@
src: "{{ item }}"
dest: "/etc/systemd/system/{{ item }}"
mode: "0644"
loop: [nft-host.service, nft-host-geo.service, nft-host-geo.timer, nft-host-spamhaus.service, nft-host-spamhaus.timer]
loop: [nft-host.service, nft-host-geo.service, nft-host-geo.timer, nft-host-spamhaus.service, nft-host-spamhaus.timer, nft-host-firehol.service, nft-host-firehol.timer]
register: firewall_units
- name: Install the rollback script
@@ -158,6 +158,59 @@
path: /etc/nftables.d/host-spamhaus.nft
state: absent
- name: FireHOL set
when: firewall.firehol
block:
- name: Install the FireHOL set updater
ansible.builtin.copy:
src: nft-host-firehol
dest: /usr/local/sbin/nft-host-firehol
mode: "0755"
# The rule set includes this file, so a missing one would fail the load at boot.
- name: Build the FireHOL set on first run
ansible.builtin.command: /usr/local/sbin/nft-host-firehol
args:
creates: /etc/nftables.d/host-firehol.nft
- name: Read the FireHOL set file
ansible.builtin.stat:
path: /etc/nftables.d/host-firehol.nft
register: firewall_firehol
- name: Require non-empty FireHOL set
ansible.builtin.assert:
that: firewall_firehol.stat.exists and firewall_firehol.stat.size > 0
fail_msg: /etc/nftables.d/host-firehol.nft is missing or empty, refusing to apply the firewall
# Check mode neither installs the updater nor builds the sets.
when: not ansible_check_mode
- name: Enable the FireHOL set timer
ansible.builtin.systemd:
name: nft-host-firehol.timer
enabled: true
state: started
daemon_reload: "{{ firewall_units is changed }}"
# Check mode does not install the unit.
ignore_errors: "{{ ansible_check_mode }}"
- name: Stop the FireHOL set refresh
when: not firewall.firehol
block:
- name: Disable the FireHOL set timer
ansible.builtin.systemd:
name: nft-host-firehol.timer
enabled: false
state: stopped
daemon_reload: "{{ firewall_units is changed }}"
# Check mode does not install the unit.
ignore_errors: "{{ ansible_check_mode }}"
- name: Remove the FireHOL set file
ansible.builtin.file:
path: /etc/nftables.d/host-firehol.nft
state: absent
- name: Render the rule set
ansible.builtin.template:
src: host.nft.j2