Skip to content
Snippets Groups Projects
Commit 5c2d18f8 authored by Leonard Penzer's avatar Leonard Penzer
Browse files

Exclude hosts from scrape rules if prometheus_exporters_ignore is set

parent 0f065791
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !3. Comments created here will be created in the context of that merge request.
---
prometheus_exporters_ignore: true
---
prometheus_exporters_ignore: true
---
prometheus_exporters_ignore: true
---
prometheus_exporters_ignore: true
---
prometheus_exporters_ignore: true
---
role_core:
hosts:
core01-z10a.vm.freifunk-stuttgart.de:
core02-z10a.vm.freifunk-stuttgart.de:
...@@ -8,12 +8,26 @@ ...@@ -8,12 +8,26 @@
msg: "This role must only be run on prometheus hosts" msg: "This role must only be run on prometheus hosts"
when: not is_prometheus | default(false) when: not is_prometheus | default(false)
#- name: Create node_exporter_targets.yml file - name: Create node_exporter_targets.yml file
# template: template:
# src: node_exporter_targets.yml.j2 src: node_exporter_targets.yml.j2
# dest: /etc/prometheus/node_exporter_targets.yml dest: /etc/prometheus/node_exporter_targets.yml
# notify: notify:
# - Restart prometheus - Restart prometheus
- name: Create kea_exporter_targets.yml file
template:
src: kea_exporter_targets.yml.j2
dest: /etc/prometheus/kea_exporter_targets.yml
notify:
- Restart prometheus
- name: Create bird_exporter_targets.yml file
template:
src: bird_exporter_targets.yml.j2
dest: /etc/prometheus/bird_exporter_targets.yml
notify:
- Restart prometheus
- name: Check if client-cert exists - name: Check if client-cert exists
stat: stat:
...@@ -134,3 +148,12 @@ ...@@ -134,3 +148,12 @@
file: file:
path: /tmp/{{ inventory_hostname }}.cert.pem path: /tmp/{{ inventory_hostname }}.cert.pem
state: absent state: absent
- name: Installing prometheus exporter packages
apt:
name:
- prometheus
- prometheus-alertmanager
- prometheus-blackbox-exporter
state: present
install_recommends: false
{% for container in groups['role_core'] %}
- targets:
- '{{ hostvars[container].ansible_host | default(container) }}:9998'
labels:
instance: {{ (hostvars[container].ansible_host | default(container)).split('.')[0] }}
{% endfor %}
{% for container in groups['role_dhcpserver'] %}
- targets:
- '{{ hostvars[container].ansible_host | default(container) }}:9998'
labels:
instance: {{ (hostvars[container].ansible_host | default(container)).split('.')[0] }}
{% endfor %}
{% for host in groups['all'] %}
{% if not hostvars[host].prometheus_exporters_ignore | default(false) %}
- targets: - targets:
{% for container in groups['ffspveguests'] %} - '{{ hostvars[host].ansible_host | default(host) }}:9998'
- '{{ hostvars[container].ansible_host | default(container) }}.vm.freifunk-stuttgart.de:9998' labels:
instance: {{ (hostvars[host].ansible_host | default(host)).split('.')[0] }}
{% endif %}
{% endfor %} {% endfor %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment