From 0b2823d40892ffca4c0c64536c6a821cebaf3ff6 Mon Sep 17 00:00:00 2001 From: Colin Wilk Date: Sat, 27 May 2023 19:57:38 +0200 Subject: Switch to single host per exporter configuration Before you could do multiple hosts per exporter like this: - id: node_exporter hosts: - host1 - host2 This was removed since it simplifies the code quite a bit and you can still archive the same behavior like this: - { id: node_exporter, host: host1 } - { id: node_exporter, host: host2 } Signed-off-by: Colin Wilk --- tasks/lineinfile.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'tasks/lineinfile.yml') diff --git a/tasks/lineinfile.yml b/tasks/lineinfile.yml index c90e823..ff09478 100644 --- a/tasks/lineinfile.yml +++ b/tasks/lineinfile.yml @@ -1,15 +1,14 @@ --- - name: Make sure targets are deployed ansible.builtin.lineinfile: - path: '{{ item.0.path if item.0.path is defined else prometheus_target_exporter_defaults[item.0.id].path }}' + path: '{{ item.path if item.path is defined else prometheus_target_exporter_defaults[item.id].path }}' line: '{{ prometheus_target_strategy_lineinfile_prefix ~ - (item.1 if item.1 != "" else prometheus_target_exporter_defaults[item.0.id].host) ~ + (item.host if item.host is defined else prometheus_target_exporter_defaults[item.id].host) ~ prometheus_target_strategy_lineinfile_suffix }}' state: present become: true delegate_to: '{{ prometheus_target_host }}' - loop: '{{ (prometheus_target_exporter | selectattr("hosts", "defined") | subelements("hosts")) - + (prometheus_target_exporter | selectattr("hosts", "undefined") | product([""])) }}' + loop: '{{ prometheus_target_exporter }}' notify: - Run command hook - Run shell hook -- cgit v1.2.3