netplugin_iptables.yml 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. ---
  2. - name: Netplugin IPtables | Add internal rules
  3. iptables:
  4. action: insert
  5. chain: INPUT
  6. protocol: "{{ item[0].split('/')[1] }}"
  7. match: "{{ item[0].split('/')[1] }}"
  8. destination_port: "{{ item[0].split('/')[0] }}"
  9. source: "{{ item[1] }}"
  10. jump: ACCEPT
  11. comment: contiv
  12. with_nested:
  13. - "{{ contiv_netplugin_internal }}"
  14. - "{{ groups.oo_nodes_to_config|difference(hostvars[inventory_hostname]['ansible_' + contiv_netmaster_interface].ipv4.address)|list }}"
  15. notify: Save iptables rules
  16. - name: Netplugin IPtables | Add [in] forward rules
  17. iptables:
  18. action: insert
  19. chain: FORWARD
  20. in_interface: "{{ item }}"
  21. jump: ACCEPT
  22. comment: contiv
  23. with_items: "{{ contiv_netplugin_forward_interfaces }}"
  24. notify: Save iptables rules
  25. - name: Netplugin IPtables | Add [out] forward rules
  26. iptables:
  27. action: insert
  28. chain: FORWARD
  29. out_interface: "{{ item }}"
  30. jump: ACCEPT
  31. comment: contiv
  32. with_items: "{{ contiv_netplugin_forward_interfaces }}"
  33. notify: Save iptables rules
  34. - name: Netplugin IPtables | Add dns rule
  35. iptables:
  36. action: insert
  37. chain: INPUT
  38. protocol: udp
  39. match: udp
  40. destination_port: 53
  41. in_interface: contivh0
  42. jump: ACCEPT
  43. comment: contiv
  44. notify: Save iptables rules
  45. - name: Netplugin IPtables | Enable iptables at boot
  46. service:
  47. name: iptables
  48. enabled: yes