mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 22:00:22 -07:00
Alternately track listening handlers by uuid if no name is set
Fixes #17846
This commit is contained in:
parent
527d8307c1
commit
4f06a86161
5 changed files with 85 additions and 19 deletions
|
@ -3,6 +3,7 @@
|
|||
set -eux
|
||||
|
||||
ansible-playbook test_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 \
|
||||
| egrep -o 'RUNNING HANDLER \[test_handlers : .*?]')" = "RUNNING HANDLER [test_handlers : test handler]" ]
|
||||
|
|
|
@ -18,6 +18,31 @@
|
|||
- "'handler2_called' in hostvars[inventory_hostname]"
|
||||
tags: ['scenario1']
|
||||
|
||||
- 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
|
||||
|
||||
- name: test handlers
|
||||
hosts: testgroup
|
||||
gather_facts: False
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
- 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
|
Loading…
Add table
Add a link
Reference in a new issue