summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inventory/group_vars/promzone-chaos-at-home/vars.yml2
-rw-r--r--roles/monitoring/prometheus/server/tasks/main.yml11
2 files changed, 13 insertions, 0 deletions
diff --git a/inventory/group_vars/promzone-chaos-at-home/vars.yml b/inventory/group_vars/promzone-chaos-at-home/vars.yml
index 413a6502..8a0d0aa8 100644
--- a/inventory/group_vars/promzone-chaos-at-home/vars.yml
+++ b/inventory/group_vars/promzone-chaos-at-home/vars.yml
@@ -1,3 +1,5 @@
---
promethues_server: ch-mon
promethues_zone_name: chaos@home
+
+prometheus_zone_targets: "{{ groups['promzone-chaos-at-home'] }}"
diff --git a/roles/monitoring/prometheus/server/tasks/main.yml b/roles/monitoring/prometheus/server/tasks/main.yml
index 6b030fb4..492e8dc2 100644
--- a/roles/monitoring/prometheus/server/tasks/main.yml
+++ b/roles/monitoring/prometheus/server/tasks/main.yml
@@ -50,6 +50,17 @@
- name: create TLS CA and certificates
import_tasks: tls.yml
+- name: generate targets config
+ loop: "{{ prometheus_zone_targets }}"
+ copy:
+ content: |
+ - targets: [ "{{ hostvars[item].ansible_default_ipv4.address }}:9999" ]
+ labels:
+ instance: "{{ item }}"
+ dest: "/etc/prometheus/targets/{{ item }}.yml"
+
+# TODO: enable targets for configured jobs using symlinks in /etc/prometheus/jobs/*/
+
- name: generate configuration file
template:
src: prometheus.yml.j2