Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/80459-handlers-nested-includes-vars.yml
@@ -0,0 +1,2 @@
bugfixes:
- include_role - expose variables from parent roles to role's handlers (https://github.com/ansible/ansible/issues/80459)
2 changes: 1 addition & 1 deletion lib/ansible/playbook/role_include.py
Expand Up @@ -113,7 +113,7 @@ def get_block_list(self, play=None, variable_manager=None, loader=None):
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
Expand Down
@@ -0,0 +1 @@
v: foo
@@ -0,0 +1,2 @@
- include_role:
name: r2-dep_chain-vars
@@ -0,0 +1,4 @@
- name: h
assert:
that:
- v is defined
@@ -0,0 +1,2 @@
- command: echo
notify: h
2 changes: 2 additions & 0 deletions test/integration/targets/handlers/runme.sh
Expand Up @@ -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" "$@"