Do not allow addressing an import from handlers via notify. Fixes #48936 (#49317)

pull/49258/head
Matt Martz 6 years ago committed by GitHub
parent 7f04ee1eb4
commit 77befcf5d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,4 @@
bugfixes:
- imports - Prevent the name of an import from being addressable as a handler, only the tasks within should
be addressable. Use an include instead of an import if you need to execute many tasks from a single handler
(https://github.com/ansible/ansible/issues/48936)

@ -402,7 +402,7 @@ class StrategyBase:
def parent_handler_match(target_handler, handler_name):
if target_handler:
if isinstance(target_handler, (TaskInclude, IncludeRole)):
if isinstance(target_handler, (TaskInclude, IncludeRole)) and not getattr(target_handler, 'statically_loaded', True):
try:
handler_vars = self._variable_manager.get_vars(play=iterator._play, task=target_handler)
templar = Templar(loader=self._loader, variables=handler_vars)

@ -0,0 +1,11 @@
- hosts: localhost
gather_facts: false
tasks:
- import_role:
name: include_handler_test
- hosts: localhost
gather_facts: false
tasks:
- import_role:
name: import_handler_test

@ -86,3 +86,7 @@ ansible-playbook public_exposure/no_overwrite_roles.yml -i ../../inventory "$@"
# https://github.com/ansible/ansible/pull/48068
ansible-playbook run_once/playbook.yml "$@"
# https://github.com/ansible/ansible/issues/48936
ansible-playbook -v handler_addressing/playbook.yml 2>&1 | tee test_handler_addressing.out
test "$(egrep -c 'include handler task|ERROR! The requested handler '"'"'do_import'"'"' was not found' test_handler_addressing.out)" = 2

Loading…
Cancel
Save