diff --git a/iptables/tasks/main.yml b/iptables/tasks/main.yml index 3c6163c1..c3b85587 100644 --- a/iptables/tasks/main.yml +++ b/iptables/tasks/main.yml @@ -34,7 +34,7 @@ - rules.v4 - rules.v6 when: is_trusty - notify: Start the iptables service + register: install_iptables_rules tags: [ 'iptables', 'iptables_rules' ] - name: Install the IPv4 and IPv6 iptables rules. The IPv6 ones are not used. On debian 7 @@ -43,7 +43,7 @@ - rules.v4 - rules.v6 when: is_debian7 - notify: Start the iptables service + register: install_iptables_rules tags: [ 'iptables', 'iptables_rules' ] - name: Install the IPv4 and IPv6 iptables rules. The IPv6 ones are not used. On debian 8 @@ -52,6 +52,17 @@ - rules.v4 - rules.v6 when: is_debian8 - notify: Start the netfilter service + register: install_netfilter_rules tags: [ 'iptables', 'iptables_rules' ] +- name: Start the iptables service immediately after the new rules have been installed. This can have an impact on other tasks + service: name=iptables-persistent state=restarted enabled=yes + notify: Restart fail2ban + when: ( install_iptables_rules | changed ) + tags: [ 'iptables', 'iptables_rules' ] + +- name: Start the netfilter service immediately after the new rules have been installed. This can have an impact on other tasks + service: name=netfilter-persistent state=restarted enabled=yes + notify: Restart fail2ban + when: ( install_netfilter_rules | changed ) + tags: [ 'iptables', 'iptables_rules' ]