mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
correct template lookup path
now all paths get 'templates/'
This commit is contained in:
parent
60a1e719c8
commit
ed933421fe
1 changed files with 16 additions and 7 deletions
|
@ -115,13 +115,22 @@ class ActionModule(ActionBase):
|
||||||
time.localtime(os.path.getmtime(b_source))
|
time.localtime(os.path.getmtime(b_source))
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create a new searchpath list to assign to the templar environment's file
|
|
||||||
# loader, so that it knows about the other paths to find template files
|
searchpath = []
|
||||||
searchpath = [self._loader._basedir, os.path.dirname(source)]
|
# set jinja2 internal search path for includes
|
||||||
if self._task._role is not None:
|
if 'ansible_search_path' in task_vars:
|
||||||
if C.DEFAULT_ROLES_PATH:
|
searchpath = task_vars['ansible_search_path']
|
||||||
searchpath[:0] = C.DEFAULT_ROLES_PATH
|
# our search paths aren't actually the proper ones for jinja includes.
|
||||||
searchpath.insert(1, self._task._role._role_path)
|
|
||||||
|
searchpath.extend([self._loader._basedir, os.path.dirname(source)])
|
||||||
|
|
||||||
|
# We want to search into the 'templates' subdir of each search path in
|
||||||
|
# addition to our original search paths.
|
||||||
|
newsearchpath = []
|
||||||
|
for p in searchpath:
|
||||||
|
newsearchpath.append(os.path.join(p, 'templates'))
|
||||||
|
newsearchpath.append(p)
|
||||||
|
searchpath = newsearchpath
|
||||||
|
|
||||||
self._templar.environment.loader.searchpath = searchpath
|
self._templar.environment.loader.searchpath = searchpath
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue