Properly assign search path to environment.loader in template lookup

Same fix as was applied in f162990c to the action plugin

Fixes #12355
This commit is contained in:
James Cammarata 2015-09-17 14:47:20 -04:00
parent bde5ed9672
commit c95d4ca05f

View file

@ -40,11 +40,12 @@ class LookupModule(LookupBase):
with open(lookupfile, 'r') as f:
template_data = f.read()
self._templar.environment.searchpath = [self._loader._basedir, os.path.dirname(lookupfile)]
searchpath = [self._loader._basedir, os.path.dirname(lookupfile)]
if 'role_path' in variables:
self._templar.environment.searchpath.insert(1, C.DEFAULT_ROLES_PATH)
self._templar.environment.searchpath.insert(1, variables['role_path'])
searchpath.insert(1, C.DEFAULT_ROLES_PATH)
searchpath.insert(1, variables['role_path'])
self._templar.environment.loader.searchpath = searchpath
res = self._templar.template(template_data, preserve_trailing_newlines=True)
ret.append(res)
else: