tests: checks that handlers work with loops

This commit is contained in:
Pierre-Louis Bonicoli
2015-07-20 14:11:31 +02:00
parent a09ce4bd87
commit aa23ea8462
4 changed files with 20 additions and 2 deletions

View File

@@ -1,3 +1,5 @@
- name: set handler fact
set_fact:
handler_called: True
- name: test handler
debug: msg="handler called"

View File

@@ -20,19 +20,33 @@
- name: reset handler_called variable to false for all hosts
set_fact:
handler_called: False
tags: scenario1
- name: notify the handler for host A only
shell: echo
notify:
- set handler fact
when: inventory_hostname == 'A'
tags: scenario1
- name: force handler execution now
meta: "flush_handlers"
tags: scenario1
- debug: var=handler_called
tags: scenario1
- name: validate the handler only ran on one host
assert:
that:
- "inventory_hostname == 'A' and handler_called == True or handler_called == False"
tags: scenario1
- name: 'test notify with loop'
debug: msg='a task'
changed_when: item == 1
notify: test handler
with_items:
- 1
- 2
tags: scenario2