From c95d4ca05f5f50f8b38f90be89f0395ae735edec Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Thu, 17 Sep 2015 14:47:20 -0400 Subject: [PATCH] Properly assign search path to environment.loader in template lookup Same fix as was applied in f162990c to the action plugin Fixes #12355 --- lib/ansible/plugins/lookup/template.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/ansible/plugins/lookup/template.py b/lib/ansible/plugins/lookup/template.py index 16b86c2de5b..5fc10d7f52f 100644 --- a/lib/ansible/plugins/lookup/template.py +++ b/lib/ansible/plugins/lookup/template.py @@ -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: