aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/molecule/default/converge.yml
diff options
context:
space:
mode:
authorColin Wilk <colin.wilk@tum.de>2023-10-11 15:34:10 +0200
committerColin Wilk <colin.wilk@tum.de>2023-10-11 15:49:45 +0200
commitc9c812343831be1bb56965b2aeff41eecdae0a11 (patch)
tree4a5eec53821831cfc746788f631e8b283bfebe3b /molecule/default/converge.yml
parent6da60ee68e98d97f2c58ea7dca39d85c9b81370b (diff)
downloadansible-role-prometheus-target-c9c812343831be1bb56965b2aeff41eecdae0a11.tar.gz
ansible-role-prometheus-target-c9c812343831be1bb56965b2aeff41eecdae0a11.zip
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 <colin.wilk@tum.de>
Diffstat (limited to 'molecule/default/converge.yml')
-rw-r--r--molecule/default/converge.yml12
1 files changed, 6 insertions, 6 deletions
diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml
index 9346988..cb6a281 100644
--- a/molecule/default/converge.yml
+++ b/molecule/default/converge.yml
@@ -83,7 +83,7 @@
################################################################################
################################################################################
- name: Deploy with hooks
- hosts: application
+ hosts: application_group
pre_tasks:
- name: Create targets
ansible.builtin.file:
@@ -96,23 +96,23 @@
delegate_to: '{{ prometheus_target_host }}'
loop:
- /opt/hook_target.yml
- - /opt/hook1
- - /opt/hook1
+ - /opt/hook2
vars:
prometheus_target_host: prometheus
prometheus_target_handler_command_enabled: true
prometheus_target_handler_command:
- cmd: touch /opt/hook1
+ cmd: mkdir /opt/hook1 # Fails if run twice
+ prometheus_target_handler_command_run_once: true
prometheus_target_handler_shell_enabled: true
prometheus_target_handler_shell:
- cmd: touch /opt/hook2
+ cmd: echo hello >> /opt/hook2
roles:
- role: kliwniloc.prometheus_target
prometheus_target_exporter:
- id: node_exporter
- host: application
+ host: '{{ inventory_hostname }}'
path: /opt/hook_target.yml
################################################################################