blob: 1b9f33889d0c473ca79c4a4fb5f09e7315dcb342 [file] [log] [blame]
Jeremy Mowery0d693d32015-12-04 13:50:05 -07001---
2- hosts: {{ instance_name }}
3 gather_facts: False
4 connection: ssh
5 user: ubuntu
6 sudo: yes
Jeremy Mowery9a7ac292016-01-07 15:00:07 -07007 vars:
Jeremy Moweryfd081292016-02-07 17:07:55 -07008 server_network: {{ server_network }}
Jeremy Mowery9a7ac292016-01-07 15:00:07 -07009 is_persistent: {{ is_persistent }}
Jeremy Moweryfd081292016-02-07 17:07:55 -070010 vpn_subnet: {{ vpn_subnet }}
11 clients_can_see_each_other: {{ clients_can_see_each_other }}
Jeremy Mowery6d49f1a2016-03-21 17:56:25 -070012 port_number: {{ port_number }}
13 protocol: {{ protocol }}
Jeremy Mowery9d718b52016-04-02 10:16:21 -070014 pki_dir: {{ pki_dir }}
Jeremy Mowery9a7ac292016-01-07 15:00:07 -070015
Jeremy Mowery0d693d32015-12-04 13:50:05 -070016 tasks:
Jeremy Mowery8e91e872015-12-06 22:43:19 -070017 - name: install openvpn
18 apt: name=openvpn state=present update_cache=yes
Jeremy Mowery0d693d32015-12-04 13:50:05 -070019
Jeremy Mowerycec14012016-01-06 16:16:17 -070020 - name: stop openvpn
Jeremy Mowery9d718b52016-04-02 10:16:21 -070021 shell: kill -9 $(cat {{ pki_dir }}/pid) || true
Jeremy Mowerycec14012016-01-06 16:16:17 -070022
Jeremy Mowery1bac6472016-02-11 21:13:07 -070023 - name: make sure /opt/openvpn exists
24 file: path=/opt/openvpn state=directory
Jeremy Mowery81ec7002015-12-08 12:53:28 -070025
Jeremy Moweryb0178f02016-02-25 14:26:12 -070026 - name: make sure directory for this server exists
Jeremy Mowery9d718b52016-04-02 10:16:21 -070027 file: path={{ pki_dir }} state=directory
Jeremy Moweryb0178f02016-02-25 14:26:12 -070028
Jeremy Mowery1bac6472016-02-11 21:13:07 -070029 - name: get server key
Jeremy Mowery9d718b52016-04-02 10:16:21 -070030 copy: src={{ pki_dir }}/private/server.key dest={{ pki_dir }}/server.key
Jeremy Mowery0d693d32015-12-04 13:50:05 -070031
Jeremy Mowery1bac6472016-02-11 21:13:07 -070032 - name: get server crt
Jeremy Mowery9d718b52016-04-02 10:16:21 -070033 copy: src={{ pki_dir }}/issued/server.crt dest={{ pki_dir }}/server.crt
Jeremy Moweryfd081292016-02-07 17:07:55 -070034
Jeremy Mowery1bac6472016-02-11 21:13:07 -070035 - name: get ca crt
Jeremy Mowery9d718b52016-04-02 10:16:21 -070036 copy: src={{ pki_dir }}/ca.crt dest={{ pki_dir }}/ca.crt
Jeremy Moweryfd081292016-02-07 17:07:55 -070037
Jeremy Mowery60d4b742016-03-27 21:55:25 -070038 - name: get crl
Jeremy Mowery9d718b52016-04-02 10:16:21 -070039 copy: src={{ pki_dir }}/crl.pem dest={{ pki_dir }}/crl.pem
Jeremy Mowery60d4b742016-03-27 21:55:25 -070040
Jeremy Mowery1bac6472016-02-11 21:13:07 -070041 - name: get dh
Jeremy Mowery968129f2016-04-13 17:26:36 -070042 copy: src={{ pki_dir }}/dh.pem dest={{ pki_dir }}/dh.pem
Jeremy Moweryfd081292016-02-07 17:07:55 -070043
Jeremy Mowery79c07ec2016-04-15 15:50:28 -070044 - name: write config
45 template: src=/opt/xos/synchronizers/vpn/templates/server.conf.j2 dest={{ pki_dir }}/server.conf owner=root group=root
Jeremy Mowery3f6adcd2016-02-21 15:36:32 -070046
Jeremy Mowery8e91e872015-12-06 22:43:19 -070047 - name: start openvpn
Jeremy Moweryf2d72782016-04-10 15:25:14 -070048 shell: openvpn {{ pki_dir }}/server.conf &