-
Notifications
You must be signed in to change notification settings - Fork 5
/
blackbox_exporter.yml
60 lines (50 loc) · 1.77 KB
/
blackbox_exporter.yml
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
59
60
---
- hosts: homelab
vars:
application: blackbox_exporter
blackbox_auth_username: "{{ blackbox_htpasswd.username }}"
blackbox_auth_password: "{{ blackbox_htpasswd.password }}"
docker_network: "{{ networks.user }}"
handlers:
- name: Restart
community.docker.docker_container:
name: "{{ application }}"
restart: true
comparisons:
'*': ignore
- name: Reload Prometheus
community.docker.docker_container_exec:
container: prometheus
command: kill -HUP 1
tasks:
- name: Create config folder
ansible.builtin.file:
path: "{{ config_directory }}"
state: directory
owner: "{{ common_user }}"
group: "{{ common_group }}"
mode: "0711"
- name: Template configuration
ansible.builtin.template:
src: "{{ files_directory }}/config.yml.j2"
dest: "{{ config_directory }}/config.yml"
mode: "0440"
validate: "docker run --rm --name {{ application }}_config_check -v %s:/tmp/config.yml prom/blackbox-exporter:master --config.check --config.file=/tmp/config.yml"
notify: Restart
- name: Create container
ansible.builtin.include_role:
name: docker_container
vars:
image: prom/blackbox-exporter:v0.25.0
volumes:
- "{{ config_directory }}:/etc/blackbox_exporter"
- name: Create scrape config for Prometheus
ansible.builtin.template:
src: "{{ item }}"
dest: "{{ prometheus_scrape_directory }}/{{ application }}-{{ item | basename | regex_replace('\\.j2$', '') }}"
mode: "0755"
owner: "65534" # nobody user
group: "{{ common_group }}"
with_fileglob:
- "{{ files_directory }}/scrape-configs/*"
notify: Reload Prometheus