summaryrefslogtreecommitdiff
path: root/roles/network/openvpn/ca/tasks/main.yml
blob: 90b021fc34abb4633f0e0d1750d854c23137fd1a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
- name: install python-cryptoraphy
  apt:
    name: "{{ python_basename }}-cryptography"
    state: present

- name: create base directory
  file:
    path: "/etc/ssl/openvpn/{{ openvpn_zone.name }}"
    state: directory

- name: create CA directory
  file:
    path: "/etc/ssl/openvpn/{{ openvpn_zone.name }}/ca"
    state: directory
    owner: root
    group: root
    mode: 0700

- name: create CA private key
  openssl_privatekey:
    path: "/etc/ssl/openvpn/{{ openvpn_zone.name }}/ca/key.pem"
    type: RSA
    size: 4096
    owner: root
    group: root
    mode: 0600

- name: create signing request for CA certificate
  openssl_csr:
    path: "/etc/ssl/openvpn/{{ openvpn_zone.name }}/ca/csr.pem"
    privatekey_path: "/etc/ssl/openvpn/{{ openvpn_zone.name }}/ca/key.pem"
    CN: "CA for OpenVPN zone {{ openvpn_zone.name }}"
    useCommonNameForSAN: no
    key_usage:
    - cRLSign
    - keyCertSign
    key_usage_critical: yes
    basic_constraints:
    - 'CA:TRUE'
    - 'pathlen:0'
    basic_constraints_critical: yes

- name: create self-signed CA certificate
  openssl_certificate:
    path: "/etc/ssl/openvpn/{{ openvpn_zone.name }}/ca-crt.pem"
    csr_path: "/etc/ssl/openvpn/{{ openvpn_zone.name }}/ca/csr.pem"
    privatekey_path: "/etc/ssl/openvpn/{{ openvpn_zone.name }}/ca/key.pem"
    provider: selfsigned
    selfsigned_digest: sha256
    selfsigned_not_after: "+18250d" ## 50 years
    selfsigned_create_subject_key_identifier: always_create