mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-27 07:01:22 -07:00
Allow with_first_files to search relative to templates and vars in roles
Fixes #8879
This commit is contained in:
parent
f7b5b85743
commit
da5de725d7
1 changed files with 11 additions and 4 deletions
|
@ -172,14 +172,21 @@ class LookupModule(object):
|
||||||
else:
|
else:
|
||||||
total_search = terms
|
total_search = terms
|
||||||
|
|
||||||
result = None
|
|
||||||
for fn in total_search:
|
for fn in total_search:
|
||||||
|
if inject and '_original_file' in inject:
|
||||||
|
# check the templates and vars directories too,
|
||||||
|
# if they exist
|
||||||
|
for roledir in ('templates', 'vars'):
|
||||||
|
path = utils.path_dwim(os.path.join(self.basedir, '..', roledir), fn)
|
||||||
|
if os.path.exists(path):
|
||||||
|
return [path]
|
||||||
|
# if none of the above were found, just check the
|
||||||
|
# current filename against the basedir (this will already
|
||||||
|
# have ../files from runner, if it's a role task
|
||||||
path = utils.path_dwim(self.basedir, fn)
|
path = utils.path_dwim(self.basedir, fn)
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
return [path]
|
return [path]
|
||||||
|
else:
|
||||||
|
|
||||||
if not result:
|
|
||||||
if skip:
|
if skip:
|
||||||
return []
|
return []
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue