From 049689c124a274870b5405ff6816beeba7d94a14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20K=C3=BChne?= <73171182+magkue@users.noreply.github.com> Date: Mon, 9 Feb 2026 17:23:57 +0100 Subject: Add support for YAML strategy Introduces a new 'yaml' strategy using Ansible's `from_yaml` to read target files. This allows users to group multiple targets with distinct label sets (e.g., severity or job) within a single file, optimizing Prometheus file-based service discovery. - Refactored task structure into `strategy_*.yml` for consistency. - Extracted shared exporter variable computation. - Implemented label merging where exporter labels override defaults. - Included support for groups and hosts without labels to prevent crashes. PR: (#1) https://github.com/kliwniloc/ansible-role-prometheus-target/pull/1 --- defaults/main.yml | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'defaults/main.yml') diff --git a/defaults/main.yml b/defaults/main.yml index 807f507..795e3cb 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -126,10 +126,15 @@ prometheus_target_exporter_defaults: {} # node_exporter: # path: /opt/prometheus/targets.yml # host: '{{ inventory_hostname }}:9100' + # labels: # Labels to match when using yaml strategy + # severity: warning + # job: external # blackbox_exporter: # path: /opt/targets/blackbox.yml # host: 'https://{{ hostvars[inventory_hostname].ansible_host }}' # path_prefix: '' + # labels: + # severity: critical # This is where you specify the exporters that should be deployed to prometheus. # You should configure this on a per play basis. If you wish to configure @@ -141,6 +146,10 @@ prometheus_target_exporter: [] # path: /path/to/targets/file/on/prometheus/host # # overwrites: prometheus_target_exporter_defaults.node_exporter.host # host: '{{ inventory_hostname }}:9100' + # # labels to match the target group in the YAML file (yaml strategy only) + # labels: + # severity: warning + # job: external # This is a list of exporters that will be appended to the # prometheus_target_exporter variable. duplicate exporters in -- cgit v1.2.3