xoxys.openvpn_client/tasks/main.yml

46 lines
1.5 KiB
YAML
Raw Normal View History

2020-05-15 08:34:57 +00:00
---
- block:
- name: Install dependencies
package:
name: "{{ item }}"
state: present
loop: "{{ openvpn_client_packages_extra }}"
- name: Install required packages
package:
name: "{{ item }}"
state: present
loop:
- openvpn
- name: Write client config
template:
src: etc/openvpn/client.conf.j2
2020-05-15 09:21:59 +00:00
dest: "/etc/openvpn/{{ openvpn_client_name }}.conf"
2020-05-15 08:34:57 +00:00
mode: 0600
notify: __openvpn_restart
- name: Copy cert files (if defined)
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
loop:
2020-05-15 09:31:32 +00:00
- { src: "{{ openvpn_client_ca_source | default('') }}", dest: "/etc/openvpn/certs/{{ openvpn_client_ca_file }}", mode: "0650" }
- { src: "{{ openvpn_client_cert_source | default('') }}", dest: "/etc/openvpn/certs/{{ openvpn_client_cert_file }}", mode: "0650" }
- { src: "{{ openvpn_client_key_source | default('') }}", dest: "/etc/openvpn/certs/{{ openvpn_client_key_file }}", mode: "0600" }
- { src: "{{ openvpn_client_ta_source | default('') }}", dest: "/etc/openvpn/certs/{{ openvpn_client_ta_file }}", mode: "0600" }
2020-05-15 08:34:57 +00:00
loop_control:
label: "{{ item.dest }}"
2020-05-15 09:31:32 +00:00
when: item.src | length > 0
2020-05-15 09:21:59 +00:00
notify: __openvpn_restart
- name: Ensure openvpn service is up and running
systemd:
name: "openvpn@{{ openvpn_client_name }}"
state: started
enabled: yes
2020-05-15 08:34:57 +00:00
become: True
become_user: root