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 --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index 0cfe278..3a1c3a9 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,10 @@ You can enable or disable the handlers via the `prometheus_target_handler_comman behavior via `prometheus_target_handler_command_become*`/ `prometheus_target_handler_shell_become*`. +To run the hook per play instead of per hosts, meaning it only runs once, you +can set the `prometheus_target_handler_command_run_once` / +`prometheus_target_handler_shell_run_once` hooks to `true`. + The `prometheus_target_handler_command` and `prometheus_target_handler_shell` variables map the options of their respective Ansible [command](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/command_module.html) @@ -153,12 +157,14 @@ prometheus_target_handler_command_enabled: false prometheus_target_handler_command_become: true # prometheus_target_handler_command_become_method: # prometheus_target_handler_command_become_user: +prometheus_target_handler_command_run_once: false prometheus_target_handler_command: {} prometheus_target_handler_shell_enabled: false prometheus_target_handler_shell_become: true # prometheus_target_handler_shell_become_method: # prometheus_target_handler_shell_become_user: +prometheus_target_handler_shell_run_once: false prometheus_target_handler_shell: {} ``` -- cgit v1.2.3