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 --- handlers/main.yml | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 handlers/main.yml (limited to 'handlers/main.yml') diff --git a/handlers/main.yml b/handlers/main.yml deleted file mode 100644 index 8b77084..0000000 --- a/handlers/main.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -- name: Run command hook # noqa inline-env-var - ansible.builtin.command: - argv: '{{ prometheus_target_handler_command.argv | default(omit) }}' - chdir: '{{ prometheus_target_handler_command.chdir | default(omit) }}' - cmd: '{{ prometheus_target_handler_command.cmd | default(omit) }}' - creates: '{{ prometheus_target_handler_command.creates | default(omit) }}' - free_form: '{{ prometheus_target_handler_command.free_form | default(omit) }}' - removes: '{{ prometheus_target_handler_command.removes | default(omit) }}' - stdin: '{{ prometheus_target_handler_command.stdin | default(omit) }}' - stdin_add_newline: '{{ prometheus_target_handler_command.stdin_add_newline | default(omit) }}' - become: '{{ prometheus_target_handler_command_become }}' - become_method: '{{ prometheus_target_handler_command_become_method | default(omit) }}' - become_user: '{{ prometheus_target_handler_command_become_user | default(omit) }}' - delegate_to: '{{ prometheus_target_host }}' - when: prometheus_target_handler_command_enabled - -- name: Run shell hook - ansible.builtin.shell: - chdir: '{{ prometheus_target_handler_shell.chdir | default(omit) }}' - cmd: '{{ prometheus_target_handler_shell.cmd | default(omit) }}' - creates: '{{ prometheus_target_handler_shell.creates | default(omit) }}' - executable: '{{ prometheus_target_handler_shell.executable | default(omit) }}' - free_form: '{{ prometheus_target_handler_shell.free_form | default(omit) }}' - removes: '{{ prometheus_target_handler_shell.removes | default(omit) }}' - stdin: '{{ prometheus_target_handler_shell.stdin | default(omit) }}' - stdin_add_newline: '{{ prometheus_target_handler_shell.stdin_add_newline | default(omit) }}' - become: '{{ prometheus_target_handler_shell_become }}' - become_method: '{{ prometheus_target_handler_shell_become_method | default(omit) }}' - become_user: '{{ prometheus_target_handler_shell_become_user | default(omit) }}' - delegate_to: '{{ prometheus_target_host }}' - when: prometheus_target_handler_shell_enabled -- cgit v1.2.3