|
@@ -119,20 +119,22 @@
|
119
|
119
|
command: openssl dhparam -out {{ openvpn_dhparam }} {{ openvpn_key_size }}
|
120
|
120
|
creates={{ openvpn_dhparam }}
|
121
|
121
|
|
122
|
|
-- name: Copy rc.local with firewall and dnsmasq rules into place
|
123
|
|
- template: src=etc_rc.local dest=/etc/rc.local
|
|
122
|
+- name: Add empty rc.local if it doesn't exist
|
|
123
|
+ copy: src=rc.local dest=/etc/rc.local mode=700 owner=root group=root force=no
|
|
124
|
+
|
|
125
|
+- name: custom rc.local file with iptables rules
|
|
126
|
+ template: src=rc.local_ansible_openvpn dest=/etc/rc.local_ansible_openvpn mode=700 owner=root group=root
|
|
127
|
+
|
|
128
|
+- name: Ensure custom rc.local file is included in rc.local
|
|
129
|
+ lineinfile: dest=/etc/rc.local line='bash /etc/rc.local_ansible_openvpn' insertbefore='exit 0'
|
|
130
|
+
|
|
131
|
+- name: Run custom rc file
|
|
132
|
+ command: bash /etc/rc.local_ansible_openvpn
|
|
133
|
+ changed_when: False
|
124
|
134
|
|
125
|
135
|
- name: Enable IPv4 traffic forwarding
|
126
|
136
|
sysctl: name=net.ipv4.ip_forward value=1
|
127
|
137
|
|
128
|
|
-- name: Allow OpenVPN through the firewall
|
129
|
|
- command: "{{ item }}"
|
130
|
|
- with_items:
|
131
|
|
- - iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
|
132
|
|
- - iptables -A FORWARD -s 10.8.0.0/24 -j ACCEPT
|
133
|
|
- - iptables -A FORWARD -j REJECT
|
134
|
|
- - iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o {{ ansible_default_ipv4.interface }} -j MASQUERADE
|
135
|
|
-
|
136
|
138
|
- name: Allow OpenVPN through ufw
|
137
|
139
|
ufw: rule=allow port={{ openvpn_port }} proto={{ openvpn_protocol }}
|
138
|
140
|
tags: ufw
|