aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/molecule
diff options
context:
space:
mode:
Diffstat (limited to 'molecule')
-rw-r--r--molecule/default/converge.yml12
-rw-r--r--molecule/default/molecule.yml9
-rw-r--r--molecule/default/tests/test_check_prometheus_targets.py14
3 files changed, 26 insertions, 9 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
################################################################################
diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml
index a8623d0..de1ac40 100644
--- a/molecule/default/molecule.yml
+++ b/molecule/default/molecule.yml
@@ -20,6 +20,15 @@ platforms:
com.docker.network.driver.mtu: 1420
networks:
- name: molecule-container-net
+ groups: [application_group]
+
+ - name: application2
+ image: ${MOLECULE_DISTRO:-debian:10}
+ dockerfile: Dockerfile.j2
+ pre_build_image: false
+ networks:
+ - name: molecule-container-net
+ groups: [application_group]
- name: prometheus
image: ${MOLECULE_DISTRO:-debian:10}
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