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 --- tasks/main.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'tasks/main.yml') diff --git a/tasks/main.yml b/tasks/main.yml index f8d6caa..5a184f8 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,11 +1,13 @@ --- -- name: Select strategy +- name: Process all exporters ansible.builtin.include_tasks: - file: '{{ prometheus_target_strategy }}.yml' - vars: - changed: false + file: process_exporter.yml + loop: '{{ prometheus_target_exporter + + ([] if prometheus_target_skip_default_exporters else prometheus_target_default_exporters) }}' + loop_control: + loop_var: item - name: Run handlers ansible.builtin.include_tasks: file: handlers.yml - when: changed + when: changed | default(false) -- cgit v1.2.3