Skip to content

Commit

Permalink
Docker: Add systemd file to start iptables
Browse files Browse the repository at this point in the history
  • Loading branch information
quartje committed Sep 1, 2023
1 parent fd6f97c commit dd93635
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
11 changes: 11 additions & 0 deletions roles/docker/files/iptablesdocker.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Restore iptables firewall rules
Before=network-pre.target

[Service]
Type=oneshot
ExecStart=/usr/local/sbin/ip4tables.sh

[Install]
WantedBy=multi-user.target

19 changes: 18 additions & 1 deletion roles/docker/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,24 @@
- name: Place the iptables file
ansible.builtin.template:
src: ip4tables.sh.j2
dest: /usr/local/sbin/ipt4tables.sh
dest: /usr/local/sbin/ip4tables.sh
mode: "0750"
owner: root

- name: Disable the default iptables service
ansible.builtin.systemd:
service: iptables
enabled: false

- name: Place the new systemd service file
ansible.builtin.copy:
src: iptablesdocker.service
dest: /etc/systemd/system/
owner: root
mode: "0755"

- name: Enable and start the new firewall service
ansible.builtin.systemd:
service: iptablesdocker.service
enabled: true
state: started

0 comments on commit dd93635

Please sign in to comment.