Fix regression in jinja2 include search path

Since commit 3c39bb5, the 'ansible_search_path' variable is used to set
jinja2's search path for {% include %} directives. However, this path is
the the proper one because our templates live in 'templates' subdirs in
our search path.

This is a regression because previously, our include search path would
include the dirname of the currently interpreted file, which worked most
of the time.

fixes #18526
pull/18617/head
Virgil Dupras 8 years ago
parent b606078d69
commit c96c8532c8

@ -49,6 +49,9 @@ class LookupModule(LookupBase):
# set jinja2 internal search path for includes
if 'ansible_search_path' in variables:
searchpath = variables['ansible_search_path']
# our search paths aren't actually the proper ones for jinja includes.
# We want to search into the 'templates' subdir of each search path.
searchpath = [os.path.join(p, 'templates') for p in searchpath]
else:
searchpath = [self._loader._basedir, os.path.dirname(lookupfile)]
self._templar.environment.loader.searchpath = searchpath

Loading…
Cancel
Save