|
@@ -3,8 +3,11 @@
|
3
|
3
|
# ref: https://library.linode.com/networking/openvpn/debian-6-squeeze
|
4
|
4
|
|
5
|
5
|
- name: Install OpenVPN and dependencies
|
6
|
|
- apt: pkg={{ item }} state=present
|
7
|
|
- with_items:
|
|
6
|
+ apt:
|
|
7
|
+ name: "{{ packages }}"
|
|
8
|
+ state: present
|
|
9
|
+ vars:
|
|
10
|
+ packages:
|
8
|
11
|
- dnsmasq
|
9
|
12
|
- openvpn
|
10
|
13
|
- udev
|
|
@@ -41,13 +44,13 @@
|
41
|
44
|
command: openssl req -nodes -batch -new -x509 -key {{ openvpn_ca }}.key -out {{ openvpn_ca }}.crt -days {{ openvpn_days_valid }} -subj "{{ openssl_request_subject }}/CN=sovereign-ca-certificate"
|
42
|
45
|
creates={{ openvpn_ca }}.crt
|
43
|
46
|
|
44
|
|
-- name: Generate the OpenSSL configuration that will be used for the Server certificate's req and ca commands
|
45
|
47
|
# Properly sets the attributes that are described here:
|
46
|
48
|
# openvpn.net/index.php/open-source/documentation/howto.html#mitm
|
47
|
49
|
#
|
48
|
50
|
# This is required in order for the 'ns-cert-type server' option to
|
49
|
51
|
# work, which is enabled by default in most standard client.conf
|
50
|
52
|
# files.
|
|
53
|
+- name: Generate the OpenSSL configuration that will be used for the Server certificate's req and ca commands
|
51
|
54
|
template: src=openssl-server-certificate.cnf.j2
|
52
|
55
|
dest={{ openvpn_path }}/openssl-server-certificate.cnf
|
53
|
56
|
|
|
@@ -146,12 +149,12 @@
|
146
|
149
|
- name: Enable OpenVPN server systemd service unit
|
147
|
150
|
service: name=openvpn@server enabled=yes
|
148
|
151
|
|
149
|
|
-# OpenVPN must restart first so the 10.8.0.0 interface is available
|
|
152
|
+# OpenVPN must restart first so the VPN interface is available
|
150
|
153
|
# to dnsmasq
|
151
|
154
|
- meta: flush_handlers
|
152
|
155
|
|
153
|
156
|
- name: Copy dnsmasq configuration file into place
|
154
|
|
- copy: src=etc_dnsmasq.conf dest=/etc/dnsmasq.conf
|
|
157
|
+ template: src=etc_dnsmasq.conf.j2 dest=/etc/dnsmasq.conf
|
155
|
158
|
notify: restart dnsmasq
|
156
|
159
|
|
157
|
160
|
- name: Copy the ca.crt and ta.key files that clients will need in order to connect to the OpenVPN server
|
|
@@ -164,11 +167,12 @@
|
164
|
167
|
|
165
|
168
|
- name: Retrieve the files that clients will need in order to connect to the OpenVPN server
|
166
|
169
|
fetch: src={{ openvpn_path }}/{{ item[0] }}/{{ item[1] }}
|
167
|
|
- dest=/tmp/sovereign-openvpn-files fail_on_missing=yes
|
|
170
|
+ dest="{{ secret }}/sovereign-openvpn-files"
|
|
171
|
+ fail_on_missing=yes
|
168
|
172
|
with_nested:
|
169
|
173
|
- "{{ openvpn_clients }}"
|
170
|
174
|
- ["client.crt", "client.key", "ca.crt", "ta.key", "{{ openvpn_server }}.ovpn"]
|
171
|
175
|
|
172
|
176
|
- name: Pause 5s seconds for OpenVPN ready
|
173
|
177
|
pause: seconds=5
|
174
|
|
- prompt="You are ready to set up your OpenVPN clients. The files that you need are in /tmp/sovereign-openvpn-files. Make sure LZO compression is enabled and that you provide the ta.key file for the TLS-Auth option with a direction of '1'. Press any key to continue..."
|
|
178
|
+ prompt="You are ready to set up your OpenVPN clients. The files that you need are in {{ secret }}/sovereign-openvpn-files. Make sure LZO compression is enabled and that you provide the ta.key file for the TLS-Auth option with a direction of '1'. Press any key to continue..."
|