2022-09-11 20:55:30 +02:00
|
|
|
- name: Install nftables
|
|
|
|
apt:
|
|
|
|
name: nftables
|
|
|
|
|
|
|
|
- name: Configure nftables
|
|
|
|
template:
|
2022-09-24 00:15:46 +02:00
|
|
|
src: ./filesystem/{{ ansible_host }}/etc/nftables.conf.j2
|
2022-09-11 20:55:30 +02:00
|
|
|
dest: /etc/nftables.conf
|
|
|
|
mode: 0755
|
|
|
|
register: nftables_conf
|
|
|
|
|
2022-11-03 01:06:40 +01:00
|
|
|
- name: Enable nftables
|
2022-09-11 20:55:30 +02:00
|
|
|
systemd:
|
|
|
|
name: nftables
|
|
|
|
enabled: yes
|
|
|
|
|
2022-11-03 01:06:40 +01:00
|
|
|
- name: Start nftables
|
|
|
|
systemd:
|
|
|
|
name: nftables
|
|
|
|
state: started
|
|
|
|
register: nftables_start
|
|
|
|
|
2022-09-11 20:55:30 +02:00
|
|
|
- name: Restart nftables
|
|
|
|
systemd:
|
|
|
|
name: nftables
|
|
|
|
state: restarted
|
2022-09-25 13:15:17 +02:00
|
|
|
register: nftables_restart
|
2022-09-11 20:55:30 +02:00
|
|
|
when:
|
2022-11-03 01:06:40 +01:00
|
|
|
nftables_conf is changed and
|
|
|
|
nftables_start is not changed
|
2022-09-25 13:15:17 +02:00
|
|
|
|
2022-11-15 23:01:51 +01:00
|
|
|
- block:
|
|
|
|
- name: List all post-up nft scripts for interfaces
|
|
|
|
find:
|
|
|
|
paths: /usr/local/sbin
|
|
|
|
patterns: "post-up-*.nft"
|
|
|
|
register: nft_post_up_scripts
|
|
|
|
|
|
|
|
- name: Reload nft scripts for interfaces
|
|
|
|
command: "{{ item.path }}"
|
|
|
|
with_items:
|
|
|
|
- "{{ nft_post_up_scripts.files }}"
|
|
|
|
|
2022-09-25 13:15:17 +02:00
|
|
|
when:
|
|
|
|
nftables_restart is changed
|