Skip to content

Commit c9080f1

Browse files
committed
feat(firewall): Firewall rules are loaded at boot
The filter table rules are loaded by systemd at boot time. It will load them in much the same way as when Ansible sets the rules - with noflush=true - so that docker isn't adversely affected.
1 parent ba66b2a commit c9080f1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

playbooks/firewall/iptables_docker_swarm.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,18 @@
1111
name: iptables-persistent
1212
state: present
1313

14+
- name: v4 iptables rules will be loaded at boot with --noflush
15+
ansible.builtin.lineinfile:
16+
dest: /etc/default/netfilter-persistent
17+
regexp: '^IPTABLES_RESTORE_NOFLUSH=yes'
18+
line: 'IPTABLES_RESTORE_NOFLUSH=yes'
19+
state: present
20+
1421
- name: v4 iptables rules exist
1522
become: true
1623
ansible.builtin.template:
1724
src: etc-iptables-filter.v4
18-
dest: /etc/iptables/filter.v4
25+
dest: /etc/iptables/rules.v4
1926
owner: root
2027
group: adm
2128
mode: '0644'
@@ -27,6 +34,6 @@
2734
table: filter
2835
state: restored
2936
noflush: true
30-
path: /etc/iptables/filter.v4
37+
path: /etc/iptables/rules.v4
3138
async: '{{ ansible_timeout }}'
3239
poll: 0

0 commit comments

Comments
 (0)