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 --- molecule/default/tests/test_check_prometheus_targets.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'molecule/default/tests') diff --git a/molecule/default/tests/test_check_prometheus_targets.py b/molecule/default/tests/test_check_prometheus_targets.py index ddf3a22..2eeb21b 100644 --- a/molecule/default/tests/test_check_prometheus_targets.py +++ b/molecule/default/tests/test_check_prometheus_targets.py @@ -58,12 +58,20 @@ def test_check_hosts_added_hooks(host): t2 = host.file('/opt/hook1') t3 = host.file('/opt/hook2') - assert t1.content_string == \ - ' - application\n' - + assert t1.exists assert t2.exists assert t3.exists + assert t1.content_string == \ + ' - application\n' \ + ' - application2\n' \ + or t1.content_string == \ + ' - application2\n' \ + ' - application\n' + + assert t3.content_string == \ + 'hello\n' \ + 'hello\n' """ Test lineinfile strategy parameters -- cgit v1.2.3