summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToshio Kuratomi <toshio@fedoraproject.org>2015-10-29 12:18:47 -0700
committerToshio Kuratomi <toshio@fedoraproject.org>2015-10-29 12:44:02 -0700
commiteaa183035386e5521d22d51d41912a69c21e27d0 (patch)
tree2aeef988f16081b17f12de9c36ad87b129c6c6a5
parent56b310b18dba85c396048251989952c9665c2209 (diff)
downloadansible-conditionals-before-templating.tar.gz
Move evaluation of conditionals to happen before templatingconditionals-before-templating
Fixes #12774
-rw-r--r--lib/ansible/executor/task_executor.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py
index 2fdc1e9b56..a8b7d42316 100644
--- a/lib/ansible/executor/task_executor.py
+++ b/lib/ansible/executor/task_executor.py
@@ -259,18 +259,6 @@ class TaskExecutor:
templar = Templar(loader=self._loader, shared_loader_obj=self._shared_loader_obj, variables=variables)
- # apply the given task's information to the connection info,
- # which may override some fields already set by the play or
- # the options specified on the command line
- self._play_context = self._play_context.set_task_and_variable_override(task=self._task, variables=variables, templar=templar)
-
- # fields set from the play/task may be based on variables, so we have to
- # do the same kind of post validation step on it here before we use it.
- # We also add "magic" variables back into the variables dict to make sure
- # a certain subset of variables exist.
- self._play_context.update_vars(variables)
- self._play_context.post_validate(templar=templar)
-
# Evaluate the conditional (if any) for this task, which we do before running
# the final task post-validation. We do this before the post validation due to
# the fact that the conditional may specify that the task be skipped due to a
@@ -284,6 +272,19 @@ class TaskExecutor:
if self._task.action != 'include':
raise
+ # apply the given task's information to the connection info,
+ # which may override some fields already set by the play or
+ # the options specified on the command line
+ self._play_context = self._play_context.set_task_and_variable_override(task=self._task, variables=variables, templar=templar)
+
+ # fields set from the play/task may be based on variables, so we have to
+ # do the same kind of post validation step on it here before we use it.
+ # We also add "magic" variables back into the variables dict to make sure
+ # a certain subset of variables exist.
+ self._play_context.update_vars(variables)
+ self._play_context.post_validate(templar=templar)
+
+
# if this task is a TaskInclude, we just return now with a success code so the
# main thread can expand the task list for the given host
if self._task.action == 'include':