Allow include_tasks handlers for searching role subdirs (#82248)

Fixes #82241
pull/82269/head
Martin Krizek 6 months ago committed by GitHub
parent a4b00793be
commit d664f13b4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- Fix issue where an ``include_tasks`` handler in a role was not able to locate a file in ``tasks/`` when ``tasks_from`` was used as a role entry point and ``main.yml`` was not present (https://github.com/ansible/ansible/issues/82241)

@ -147,8 +147,8 @@ class IncludedFile:
dirname = 'handlers' if isinstance(original_task, Handler) else 'tasks'
new_basedir = os.path.join(original_task._role._role_path, dirname, cumulative_path)
candidates = [
loader.path_dwim_relative(original_task._role._role_path, dirname, include_target),
loader.path_dwim_relative(new_basedir, dirname, include_target)
loader.path_dwim_relative(original_task._role._role_path, dirname, include_target, is_role=True),
loader.path_dwim_relative(new_basedir, dirname, include_target, is_role=True)
]
for include_file in candidates:
try:

@ -0,0 +1,6 @@
- hosts: A
gather_facts: false
tasks:
- import_role:
name: role-82241
tasks_from: entry_point.yml

@ -0,0 +1,2 @@
- name: handler
include_tasks: included_tasks.yml

@ -210,3 +210,6 @@ ansible-playbook force_handlers_blocks_81533-2.yml -i inventory.handlers "$@" 2>
ansible-playbook nested_flush_handlers_failure_force.yml -i inventory.handlers "$@" 2>&1 | tee out.txt
[ "$(grep out.txt -ce 'flush_handlers_rescued')" = "1" ]
[ "$(grep out.txt -ce 'flush_handlers_always')" = "2" ]
ansible-playbook 82241.yml -i inventory.handlers "$@" 2>&1 | tee out.txt
[ "$(grep out.txt -ce 'included_task_from_tasks_dir')" = "1" ]

Loading…
Cancel
Save