added handlers_from (#49220)

* added handlers_from

fixes #46769
This commit is contained in:
Brian Coca
2018-12-18 11:28:24 -05:00
committed by GitHub
parent 1e415899ad
commit 88c87a3583
8 changed files with 72 additions and 2 deletions

View File

@@ -0,0 +1,41 @@
- name: verify handlers_from on include_role
hosts: A
gather_facts: False
connection: local
tags: ['scenario1']
tasks:
- name: test include_role
include_role: name=test_handlers_meta handlers_from=alternate.yml
- name: force handler run
meta: flush_handlers
- name: verify handlers ran
assert:
that:
- "'handler1_alt_called' in hostvars[inventory_hostname]"
- "'handler2_alt_called' in hostvars[inventory_hostname]"
tags: ['scenario1']
- name: verify handlers_from on import_role
hosts: A
gather_facts: False
connection: local
tasks:
- name: set facts to false
set_fact:
handler1_alt_called: False
handler2_alt_called: False
- import_role: name=test_handlers_meta handlers_from=alternate.yml
- name: force handler run
meta: flush_handlers
- name: verify handlers ran
assert:
that:
- handler1_alt_called|bool
- handler2_alt_called|bool
tags: ['scenario1']

View File

@@ -0,0 +1,12 @@
- name: set_handler_fact_1
set_fact:
handler1_called: True
handler1_alt_called: True
- name: set_handler_fact_2
set_fact:
handler2_called: True
handler2_alt_called: True
- name: count_handler
shell: echo . >> {{ handler_countpath }}

View File

@@ -2,7 +2,12 @@
set -eux
# simple handler test
ansible-playbook test_handlers.yml -i inventory.handlers -v "$@" --tags scenario1
# simple from_handlers test
ansible-playbook from_handlers.yml -i inventory.handlers -v "$@" --tags scenario1
ansible-playbook test_listening_handlers.yml -i inventory.handlers -v "$@"
[ "$(ansible-playbook test_handlers.yml -i inventory.handlers -v "$@" --tags scenario2 -l A \