diff --git a/roles/fail2ban/tasks/main.yml b/roles/fail2ban/tasks/main.yml index bae462a..3efa3ba 100755 --- a/roles/fail2ban/tasks/main.yml +++ b/roles/fail2ban/tasks/main.yml @@ -29,3 +29,12 @@ name: fail2ban state: started enabled: yes + +- name: Check the fail2ban service status + register: fail2ban_service + ansible.builtin.systemd_service: + name: fail2ban + +- name: Fail if fail2ban failed + ansible.builtin.assert: + that: fail2ban_service.StatusErrno != "0" diff --git a/roles/system/handlers/main.yml b/roles/system/handlers/main.yml new file mode 100644 index 0000000..c990df8 --- /dev/null +++ b/roles/system/handlers/main.yml @@ -0,0 +1,5 @@ +--- +- name: Restart iptables + ansible.builtin.service: + name: iptables + state: restarted diff --git a/roles/system/tasks/firewall.yml b/roles/system/tasks/firewall.yml index f9bbf19..6d164f9 100644 --- a/roles/system/tasks/firewall.yml +++ b/roles/system/tasks/firewall.yml @@ -15,6 +15,7 @@ cmd: "which iptables-restore" - name: Template the iptables systemd service + notify: Restart iptables ansible.builtin.template: src: systemd/iptables.service.j2 dest: /etc/systemd/system/iptables.service