firewalld.yml 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. ---
  2. - name: Install firewalld packages
  3. package:
  4. name: firewalld
  5. state: present
  6. - name: Ensure iptables services are not enabled
  7. systemd:
  8. name: "{{ item }}"
  9. state: stopped
  10. enabled: no
  11. masked: yes
  12. with_items:
  13. - iptables
  14. - ip6tables
  15. register: task_result
  16. failed_when: task_result|failed and 'could not' not in task_result.msg|lower
  17. - name: Wait 10 seconds after disabling iptables
  18. pause:
  19. seconds: 10
  20. when: task_result | changed
  21. - name: Start and enable firewalld service
  22. systemd:
  23. name: firewalld
  24. state: started
  25. enabled: yes
  26. masked: no
  27. daemon_reload: yes
  28. register: result
  29. - name: need to pause here, otherwise the firewalld service starting can sometimes cause ssh to fail
  30. pause: seconds=10
  31. when: result | changed
  32. - name: Restart polkitd
  33. systemd:
  34. name: polkit
  35. state: restarted
  36. when: result | changed
  37. # Fix suspected race between firewalld and polkit BZ1436964
  38. - name: Wait for polkit action to have been created
  39. command: pkaction --action-id=org.fedoraproject.FirewallD1.config.info
  40. ignore_errors: true
  41. register: pkaction
  42. changed_when: false
  43. until: pkaction.rc == 0
  44. retries: 6
  45. delay: 10