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 --- defaults/main.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'defaults/main.yml') diff --git a/defaults/main.yml b/defaults/main.yml index 0a8e9ba..807f507 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -31,6 +31,14 @@ prometheus_target_handler_command_become: true # prometheus_target_handler_command_become_method: # prometheus_target_handler_command_become_user: +# By default the target handler will run for every host added on the delegated +# host. This means that if you add 20 hosts as your target, you will run the +# handler 20 times on your delegated host. This is useful if you need some host +# specific variables to run on the delegated host however often times, such as +# when using it to create a commit in a repository, you only need to do it once +# per run and not per host. +prometheus_target_handler_command_run_once: false + # This is the configuration for the command module. For documentation see: # https://docs.ansible.com/ansible/latest/collections/ansible/builtin/command_module.html # --- @@ -55,6 +63,10 @@ prometheus_target_handler_shell_become: true # prometheus_target_handler_shell_become_method: # prometheus_target_handler_shell_become_user: +# This will configure the shell handler to run once. +# See documentation for prometheus_target_handler_command_run_once above. +prometheus_target_handler_shell_run_once: false + # This is the configuration for the shell module. For documentation see: # https://docs.ansible.com/ansible/latest/collections/ansible/builtin/shell_module.html # --- -- cgit v1.2.3