iptables.yml 974 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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: task_result|failed and 'could not' not in task_result.msg|lower
  10. - name: Wait 10 seconds after disabling firewalld
  11. pause:
  12. seconds: 10
  13. when: task_result | changed
  14. - name: Install iptables packages
  15. package:
  16. name: "{{ item }}"
  17. state: present
  18. with_items:
  19. - iptables
  20. - iptables-services
  21. when: not r_os_firewall_is_atomic | bool
  22. register: result
  23. until: result | success
  24. - name: Start and enable iptables service
  25. systemd:
  26. name: iptables
  27. state: started
  28. enabled: yes
  29. masked: no
  30. daemon_reload: yes
  31. register: result
  32. delegate_to: "{{item}}"
  33. run_once: true
  34. with_items: "{{ ansible_play_batch }}"
  35. - name: need to pause here, otherwise the iptables service starting can sometimes cause ssh to fail
  36. pause:
  37. seconds: 10
  38. when: result | changed