summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Cammarata <jimi@sngx.net>2015-08-03 12:12:45 -0400
committerJames Cammarata <jimi@sngx.net>2015-08-03 12:12:45 -0400
commitc2435fab7edf39ef5f36d924bee33cb37dd0795d (patch)
tree2051f8d0ce1239a49ef6f5900f1466a42578f207
parentbcbcfc79be6a58ed33d831c6038a40334ebdc8d1 (diff)
downloadansible-c2435fab7edf39ef5f36d924bee33cb37dd0795d.tar.gz
Inject the play context vars into the variables used for loop item templating
-rw-r--r--lib/ansible/executor/task_executor.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py
index f83f901e90..b317c72cb5 100644
--- a/lib/ansible/executor/task_executor.py
+++ b/lib/ansible/executor/task_executor.py
@@ -141,10 +141,18 @@ class TaskExecutor:
and returns the items result.
'''
+ # create a copy of the job vars here so that we can modify
+ # them temporarily without changing them too early for other
+ # parts of the code that might still need a pristine version
+ vars_copy = self._job_vars.copy()
+
+ # now we update them with the play context vars
+ self._play_context.update_vars(vars_copy)
+
items = None
if self._task.loop and self._task.loop in lookup_loader:
- loop_terms = listify_lookup_plugin_terms(terms=self._task.loop_args, variables=self._job_vars, loader=self._loader, fail_on_undefined=True)
- items = lookup_loader.get(self._task.loop, loader=self._loader).run(terms=loop_terms, variables=self._job_vars)
+ loop_terms = listify_lookup_plugin_terms(terms=self._task.loop_args, variables=vars_copy, loader=self._loader, fail_on_undefined=True)
+ items = lookup_loader.get(self._task.loop, loader=self._loader).run(terms=loop_terms, variables=vars_copy)
return items