summaryrefslogtreecommitdiffstats
path: root/roles/contiv/tasks/netplugin_iptables.yml
blob: 9d376f4e5a86e1619d991f8c084b68517a41fecb (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
---
- name: Netplugin IPtables | Add internal rules
  iptables:
    action: insert
    chain: INPUT
    protocol: "{{ item[0].split('/')[1] }}"
    match: "{{ item[0].split('/')[1] }}"
    destination_port: "{{ item[0].split('/')[0] }}"
    source: "{{ item[1] }}"
    jump: ACCEPT
    comment: contiv
  with_nested:
    - "{{ contiv_netplugin_internal }}"
    - "{{ groups.oo_nodes_to_config|difference(hostvars[inventory_hostname]['ansible_' + contiv_netmaster_interface].ipv4.address)|list }}"
  notify: Save iptables rules

- name: Netplugin IPtables | Add [in] forward rules
  iptables:
    action: insert
    chain: FORWARD
    in_interface: "{{ item }}"
    jump: ACCEPT
    comment: contiv
  with_items: "{{ contiv_netplugin_forward_interfaces }}"
  notify: Save iptables rules

- name: Netplugin IPtables | Add [out] forward rules
  iptables:
    action: insert
    chain: FORWARD
    out_interface: "{{ item }}"
    jump: ACCEPT
    comment: contiv
  with_items: "{{ contiv_netplugin_forward_interfaces }}"
  notify: Save iptables rules

- name: Netplugin IPtables | Add dns rule
  iptables:
    action: insert
    chain: INPUT
    protocol: udp
    match: udp
    destination_port: 53
    in_interface: contivh0
    jump: ACCEPT
    comment: contiv
  notify: Save iptables rules

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