main.yml 977 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. ---
  2. - name: Install iptables-persistent
  3. apt:
  4. pkg: "iptables-persistent"
  5. update_cache: yes
  6. state: present
  7. - name: Get IPv4-DNS-servers
  8. shell: grep '^nameserver' /etc/resolv.conf|sed -e 's/.*nameserver *//' -e 's/#.*//'|grep -v ':' || true
  9. register: v4dns
  10. check_mode: no
  11. changed_when: false
  12. - name: Set IPv4-DNS-servers as fact
  13. set_fact:
  14. v4dnsips: "{{ v4dns.stdout_lines }}"
  15. when: v4dns.stdout != ""
  16. - name: Create rules.v4 file
  17. template: src=rules.v4.j2 dest=/etc/iptables/rules.v4
  18. notify:
  19. - iptables-restore
  20. - name: Get IPv6-DNS-servers
  21. shell: grep '^nameserver' /etc/resolv.conf|sed -e 's/.*nameserver *//' -e 's/#.*//'|grep ':' || true
  22. register: v6dns
  23. check_mode: no
  24. changed_when: false
  25. - name: Set IPv6-DNS-servers as fact
  26. set_fact:
  27. v6dnsips: "{{ v6dns.stdout_lines }}"
  28. when: v6dns.stdout != ""
  29. - name: Create rules.v6 file
  30. template: src=rules.v6.j2 dest=/etc/iptables/rules.v6
  31. notify:
  32. - ip6tables-restore