blob: c37bca1c1b4c6038b32f3148852efe7fa9a5808d [file] [log] [blame]
Hyunsun Moone4848342020-02-16 04:28:55 -08001# Copyright 2020-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15---
16- name: Create netplan config file for SGI network gateway
17 template:
18 src: etc/netplan/sgi-s1u-gateway.yaml.j2
19 dest: "{{ netplan_config_file }}"
20 notify:
21 - netplan generate
22 - netplan apply
23 tags: router
24
25- name: Install iptables-persistent
26 apt:
27 name: iptables-persistent
28 state: present
29 update_cache: yes
30 tags: router
31
32- name: Ensure ip_forward enabled
33 sysctl:
34 name: net.ipv4.ip_forward
35 value: '1'
36 sysctl_set: yes
37 state: present
38 tags: router
39
40- name: Set default forwarding policy to ACCEPT
41 iptables:
42 chain: FORWARD
43 policy: ACCEPT
44 tags: router
45
46- name: Add SNAT
47 iptables:
48 table: nat
49 chain: POSTROUTING
50 out_interface: "{{ ansible_default_ipv4.interface }}"
51 jump: MASQUERADE
52 tags: router
53
54- name: Save iptables v4 rules
55 shell: iptables-save > /etc/iptables/rules.v4
56 tags: router