blob: 1b9f33889d0c473ca79c4a4fb5f09e7315dcb342 [file] [log] [blame]
---
- hosts: {{ instance_name }}
gather_facts: False
connection: ssh
user: ubuntu
sudo: yes
vars:
server_network: {{ server_network }}
is_persistent: {{ is_persistent }}
vpn_subnet: {{ vpn_subnet }}
clients_can_see_each_other: {{ clients_can_see_each_other }}
port_number: {{ port_number }}
protocol: {{ protocol }}
pki_dir: {{ pki_dir }}
tasks:
- name: install openvpn
apt: name=openvpn state=present update_cache=yes
- name: stop openvpn
shell: kill -9 $(cat {{ pki_dir }}/pid) || true
- name: make sure /opt/openvpn exists
file: path=/opt/openvpn state=directory
- name: make sure directory for this server exists
file: path={{ pki_dir }} state=directory
- name: get server key
copy: src={{ pki_dir }}/private/server.key dest={{ pki_dir }}/server.key
- name: get server crt
copy: src={{ pki_dir }}/issued/server.crt dest={{ pki_dir }}/server.crt
- name: get ca crt
copy: src={{ pki_dir }}/ca.crt dest={{ pki_dir }}/ca.crt
- name: get crl
copy: src={{ pki_dir }}/crl.pem dest={{ pki_dir }}/crl.pem
- name: get dh
copy: src={{ pki_dir }}/dh.pem dest={{ pki_dir }}/dh.pem
- name: write config
template: src=/opt/xos/synchronizers/vpn/templates/server.conf.j2 dest={{ pki_dir }}/server.conf owner=root group=root
- name: start openvpn
shell: openvpn {{ pki_dir }}/server.conf &