Bez popisu
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

12345678910111213141516171819202122232425262728293031323334353637383940
  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. - 6697/tcp # znc
  19. - openvpn/udp
  20. - 60000:61000/udp # mosh udp packets
  21. - name: Check status of ufw
  22. command: ufw status
  23. register: ufw_status
  24. changed_when: False # never report as "changed"
  25. - name: Check config of ufw
  26. command: cat /etc/ufw/ufw.conf
  27. register: ufw_config
  28. changed_when: False # never report as "changed"
  29. - name: Disable logging (workaround for known bug in Debian 7)
  30. command: ufw logging off
  31. when: "ansible_lsb['codename'] == 'wheezy' and 'LOGLEVEL=off' not in ufw_config.stdout"
  32. - name: Enable ufw
  33. command: ufw --force enable
  34. when: "ufw_status.stdout.startswith('Status: inactive') or 'ENABLED=yes' not in ufw_config.stdout"