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

Exclude hosts from scrape rules if prometheus_exporters_ignore is set

parent fb9bb15e
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 @@
msg: "This role must only be run on prometheus hosts"
when: not is_prometheus | default(false)
#- name: Create node_exporter_targets.yml file
# template:
# src: node_exporter_targets.yml.j2
# dest: /etc/prometheus/node_exporter_targets.yml
# notify:
# - Restart prometheus
- name: Create node_exporter_targets.yml file
template:
src: node_exporter_targets.yml.j2
dest: /etc/prometheus/node_exporter_targets.yml
notify:
- 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
stat:
......@@ -134,3 +148,12 @@
file:
path: /tmp/{{ inventory_hostname }}.cert.pem
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:
{% for container in groups['ffspveguests'] %}
- '{{ hostvars[container].ansible_host | default(container) }}.vm.freifunk-stuttgart.de:9998'
- '{{ hostvars[host].ansible_host | default(host) }}:9998'
labels:
instance: {{ (hostvars[host].ansible_host | default(host)).split('.')[0] }}
{% endif %}
{% endfor %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment