mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
FIX: multiple nested tasks include levels (#35165)
* Test for include_tasks & include_role bug Related to ansible/ansible:#21890 * Fix nested include_tasks called from role This fixes the path of included files when you want to call include_task inside a role's task file and this role is itself called from multiple level of playbook include_tasks Related to ansible/ansible:#21890 This fixes ansible/ansible:#35109
This commit is contained in:
parent
984edacd2a
commit
9001a8794f
28 changed files with 77 additions and 1 deletions
|
@ -109,7 +109,16 @@ class IncludedFile:
|
|||
include_target = templar.template(include_result['include'])
|
||||
if original_task._role:
|
||||
new_basedir = os.path.join(original_task._role._role_path, 'tasks', cumulative_path)
|
||||
include_file = loader.path_dwim_relative(new_basedir, 'tasks', include_target)
|
||||
candidates = [loader.path_dwim_relative(original_task._role._role_path, 'tasks', include_target),
|
||||
loader.path_dwim_relative(new_basedir, 'tasks', include_target)]
|
||||
for include_file in candidates:
|
||||
try:
|
||||
# may throw OSError
|
||||
os.stat(include_file)
|
||||
# or select the task file if it exists
|
||||
break
|
||||
except OSError:
|
||||
pass
|
||||
else:
|
||||
include_file = loader.path_dwim_relative(loader.get_basedir(), cumulative_path, include_target)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue