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.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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
  13. - http/tcp
  14. - https/tcp
  15. - ssh/tcp
  16. - ssmtp/tcp
  17. - pop3s/tcp
  18. - imaps/tcp
  19. - 5222/tcp # xmpp c2s
  20. - 5269/tcp # xmpp s2s
  21. - 6697/tcp # znc
  22. - "{{ openvpn_port }}/{{ openvpn_protocol }}"
  23. - 60000:61000/udp # mosh udp packets
  24. - name: Check status of ufw
  25. command: ufw status
  26. register: ufw_status
  27. changed_when: False # never report as "changed"
  28. - name: Check config of ufw
  29. command: cat /etc/ufw/ufw.conf
  30. register: ufw_config
  31. changed_when: False # never report as "changed"
  32. - name: Disable logging (workaround for known bug in Debian 7)
  33. command: ufw logging off
  34. when: "ansible_lsb['codename'] == 'wheezy' and 'LOGLEVEL=off' not in ufw_config.stdout"
  35. - name: Enable ufw
  36. command: ufw --force enable
  37. when: "ufw_status.stdout.startswith('Status: inactive') or 'ENABLED=yes' not in ufw_config.stdout"