crio_firewall.yml 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ---
  2. - when: r_crio_firewall_enabled | bool and not r_crio_use_firewalld | bool
  3. block:
  4. - name: Make sure iptables-services is installed
  5. package:
  6. name: iptables-services
  7. state: present
  8. - name: Add iptables allow rules
  9. os_firewall_manage_iptables:
  10. name: "{{ item.service }}"
  11. action: add
  12. protocol: "{{ item.port.split('/')[1] }}"
  13. port: "{{ item.port.split('/')[0] }}"
  14. when: item.cond | default(True)
  15. with_items: "{{ r_crio_os_firewall_allow }}"
  16. - name: Remove iptables rules
  17. os_firewall_manage_iptables:
  18. name: "{{ item.service }}"
  19. action: remove
  20. protocol: "{{ item.port.split('/')[1] }}"
  21. port: "{{ item.port.split('/')[0] }}"
  22. when: item.cond | default(True)
  23. with_items: "{{ r_crio_os_firewall_deny }}"
  24. - when: r_crio_firewall_enabled | bool and r_crio_use_firewalld | bool
  25. block:
  26. - name: Add firewalld allow rules
  27. firewalld:
  28. port: "{{ item.port }}"
  29. permanent: true
  30. immediate: true
  31. state: enabled
  32. when: item.cond | default(True)
  33. with_items: "{{ r_crio_os_firewall_allow }}"
  34. - name: Remove firewalld allow rules
  35. firewalld:
  36. port: "{{ item.port }}"
  37. permanent: true
  38. immediate: true
  39. state: disabled
  40. when: item.cond | default(True)
  41. with_items: "{{ r_crio_os_firewall_deny }}"