mirror of
https://github.com/ansible/ansible.git
synced 2026-08-03 00:22:10 +02:00
Fix task-adjacent search path in roles (#83621)
* Restore search path in the current task file’s directory for roles
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
bugfixes:
|
||||
- Fix using the current task's directory for looking up relative paths within roles (https://github.com/ansible/ansible/issues/82695).
|
||||
@@ -329,11 +329,10 @@ class DataLoader:
|
||||
if (is_role or self._is_role(path)) and b_pb_base_dir.endswith(b'/tasks'):
|
||||
search.append(os.path.join(os.path.dirname(b_pb_base_dir), b_dirname, b_source))
|
||||
search.append(os.path.join(b_pb_base_dir, b_source))
|
||||
else:
|
||||
# don't add dirname if user already is using it in source
|
||||
if b_source.split(b'/')[0] != dirname:
|
||||
search.append(os.path.join(b_upath, b_dirname, b_source))
|
||||
search.append(os.path.join(b_upath, b_source))
|
||||
# don't add dirname if user already is using it in source
|
||||
if b_source.split(b'/')[0] != dirname:
|
||||
search.append(os.path.join(b_upath, b_dirname, b_source))
|
||||
search.append(os.path.join(b_upath, b_source))
|
||||
|
||||
# always append basedir as last resort
|
||||
# don't add dirname if user already is using it in source
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
- include_tasks: subdir/main.yml
|
||||
@@ -0,0 +1,7 @@
|
||||
- assert:
|
||||
that:
|
||||
- "lookup('first_found', task_adjacent) is is_file"
|
||||
vars:
|
||||
task_adjacent:
|
||||
- files:
|
||||
- relative
|
||||
@@ -152,3 +152,7 @@
|
||||
assert:
|
||||
that:
|
||||
- q('first_found', ['/nonexistant'], skip=True) == []
|
||||
|
||||
- name: Test relative paths in roles
|
||||
include_role:
|
||||
role: "{{ role_path }}/roles/a"
|
||||
|
||||
Reference in New Issue
Block a user