From c9c812343831be1bb56965b2aeff41eecdae0a11 Mon Sep 17 00:00:00 2001 From: Colin Wilk Date: Wed, 11 Oct 2023 15:34:10 +0200 Subject: Add run_once option for handlers This adds the run_once option for the two handler types (shell and command). The variables `prometheus_target_handler_command_run_once` and `prometheus_target_handler_shell_run_once` are introduced to control this behavior. For this change a switch from the Ansible Handlers to regular tasks was necessary to enforce run_once behavior with delegated hosts. If you don't rely on handler specific features such as deferring, nothing changes when using the role. Signed-off-by: Colin Wilk --- tasks/lineinfile.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tasks/lineinfile.yml') diff --git a/tasks/lineinfile.yml b/tasks/lineinfile.yml index 0367be9..8c60ba0 100644 --- a/tasks/lineinfile.yml +++ b/tasks/lineinfile.yml @@ -17,6 +17,8 @@ delegate_to: '{{ prometheus_target_host }}' loop: '{{ prometheus_target_exporter + ([] if prometheus_target_skip_default_exporters else prometheus_target_default_exporters) }}' - notify: - - Run command hook - - Run shell hook + register: lineinfile + +- name: Export fact + ansible.builtin.set_fact: + changed: '{{ changed or lineinfile.changed }}' -- cgit v1.2.3