add mSSL support for the prometheus server

This commit is contained in:
histausse 2021-09-21 16:30:49 +02:00
parent 569c9df319
commit 5a3268dc37
Signed by: histausse
GPG key ID: 67486F107F62E9E9
3 changed files with 24 additions and 1 deletions

View file

@ -37,7 +37,7 @@
group: prometheus group: prometheus
key_mode: u=rw,g=,o= key_mode: u=rw,g=,o=
subject_alt_name: "IP:{{ lan_address }}" subject_alt_name: "IP:{{ lan_address }}"
notify: Restart prometheus-node-exporter # Need an equivalent to notify here
- name: Copy the CA cert - name: Copy the CA cert
copy: copy:

View file

@ -19,6 +19,24 @@
owner: prometheus owner: prometheus
mode: u=rwx,g=rx,o=rx mode: u=rwx,g=rx,o=rx
- name: Generate certificate
include_role:
name: generate-cert
vars:
directory: /etc/prometheus/
cname: "prometheus-{{ lan_address }}"
owner: prometheus
group: prometheus
key_mode: u=rw,g=,o=
subject_alt_name: "IP:{{ lan_address }}"
# Need an equivalent to notify here
- name: Copy the CA cert
copy:
content: "{{ ca_cert }}"
dest: /etc/prometheus/ca.crt
notify: Restart prometheus
- name: Setup the prometheus config - name: Setup the prometheus config
template: template:
src: prometheus.yml src: prometheus.yml

View file

@ -45,3 +45,8 @@ scrape_configs:
- source_labels: [__param_target] - source_labels: [__param_target]
target_label: __address__ target_label: __address__
replacement: '$1:9100' replacement: '$1:9100'
scheme: https
tls_config:
ca_file: '/etc/prometheus/ca.crt'
cert_file: '/etc/prometheus/prometheus-{{ lan_address }}.crt'
key_file: '/etc/prometheus/prometheus-{{ lan_address }}.key'