include_role: expose vars from parent roles to role's handlers (#81524)

* include_role: expose vars from parent roles to role's handlers

Fixes #80459
pull/81543/head
Martin Krizek 10 months ago committed by GitHub
parent a2673cb564
commit 98f1627817
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- include_role - expose variables from parent roles to role's handlers (https://github.com/ansible/ansible/issues/80459)

@ -113,7 +113,7 @@ class IncludeRole(TaskInclude):
b.collections = actual_role.collections
# updated available handlers in play
handlers = actual_role.get_handler_blocks(play=myplay)
handlers = actual_role.get_handler_blocks(play=myplay, dep_chain=dep_chain)
for h in handlers:
h._parent = p_block
myplay.handlers = myplay.handlers + handlers

@ -190,3 +190,5 @@ ansible-playbook test_include_role_handler_once.yml -i inventory.handlers "$@" 2
ansible-playbook test_listen_role_dedup.yml "$@" 2>&1 | tee out.txt
[ "$(grep out.txt -ce 'a handler from a role')" = "1" ]
ansible localhost -m include_role -a "name=r1-dep_chain-vars" "$@"

Loading…
Cancel
Save