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/main.yml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tasks/main.yml') diff --git a/tasks/main.yml b/tasks/main.yml index 158191d..f8d6caa 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,3 +2,10 @@ - name: Select strategy ansible.builtin.include_tasks: file: '{{ prometheus_target_strategy }}.yml' + vars: + changed: false + +- name: Run handlers + ansible.builtin.include_tasks: + file: handlers.yml + when: changed -- cgit v1.2.3