netmaster_iptables.yml 624 B

123456789101112131415161718192021
  1. ---
  2. - name: Netmaster IPtables | Get iptables rules
  3. command: iptables -L --wait
  4. register: iptablesrules
  5. always_run: yes
  6. - name: Netmaster IPtables | Enable iptables at boot
  7. service:
  8. name: iptables
  9. enabled: yes
  10. state: started
  11. - name: Netmaster IPtables | Open Netmaster with iptables
  12. command: /sbin/iptables -I INPUT 1 -p tcp --dport {{ item }} -j ACCEPT -m comment --comment "contiv"
  13. with_items:
  14. - "{{ netmaster_port }}"
  15. - "{{ contiv_rpc_port1 }}"
  16. - "{{ contiv_rpc_port2 }}"
  17. - "{{ contiv_rpc_port3 }}"
  18. when: iptablesrules.stdout.find("contiv") == -1
  19. notify: Save iptables rules