2014-03-25 18:32:11 +01:00
|
|
|
---
|
|
|
|
- name: run handlers
|
|
|
|
hosts: A
|
|
|
|
gather_facts: False
|
|
|
|
connection: local
|
|
|
|
roles:
|
2015-07-20 14:11:31 +02:00
|
|
|
- { role: test_handlers_meta, tags: ['scenario1'] }
|
2014-03-25 18:32:11 +01:00
|
|
|
|
|
|
|
- name: verify final handler was run
|
|
|
|
hosts: A
|
|
|
|
gather_facts: False
|
|
|
|
connection: local
|
|
|
|
tasks:
|
|
|
|
- name: verify handler2 ran
|
2016-04-18 16:47:38 +02:00
|
|
|
assert:
|
2014-03-25 18:32:11 +01:00
|
|
|
that:
|
|
|
|
- "not hostvars[inventory_hostname]['handler1_called']"
|
|
|
|
- "'handler2_called' in hostvars[inventory_hostname]"
|
2015-07-20 14:11:31 +02:00
|
|
|
tags: ['scenario1']
|
2014-03-25 18:32:11 +01:00
|
|
|
|
2016-11-13 08:26:43 +01:00
|
|
|
- name: verify listening handlers
|
|
|
|
hosts: A
|
|
|
|
gather_facts: False
|
|
|
|
connection: local
|
|
|
|
tasks:
|
|
|
|
- name: notify some handlers
|
|
|
|
command: echo foo
|
|
|
|
notify:
|
|
|
|
- notify_listen
|
|
|
|
post_tasks:
|
|
|
|
- name: assert all defined handlers ran without error
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "notify_listen_ran_1 is defined"
|
|
|
|
- "notify_listen_ran_2 is defined"
|
|
|
|
handlers:
|
|
|
|
- name: first listening handler has a name
|
|
|
|
set_fact:
|
|
|
|
notify_listen_ran_1: True
|
|
|
|
listen: notify_listen
|
|
|
|
# second listening handler does not
|
|
|
|
- set_fact:
|
|
|
|
notify_listen_ran_2: True
|
|
|
|
listen: notify_listen
|
|
|
|
|
2014-05-27 17:55:09 +02:00
|
|
|
- name: test handlers
|
|
|
|
hosts: testgroup
|
|
|
|
gather_facts: False
|
|
|
|
connection: local
|
|
|
|
roles:
|
|
|
|
- { role: test_handlers }
|