iptables.yml 992 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ---
  2. - name: Ensure firewalld service is not enabled
  3. systemd:
  4. name: firewalld
  5. state: stopped
  6. enabled: no
  7. masked: yes
  8. register: task_result
  9. failed_when:
  10. - task_result is failed
  11. - ('could not' not in task_result.msg|lower)
  12. - name: Wait 10 seconds after disabling firewalld
  13. pause:
  14. seconds: 10
  15. when: task_result is changed
  16. - name: Install iptables packages
  17. package:
  18. name: "{{ item }}"
  19. state: present
  20. with_items:
  21. - iptables
  22. - iptables-services
  23. when: not r_os_firewall_is_atomic | bool
  24. register: result
  25. until: result is succeeded
  26. - name: Start and enable iptables service
  27. systemd:
  28. name: iptables
  29. state: started
  30. enabled: yes
  31. masked: no
  32. daemon_reload: yes
  33. register: result
  34. delegate_to: "{{item}}"
  35. run_once: true
  36. with_items: "{{ ansible_play_batch }}"
  37. - name: need to pause here, otherwise the iptables service starting can sometimes cause ssh to fail
  38. pause:
  39. seconds: 10
  40. when: result is changed