From f162990cb3677ad19c138a8700c39e5e656cfd81 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Tue, 1 Sep 2015 17:33:14 -0400 Subject: [PATCH] Properly assign the searchpath for templates to the environment loader dbd755e0 previously assigned the value to self._templar.environment.searchpath, which is incorrect - it needs to be assigned to the environment.loader.searchpath value instead. Fixes #11931 --- lib/ansible/plugins/action/template.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/ansible/plugins/action/template.py b/lib/ansible/plugins/action/template.py index 7a68375a447..a057e9262c9 100644 --- a/lib/ansible/plugins/action/template.py +++ b/lib/ansible/plugins/action/template.py @@ -111,10 +111,14 @@ class ActionModule(ActionBase): time.localtime(os.path.getmtime(source)) ) - self._templar.environment.searchpath = [self._loader._basedir, os.path.dirname(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 = [self._loader._basedir, os.path.dirname(source)] if self._task._role is not None: - self._templar.environment.searchpath.insert(1, C.DEFAULT_ROLES_PATH) - self._templar.environment.searchpath.insert(1, self._task._role._role_path) + searchpath.insert(1, C.DEFAULT_ROLES_PATH) + searchpath.insert(1, self._task._role._role_path) + + self._templar.environment.loader.searchpath = searchpath old_vars = self._templar._available_variables self._templar.set_available_variables(temp_vars)