|
|
@ -2,7 +2,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
- name: Build config for OpenVPN tunnels |
|
|
|
- name: Build config for OpenVPN tunnels |
|
|
|
set_fact: ovpn_daemons_conf={{ ovpn_daemons_conf | default([]) + [ovpn_daemon_defaults | combine(item)] }} |
|
|
|
set_fact: ovpn_daemons_conf={{ ovpn_daemons_conf | default([]) + [ovpn_daemon_defaults | combine(item)] }} |
|
|
|
with_items: "{{ ovpn_daemons }}" |
|
|
|
loop: "{{ ovpn_daemons }}" |
|
|
|
tags: ovpn |
|
|
|
tags: ovpn |
|
|
|
- set_fact: ovpn_daemons={{ ovpn_daemons_conf | default([]) }} |
|
|
|
- set_fact: ovpn_daemons={{ ovpn_daemons_conf | default([]) }} |
|
|
|
tags: ovpn |
|
|
|
tags: ovpn |
|
|
@ -13,9 +13,20 @@ |
|
|
|
- openvpn |
|
|
|
- openvpn |
|
|
|
tags: ovpn |
|
|
|
tags: ovpn |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Deploy OpenVPN service template |
|
|
|
|
|
|
|
template: src=openvpn@.service.j2 dest=/etc/systemd/system/openvpn@.service |
|
|
|
|
|
|
|
register: ovpn_service_template |
|
|
|
|
|
|
|
notify: restart all openvpn |
|
|
|
|
|
|
|
tags: ovpn |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Reload systemd |
|
|
|
|
|
|
|
systemd: daemon_reload=True |
|
|
|
|
|
|
|
when: ovpn_service_template.changed |
|
|
|
|
|
|
|
tags: ovpn |
|
|
|
|
|
|
|
|
|
|
|
- name: Deploy daemons configuration |
|
|
|
- name: Deploy daemons configuration |
|
|
|
template: src=openvpn.conf.j2 dest=/etc/openvpn/{{ item.name }}.conf mode=640 |
|
|
|
template: src=openvpn.conf.j2 dest=/etc/openvpn/{{ item.name }}.conf mode=640 |
|
|
|
with_items: "{{ ovpn_daemons }}" |
|
|
|
loop: "{{ ovpn_daemons }}" |
|
|
|
when: item.enabled |
|
|
|
when: item.enabled |
|
|
|
register: ovpn_daemons_mod |
|
|
|
register: ovpn_daemons_mod |
|
|
|
notify: restart openvpn |
|
|
|
notify: restart openvpn |
|
|
@ -25,7 +36,7 @@ |
|
|
|
command: openssl dhparam /etc/openvpn/{{ item.iname}}.dh 2048 |
|
|
|
command: openssl dhparam /etc/openvpn/{{ item.iname}}.dh 2048 |
|
|
|
args: |
|
|
|
args: |
|
|
|
creates: /etc/openvpn/{{ item.name }}.dh |
|
|
|
creates: /etc/openvpn/{{ item.name }}.dh |
|
|
|
with_items: "{{ ovpn_daemons }}" |
|
|
|
loop: "{{ ovpn_daemons }}" |
|
|
|
when: |
|
|
|
when: |
|
|
|
- item.type == 'server' |
|
|
|
- item.type == 'server' |
|
|
|
- item.enabled |
|
|
|
- item.enabled |
|
|
@ -58,7 +69,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
- name: Handle daemons status |
|
|
|
- name: Handle daemons status |
|
|
|
service: name=openvpn@{{ item.name }} state={{ (item.enabled) | ternary('started','stopped') }} enabled={{ (item.enabled) | ternary(True,False) }} |
|
|
|
service: name=openvpn@{{ item.name }} state={{ (item.enabled) | ternary('started','stopped') }} enabled={{ (item.enabled) | ternary(True,False) }} |
|
|
|
with_items: "{{ ovpn_daemons }}" |
|
|
|
loop: "{{ ovpn_daemons }}" |
|
|
|
tags: ovpn |
|
|
|
tags: ovpn |
|
|
|
|
|
|
|
|
|
|
|
- name: List managed daemons ID |
|
|
|
- name: List managed daemons ID |
|
|
@ -73,10 +84,10 @@ |
|
|
|
|
|
|
|
|
|
|
|
- name: Disable unmanaged services |
|
|
|
- name: Disable unmanaged services |
|
|
|
service: name=openvpn@{{ item }} state=stopped enabled=False |
|
|
|
service: name=openvpn@{{ item }} state=stopped enabled=False |
|
|
|
with_items: "{{ ovpn_existing_conf.stdout_lines | difference(ovpn_managed_id) }}" |
|
|
|
loop: "{{ ovpn_existing_conf.stdout_lines | difference(ovpn_managed_id) }}" |
|
|
|
tags: ovpn |
|
|
|
tags: ovpn |
|
|
|
|
|
|
|
|
|
|
|
- name: Remove unmanaged conf |
|
|
|
- name: Remove unmanaged conf |
|
|
|
file: path=/etc/openvpn/{{ item }}.conf state=absent |
|
|
|
file: path=/etc/openvpn/{{ item }}.conf state=absent |
|
|
|
with_items: "{{ ovpn_existing_conf.stdout_lines | difference(ovpn_managed_id) }}" |
|
|
|
loop: "{{ ovpn_existing_conf.stdout_lines | difference(ovpn_managed_id) }}" |
|
|
|
tags: ovpn |
|
|
|
tags: ovpn |
|
|
|