Skip to content

Commit cc5ac42

Browse files
committed
Allow changing config filename and client config dir
1 parent 32125cb commit cc5ac42

File tree

6 files changed

+15
-9
lines changed

6 files changed

+15
-9
lines changed

defaults/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,12 @@ openvpn_script_output_directories: []
208208
# A path on the OpenVPN server where OpenVPN scripts should be uploaded to.
209209
openvpn_scripts_dir: "{{ openvpn_etcdir }}/scripts/"
210210

211+
# In some distros, the server with `foobar.conf` config file can be managed
212+
# using `openvpn@foobar` service
213+
openvpn_config_file: "{{ openvpn_etcdir }}/server.conf"
214+
215+
openvpn_client_config_dir: "{{ openvpn_client_config_dir }}"
216+
211217
# A list of files located on the Ansible controller that the role should upload.
212218
# The scripts will be uploaded under `openvpn_scripts_dir`. You can reference
213219
# them in `openvpn_server_options` for the OpenVPN configuration option you

tasks/authentication/tls.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
- name: Generate tls-auth key
44
command:
5-
openvpn --genkey --secret "{{ openvpn_etcdir }}/ovpns/{{ openvpn_tls_key }}"
5+
openvpn --genkey --secret "{{ openvpn_client_config_dir }}/{{ openvpn_tls_key }}"
66
args:
7-
creates: "{{ openvpn_etcdir }}/ovpns/{{ openvpn_tls_key }}"
7+
creates: "{{ openvpn_client_config_dir }}/{{ openvpn_tls_key }}"
88
when: openvpn_tls_auth

tasks/core/clients.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
- name: Generate client configurations
44
template:
55
src: "{{ openvpn_client_conf_template }}"
6-
dest: "{{ openvpn_etcdir }}/ovpns/{{ item }}.ovpn"
6+
dest: "{{ openvpn_client_config_dir }}/{{ item }}.ovpn"
77
loop: "{{ openvpn_clients }}"
88
register: openvpn_clients_changed
99

@@ -20,12 +20,12 @@
2020
loop_control:
2121
index_var: index
2222
args:
23-
chdir: "{{ openvpn_etcdir }}/ovpns/"
23+
chdir: "{{ openvpn_client_config_dir }}"
2424
when: openvpn_clients_changed.results[index] is changed
2525

2626
- name: Download client credentials
2727
fetch:
28-
src: "{{ openvpn_etcdir }}/ovpns/{{ item }}.zip"
28+
src: "{{ openvpn_client_config_dir }}/{{ item }}.zip"
2929
dest: "{{ openvpn_download_dir }}"
3030
flat: true
3131
validate_checksum: true

tasks/core/configure.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
- name: Configure server
1616
template:
1717
src: server.conf.j2
18-
dest: "{{ openvpn_etcdir }}/server.conf"
18+
dest: "{{ openvpn_config_file }}"
1919
notify: openvpn restart
2020

2121
# Needed by both tls-authentication tasks and client-configuration tasks. Placed
2222
# here to avoid repeating it twice in both places where the tls and
2323
# client-config tasks are located.
2424
- name: Create client configuration directory
2525
file:
26-
path: "{{ openvpn_etcdir }}/ovpns"
26+
path: "{{ openvpn_client_config_dir }}"
2727
state: directory

tasks/core/read-client-files.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
- name: Read TLS-auth key
99
slurp:
10-
src: "{{ openvpn_etcdir }}/ovpns/{{ openvpn_tls_key }}"
10+
src: "{{ openvpn_client_config_dir }}/{{ openvpn_tls_key }}"
1111
no_log: true
1212
register: openvpn_read_tlsauth_file_results
1313
changed_when: false

templates/server.conf.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ dh {{ openvpn_keydir }}/dh.pem
5252

5353
{% if openvpn_tls_auth -%}
5454
# Use a static pre-shared key (PSK)
55-
tls-auth {{ openvpn_etcdir }}/ovpns/{{ openvpn_tls_key }} 0
55+
tls-auth {{ openvpn_client_config_dir }}/{{ openvpn_tls_key }} 0
5656
tls-server
5757
{% endif %}
5858

0 commit comments

Comments
 (0)