Rewrite nftables.service and improve start in playbook

This commit is contained in:
Dryusdan 2023-12-21 19:13:54 +01:00
parent a35a1f7fed
commit c5754935f6
3 changed files with 10 additions and 8 deletions

5
handlers/main.yml Normal file
View file

@ -0,0 +1,5 @@
- name: Restart-nftables
ansible.builtin.systemd_service:
daemon_reload: true
name: nftables
state: restarted

View file

@ -19,12 +19,7 @@
owner: root
group: root
mode: 0644
- name: Start nftables
ansible.builtin.systemd_service:
daemon_reload: true
name: crowdsec
state: started
notify: Restart-nftables
- name: Create nftables default files
ansible.builtin.template:
@ -35,12 +30,14 @@
mode: 0640
loop: "{{ nftables_default }}"
when: nftables_default is defined
notify: Restart-nftables
- name: Create nftables custom files
ansible.builtin.template:
src: nftables.j2
dest: "/etc/nftables.d/{{ item.name }}.conf"
dest: "/etc/nftables.d/{{ item.name }}.nft"
owner: root
group: root
mode: 0640
loop: "{{ nftables }}"
notify: Restart-nftables

View file

@ -13,8 +13,8 @@ RemainAfterExit=yes
StandardInput=null
ProtectSystem=full
ProtectHome=true
ExecStartPre=/usr/sbin/nft flush ruleset
ExecStart=/usr/sbin/nft -f /etc/nftables.conf
ExecReload=/usr/sbin/nft -f /etc/nftables.conf
ExecStop=/usr/sbin/nft flush ruleset
[Install]