summaryrefslogtreecommitdiff
path: root/roles/monitoring/prometheus/exporter/ssl/tasks/main.yml
blob: 07c1b3fbbc58e1d6ee466cafcf7422609c41349c (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
53
54
55
56
57
58
---
- name: generate apt pin file for exporter-ssl package
  when: prometheus_exporter_ssl_version is defined
  copy:
    dest: "/etc/apt/preferences.d/prom-exporter-ssl.pref"
    content: |
      Package: prom-exporter-ssl
      Pin: version {{ prometheus_exporter_ssl_version }}-1
      Pin-Priority: 1001

- name: remove apt pin file for exporter-ssl package
  when: prometheus_exporter_ssl_version is not defined
  file:
    path: "/etc/apt/preferences.d/prom-exporter-ssl.pref"
    state: absent

- name: install apt packages
  apt:
    name: "prom-exporter-ssl{% if prometheus_exporter_ssl_version is defined %}={{ prometheus_exporter_ssl_version }}-1{% endif %}"
    state: present
    allow_downgrade: yes
  notify: restart prometheus-ssl-exporter

- name: create config directory
  file:
    path: /etc/prometheus/exporter/ssl
    state: directory

- name: generate configuration
  template:
    src: config.yml.j2
    dest: /etc/prometheus/exporter/ssl/config.yml
  notify: restart prometheus-ssl-exporter

- name: generate systemd service unit
  template:
    src: service.j2
    dest: /etc/systemd/system/prometheus-ssl-exporter.service
  notify: restart prometheus-ssl-exporter

- name: make sure prometheus-ssl-exporter is enabled and started
  systemd:
    name: prometheus-ssl-exporter.service
    daemon_reload: yes
    state: started
    enabled: yes

- name: register exporter
  copy:
    content: |
      location = /ssl {
          proxy_pass http://127.0.0.1:9219/metrics;
      }
      location = /ssl/probe {
          proxy_pass http://127.0.0.1:9219/probe;
      }
    dest: /etc/prometheus/exporter/ssl.locations
  notify: reload nginx