summaryrefslogtreecommitdiffstats
path: root/roles/contiv/tasks/netplugin_iptables.yml
blob: 3ea34645db8cb858a24a2e705c50a81be227e133 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
- name: Netplugin IPtables | Get iptables rules
  command: iptables -L --wait
  register: iptablesrules
  check_mode: no

- name: Netplugin IPtables | Enable iptables at boot
  service:
    name: iptables
    enabled: yes
    state: started

- name: Netplugin IPtables | Open Netmaster with iptables
  command: /sbin/iptables -I INPUT 1 -p tcp --dport {{ item }} -j ACCEPT -m comment --comment "contiv"
  with_items:
  - "{{ netmaster_port }}"
  - "{{ contiv_rpc_port1 }}"
  - "{{ contiv_rpc_port2 }}"
  - "{{ contiv_rpc_port3 }}"
  - "{{ contiv_etcd_port }}"
  - "{{ kube_master_api_port }}"
  when: iptablesrules.stdout.find("contiv") == -1
  notify: Save iptables rules

- name: Netplugin IPtables | Open vxlan port with iptables
  command: /sbin/iptables -I INPUT 1 -p udp --dport 8472 -j ACCEPT -m comment --comment "netplugin vxlan 8472"
  when: iptablesrules.stdout.find("netplugin vxlan 8472") == -1
  notify: Save iptables rules

- name: Netplugin IPtables | Open vxlan port with iptables
  command: /sbin/iptables -I INPUT 1 -p udp --dport 4789 -j ACCEPT -m comment --comment "netplugin vxlan 4789"
  when: iptablesrules.stdout.find("netplugin vxlan 4789") == -1
  notify: Save iptables rules

- name: Netplugin IPtables | Allow from contivh0
  command: /sbin/iptables -I FORWARD 1 -i contivh0 -j ACCEPT -m comment --comment "contivh0 FORWARD input"
  when: iptablesrules.stdout.find("contivh0 FORWARD input") == -1
  notify: Save iptables rules

- name: Netplugin IPtables | Allow to contivh0
  command: /sbin/iptables -I FORWARD 1 -o contivh0 -j ACCEPT -m comment --comment "contivh0 FORWARD output"
  when: iptablesrules.stdout.find("contivh0 FORWARD output") == -1
  notify: Save iptables rules

- name: Netplugin IPtables | Allow from contivh1
  command: /sbin/iptables -I FORWARD 1 -i contivh1 -j ACCEPT -m comment --comment "contivh1 FORWARD input"
  when: iptablesrules.stdout.find("contivh1 FORWARD input") == -1
  notify: Save iptables rules

- name: Netplugin IPtables | Allow to contivh1
  command: /sbin/iptables -I FORWARD 1 -o contivh1 -j ACCEPT -m comment --comment "contivh1 FORWARD output"
  when: iptablesrules.stdout.find("contivh1 FORWARD output") == -1
  notify: Save iptables rules

- name: Netplugin IPtables | Allow dns
  command: /sbin/iptables -I INPUT 1 -p udp --dport 53 -j ACCEPT -m comment --comment "contiv dns"
  when: iptablesrules.stdout.find("contiv dns") == -1
  notify: Save iptables rules