Fix searchpath in the template lookup (#50488)

pull/49819/head
Martin Krizek 6 years ago committed by GitHub
parent 98b0ef370d
commit 82c95e07b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- Fix searchpath in the template lookup to work the same way as in the template module.

@ -77,7 +77,7 @@ class LookupModule(LookupBase):
template_data = to_text(f.read(), errors='surrogate_or_strict')
# set jinja2 internal search path for includes
searchpath = variables.get('ansible_search_path')
searchpath = variables.get('ansible_search_path', [])
if searchpath:
# our search paths aren't actually the proper ones for jinja includes.
# We want to search into the 'templates' subdir of each search path in
@ -87,8 +87,8 @@ class LookupModule(LookupBase):
newsearchpath.append(os.path.join(p, 'templates'))
newsearchpath.append(p)
searchpath = newsearchpath
else:
searchpath = [self._loader._basedir, os.path.dirname(lookupfile)]
searchpath.insert(0, os.path.dirname(lookupfile))
self._templar.environment.loader.searchpath = searchpath
if variable_start_string is not None:
self._templar.environment.variable_start_string = variable_start_string

Loading…
Cancel
Save