summaryrefslogtreecommitdiff
path: root/roles/monitoring/prometheus/ca/tasks/main.yml
blob: 064cb6e842ab87a873a756b7844f656dfab39f75 (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/prometheus
    state: directory

- name: create CA directory
  file:
    path: /etc/ssl/prometheus/ca
    state: directory
    owner: root
    group: root
    mode: 0700

- name: create CA private key
  openssl_privatekey:
    path: /etc/ssl/prometheus/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/prometheus/ca/csr.pem
    privatekey_path: /etc/ssl/prometheus/ca/key.pem
    CN: "CA for prometheus zone {{ prometheus_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/prometheus/ca-crt.pem
    csr_path: /etc/ssl/prometheus/ca/csr.pem
    privatekey_path: /etc/ssl/prometheus/ca/key.pem
    provider: selfsigned
    selfsigned_digest: sha256
    selfsigned_not_after: "+18250d" ## 50 years
    selfsigned_create_subject_key_identifier: always_create