From fc3a44485b4d6ac9549a4b5fc236bd42f2f77127 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 21 Oct 2015 23:14:27 -0400 Subject: [PATCH] skip errors on conditional if task is include fixes #12843 --- lib/ansible/executor/task_executor.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py index 0ce9564887..ba4eac9917 100644 --- a/lib/ansible/executor/task_executor.py +++ b/lib/ansible/executor/task_executor.py @@ -275,9 +275,14 @@ class TaskExecutor: # 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 # variable not being present which would otherwise cause validation to fail - if not self._task.evaluate_conditional(templar, variables): - self._display.debug("when evaluation failed, skipping this task") - return dict(changed=False, skipped=True, skip_reason='Conditional check failed', _ansible_no_log=self._play_context.no_log) + try: + if not self._task.evaluate_conditional(templar, variables): + self._display.debug("when evaluation failed, skipping this task") + return dict(changed=False, skipped=True, skip_reason='Conditional check failed', _ansible_no_log=self._play_context.no_log) + except AnsibleError: + # skip conditional exception in the case of includes as the vars needed might not be avaiable except in the included tasks or due to tags + if self._task.action != 'include': + raise # 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