fixed issue with when/with error deferment

now it issues correct error (loop) when conditional depends on loop
compliment fixes #16222
This commit is contained in:
Brian Coca 2016-11-23 13:40:30 -05:00
parent 9d0b8c8545
commit 4a325b5ea2

View file

@ -409,16 +409,18 @@ class TaskExecutor:
if not self._task.evaluate_conditional(templar, variables): if not self._task.evaluate_conditional(templar, variables):
display.debug("when evaluation failed, skipping this task") 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) return dict(changed=False, skipped=True, skip_reason='Conditional check failed', _ansible_no_log=self._play_context.no_log)
# since we're not skipping, if there was a loop evaluation error except AnsibleError:
# raised earlier we need to raise it now to halt the execution of # loop error takes precedence
# this task
if self._loop_eval_error is not None: if self._loop_eval_error is not None:
raise self._loop_eval_error raise self._loop_eval_error
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 # 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 not in ['include', 'include_role']: if self._task.action not in ['include', 'include_role']:
raise raise
# Not skipping, if we had loop error raised earlier we need to raise it now to halt the execution of this task
if self._loop_eval_error is not None:
raise self._loop_eval_error
# if we ran into an error while setting up the PlayContext, raise it now # if we ran into an error while setting up the PlayContext, raise it now
if context_validation_error is not None: if context_validation_error is not None:
raise context_validation_error raise context_validation_error