Skip to content

Commit

Permalink
Add variable for server key/cert/ca
Browse files Browse the repository at this point in the history
  • Loading branch information
tahajahangir committed Nov 26, 2020
1 parent 1f063a2 commit b5d6f2b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ openvpn_keydir: "{{ openvpn_etcdir }}/keys"
# README. Then you can simply point this variable to the pki folder of the
# easyrsa installation and all keys/certificates will be located fine.
# }}}

openvpn_ca_certs_file: '{{ openvpn_keydir }}/ca.crt'
openvpn_server_cert_file: '{{ openvpn_keydir }}/issued/server.crt'
openvpn_server_key_file: '{{ openvpn_keydir }}/private/server.key'

# Server configuration {{{
# Default settings (See OpenVPN documentation)
openvpn_host: "{{ inventory_hostname }}"
Expand Down
2 changes: 1 addition & 1 deletion tasks/core/clients.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{{ openvpn_keydir }}/issued/{{ item }}.crt
{{ openvpn_keydir }}/private/{{ item }}.key
{{ item }}.ovpn
{{ openvpn_keydir }}/ca.crt
{{ openvpn_ca_certs_file }}
{{ openvpn_tls_key if openvpn_tls_auth else '' }}
loop: "{{ openvpn_clients }}"
loop_control:
Expand Down
2 changes: 1 addition & 1 deletion tasks/core/read-client-files.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Read CA file
command: cat "{{ openvpn_keydir }}/ca.crt"
command: cat "{{ openvpn_ca_certs_file }}"
no_log: true
register: openvpn_read_ca_file_results
changed_when: false
Expand Down
6 changes: 3 additions & 3 deletions templates/server.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ dev {{ openvpn_dev }}
#
# Any X509 key management system can be used. OpenVPN can also use a PKCS #12
# formatted key file (see "pkcs12" directive in man page).
ca {{ openvpn_keydir }}/ca.crt
cert {{ openvpn_keydir }}/issued/server.crt
key {{ openvpn_keydir }}/private/server.key # This file should be kept secret
ca {{ openvpn_ca_certs_file }}
cert {{ openvpn_server_cert_file }}
key {{ openvpn_server_key_file }} # This file should be kept secret

# Diffie hellman parameters. Generate your own with: openssl dhparam -out
# dh1024.pem 1024 Substitute 2048 for 1024 if you are using 2048 bit keys.
Expand Down

0 comments on commit b5d6f2b

Please sign in to comment.