Jeremy Mowery | 0d693d3 | 2015-12-04 13:50:05 -0700 | [diff] [blame] | 1 | --- |
| 2 | - hosts: {{ instance_name }} |
| 3 | gather_facts: False |
| 4 | connection: ssh |
| 5 | user: ubuntu |
| 6 | sudo: yes |
Jeremy Mowery | 9a7ac29 | 2016-01-07 15:00:07 -0700 | [diff] [blame] | 7 | vars: |
Jeremy Mowery | fd08129 | 2016-02-07 17:07:55 -0700 | [diff] [blame] | 8 | server_network: {{ server_network }} |
Jeremy Mowery | 9a7ac29 | 2016-01-07 15:00:07 -0700 | [diff] [blame] | 9 | is_persistent: {{ is_persistent }} |
Jeremy Mowery | fd08129 | 2016-02-07 17:07:55 -0700 | [diff] [blame] | 10 | vpn_subnet: {{ vpn_subnet }} |
| 11 | clients_can_see_each_other: {{ clients_can_see_each_other }} |
Jeremy Mowery | 6d49f1a | 2016-03-21 17:56:25 -0700 | [diff] [blame] | 12 | port_number: {{ port_number }} |
| 13 | protocol: {{ protocol }} |
Jeremy Mowery | 9d718b5 | 2016-04-02 10:16:21 -0700 | [diff] [blame] | 14 | pki_dir: {{ pki_dir }} |
Jeremy Mowery | 9a7ac29 | 2016-01-07 15:00:07 -0700 | [diff] [blame] | 15 | |
Jeremy Mowery | 0d693d3 | 2015-12-04 13:50:05 -0700 | [diff] [blame] | 16 | tasks: |
Jeremy Mowery | 8e91e87 | 2015-12-06 22:43:19 -0700 | [diff] [blame] | 17 | - name: install openvpn |
| 18 | apt: name=openvpn state=present update_cache=yes |
Jeremy Mowery | 0d693d3 | 2015-12-04 13:50:05 -0700 | [diff] [blame] | 19 | |
Jeremy Mowery | cec1401 | 2016-01-06 16:16:17 -0700 | [diff] [blame] | 20 | - name: stop openvpn |
Jeremy Mowery | 9d718b5 | 2016-04-02 10:16:21 -0700 | [diff] [blame] | 21 | shell: kill -9 $(cat {{ pki_dir }}/pid) || true |
Jeremy Mowery | cec1401 | 2016-01-06 16:16:17 -0700 | [diff] [blame] | 22 | |
Jeremy Mowery | 1bac647 | 2016-02-11 21:13:07 -0700 | [diff] [blame] | 23 | - name: make sure /opt/openvpn exists |
| 24 | file: path=/opt/openvpn state=directory |
Jeremy Mowery | 81ec700 | 2015-12-08 12:53:28 -0700 | [diff] [blame] | 25 | |
Jeremy Mowery | b0178f0 | 2016-02-25 14:26:12 -0700 | [diff] [blame] | 26 | - name: make sure directory for this server exists |
Jeremy Mowery | 9d718b5 | 2016-04-02 10:16:21 -0700 | [diff] [blame] | 27 | file: path={{ pki_dir }} state=directory |
Jeremy Mowery | b0178f0 | 2016-02-25 14:26:12 -0700 | [diff] [blame] | 28 | |
Jeremy Mowery | 1bac647 | 2016-02-11 21:13:07 -0700 | [diff] [blame] | 29 | - name: get server key |
Jeremy Mowery | 9d718b5 | 2016-04-02 10:16:21 -0700 | [diff] [blame] | 30 | copy: src={{ pki_dir }}/private/server.key dest={{ pki_dir }}/server.key |
Jeremy Mowery | 0d693d3 | 2015-12-04 13:50:05 -0700 | [diff] [blame] | 31 | |
Jeremy Mowery | 1bac647 | 2016-02-11 21:13:07 -0700 | [diff] [blame] | 32 | - name: get server crt |
Jeremy Mowery | 9d718b5 | 2016-04-02 10:16:21 -0700 | [diff] [blame] | 33 | copy: src={{ pki_dir }}/issued/server.crt dest={{ pki_dir }}/server.crt |
Jeremy Mowery | fd08129 | 2016-02-07 17:07:55 -0700 | [diff] [blame] | 34 | |
Jeremy Mowery | 1bac647 | 2016-02-11 21:13:07 -0700 | [diff] [blame] | 35 | - name: get ca crt |
Jeremy Mowery | 9d718b5 | 2016-04-02 10:16:21 -0700 | [diff] [blame] | 36 | copy: src={{ pki_dir }}/ca.crt dest={{ pki_dir }}/ca.crt |
Jeremy Mowery | fd08129 | 2016-02-07 17:07:55 -0700 | [diff] [blame] | 37 | |
Jeremy Mowery | 60d4b74 | 2016-03-27 21:55:25 -0700 | [diff] [blame] | 38 | - name: get crl |
Jeremy Mowery | 9d718b5 | 2016-04-02 10:16:21 -0700 | [diff] [blame] | 39 | copy: src={{ pki_dir }}/crl.pem dest={{ pki_dir }}/crl.pem |
Jeremy Mowery | 60d4b74 | 2016-03-27 21:55:25 -0700 | [diff] [blame] | 40 | |
Jeremy Mowery | 1bac647 | 2016-02-11 21:13:07 -0700 | [diff] [blame] | 41 | - name: get dh |
Jeremy Mowery | 968129f | 2016-04-13 17:26:36 -0700 | [diff] [blame] | 42 | copy: src={{ pki_dir }}/dh.pem dest={{ pki_dir }}/dh.pem |
Jeremy Mowery | fd08129 | 2016-02-07 17:07:55 -0700 | [diff] [blame] | 43 | |
Jeremy Mowery | 79c07ec | 2016-04-15 15:50:28 -0700 | [diff] [blame] | 44 | - name: write config |
| 45 | template: src=/opt/xos/synchronizers/vpn/templates/server.conf.j2 dest={{ pki_dir }}/server.conf owner=root group=root |
Jeremy Mowery | 3f6adcd | 2016-02-21 15:36:32 -0700 | [diff] [blame] | 46 | |
Jeremy Mowery | 8e91e87 | 2015-12-06 22:43:19 -0700 | [diff] [blame] | 47 | - name: start openvpn |
Jeremy Mowery | f2d7278 | 2016-04-10 15:25:14 -0700 | [diff] [blame] | 48 | shell: openvpn {{ pki_dir }}/server.conf & |