blob: 02e2feb25876b19752cf3cc1070a6eb4b355e8cc [file] [log] [blame]
---
- hosts: {{ instance_name }}
gather_facts: False
connection: ssh
user: ubuntu
sudo: yes
vars:
server_address: {{ server_address }}
client_address: {{ client_address }}
server_key: {{ server_key }}
is_persistent: {{ is_persistent }}
tasks:
- name: install openvpn
apt: name=openvpn state=present update_cache=yes
- name: stop openvpn
shell: killall openvpn | true
- name: erase key
shell: rm -f static.key
- name: write key
shell: echo {{ '{{' }} item {{ '}}' }} >> static.key
with_items: "{{ server_key }}"
- name: erase config
shell: rm -f server.conf
- name: write base config
shell:
|
printf "dev tun
ifconfig {{ server_address }} {{ client_address }}
secret static.key" > server.conf
- name: write persistent config
shell:
|
printf "\nkeepalive 10 60
ping-timer-rem
persist-tun
persist-key" >> server.conf
when: {{ is_persistent }}
- name: start openvpn
shell: openvpn server.conf &