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/lineinfile.yml | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 tasks/lineinfile.yml (limited to 'tasks/lineinfile.yml') diff --git a/tasks/lineinfile.yml b/tasks/lineinfile.yml deleted file mode 100644 index 8c60ba0..0000000 --- a/tasks/lineinfile.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- -- name: Make sure targets are deployed - ansible.builtin.lineinfile: - path: '{{ ( - item.path_prefix if item.path_prefix is defined else - (prometheus_target_exporter_defaults[item.id].path_prefix - | default(prometheus_target_exporter_target_prefix)) - if item.id is defined) - ~ - (item.path if item.path is defined - else prometheus_target_exporter_defaults[item.id].path if item.id is defined) | mandatory }}' - line: '{{ prometheus_target_strategy_lineinfile_prefix ~ - (item.host if item.host is defined else prometheus_target_exporter_defaults[item.id].host) | mandatory ~ - prometheus_target_strategy_lineinfile_suffix }}' - state: present - become: true - delegate_to: '{{ prometheus_target_host }}' - loop: '{{ prometheus_target_exporter + - ([] if prometheus_target_skip_default_exporters else prometheus_target_default_exporters) }}' - register: lineinfile - -- name: Export fact - ansible.builtin.set_fact: - changed: '{{ changed or lineinfile.changed }}' -- cgit v1.2.3