---
- hosts: {{ instance_name }}
  gather_facts: False
  connection: ssh
  user: ubuntu
  sudo: yes
  tasks:
  - name: install openvpn
    apt: name=openvpn state=present update_cache=yes

  - name: erase key
    shell: rm static.key

  - name: write key
    shell: echo {{ '{{' }} item {{ '}}' }} >> static.key
    with_items: "{{ server_key }}"

  - name: erase config
    shell: rm server.conf

  - name: write config
    shell:
       |
       printf "dev tun
       ifconfig {{ '{{' }} server_address {{ '}}' }} {{ '{{' }} client_address {{ '}}' }}
       secret static.key
       keepalive 10 60
       ping-timer-rem
       persist-tun
       persist-key" > server.conf

  - name: start openvpn
    shell: openvpn server.conf &

---
- hosts: {{ instance_name }}
  gather_facts: False
  connection: ssh
  user: ubuntu
  sudo: yes
  tasks:
  - name: install openvpn
    apt: name=openvpn state=present update_cache=yes

  - name: stop openvpn
    shell: killall openvpn

  - 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 config
    shell:
       |
       printf "dev tun
       ifconfig {{ '{{' }} server_address {{ '}}' }} {{ '{{' }} client_address {{ '}}' }}
       secret static.key
       keepalive 10 60
       ping-timer-rem
       persist-tun
       persist-key" > server.conf

  - name: start openvpn
    shell: openvpn server.conf &

Add BooleanField for persistence and subnet visibility and dynimically create configuration with server and client addresses attempt 4
Add BooleanField for persistence and subnet visibility and dynimically create configuration with server and client addresses attempt 4
