Nessuna descrizione
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ufw.yml 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. ---
  2. # Installs and configures ufw, which in turn uses iptables for firewall management
  3. # ufw includes sensible icmp defaults
  4. - name: Install ufw
  5. apt: pkg=ufw state=present
  6. - name: Set firewall rules
  7. command: ufw allow {{ item }}
  8. register: ufw_result
  9. changed_when: "ufw_result.stdout.startswith('Rule')"
  10. with_items:
  11. - smtp/tcp
  12. - domain/tcp
  13. - http/tcp
  14. - https/tcp
  15. - ssh/tcp
  16. - ssmtp/tcp
  17. - imaps/tcp
  18. - 5222/tcp # xmpp c2s
  19. - 5269/tcp # xmpp s2s
  20. - 6697/tcp # znc
  21. - openvpn/udp
  22. - 60000:61000/udp # mosh udp packets
  23. - name: Check status of ufw
  24. command: ufw status
  25. register: ufw_status
  26. changed_when: False # never report as "changed"
  27. - name: Check config of ufw
  28. command: cat /etc/ufw/ufw.conf
  29. register: ufw_config
  30. changed_when: False # never report as "changed"
  31. - name: Disable logging (workaround for known bug in Debian 7)
  32. command: ufw logging off
  33. when: "ansible_lsb['codename'] == 'wheezy' and 'LOGLEVEL=off' not in ufw_config.stdout"
  34. - name: Enable ufw
  35. command: ufw --force enable
  36. when: "ufw_status.stdout.startswith('Status: inactive') or 'ENABLED=yes' not in ufw_config.stdout"