Make sure vars in debug tasks aren't templated too early

If the syntax var={{something}} is used, that can be templated too
early in the post_validation, leading the debug module to fail when it
tries to template the same value in turn.
This commit is contained in:
James Cammarata 2015-07-05 01:06:54 -04:00
parent 38cc54b717
commit 9155af20e3

View file

@ -231,9 +231,18 @@ class TaskExecutor:
debug("when evaulation failed, skipping this task")
return dict(changed=False, skipped=True, skip_reason='Conditional check failed')
# Now we do final validation on the task, which sets all fields to their final values
# Now we do final validation on the task, which sets all fields to their final values.
# In the case of debug tasks, we save any 'var' params and restore them after validating
# so that variables are not replaced too early.
prev_var = None
if self._task.action == 'debug' and 'var' in self._task.args:
prev_var = self._task.args.pop('var')
self._task.post_validate(templar=templar)
if prev_var is not None:
self._task.args['var'] = prev_var
# 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':