add service handling
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Robert Kaussow 2020-05-15 11:21:59 +02:00
parent 30492f7228
commit bbf0246554
2 changed files with 17 additions and 2 deletions

9
handlers/main.yml Normal file
View File

@ -0,0 +1,9 @@
---
- name: Restart openvpn client
service:
name: "openvpn@{{ openvpn_client_name }}"
state: restarted
enabled: yes
listen: __openvpn_restart
become: True
become_user: root

View File

@ -16,7 +16,7 @@
- name: Write client config
template:
src: etc/openvpn/client.conf.j2
dest: "/etc/openvpn/{{ openvpn_name }}.conf"
dest: "/etc/openvpn/{{ openvpn_client_name }}.conf"
mode: 0600
notify: __openvpn_restart
@ -33,6 +33,12 @@
- { src: "{{ openvpn_client_ta_source | default(False) }}", dest: "/etc/openvpn/certs/{{ openvpn_client_ta_file }}", mode: "0600" }
loop_control:
label: "{{ item.dest }}"
notify: __nginx_reload
notify: __openvpn_restart
- name: Ensure openvpn service is up and running
systemd:
name: "openvpn@{{ openvpn_client_name }}"
state: started
enabled: yes
become: True
become_user: root