Prevent losing error info by including both loop and cond error msgs (#68485)

Fixes #66529
This commit is contained in:
Martin Krizek 2020-05-28 23:13:39 +02:00 committed by GitHub
parent 1e01ac413b
commit 061c6c7c6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- Prevent losing useful error information by including both the loop and the conditional error messages (https://github.com/ansible/ansible/issues/66529)

View file

@ -562,9 +562,12 @@ class TaskExecutor:
if not self._task.evaluate_conditional(templar, variables): if not self._task.evaluate_conditional(templar, variables):
display.debug("when evaluation is False, skipping this task") display.debug("when evaluation is False, skipping this task")
return dict(changed=False, skipped=True, skip_reason='Conditional result was False', _ansible_no_log=self._play_context.no_log) return dict(changed=False, skipped=True, skip_reason='Conditional result was False', _ansible_no_log=self._play_context.no_log)
except AnsibleError: except AnsibleError as e:
# loop error takes precedence # loop error takes precedence
if self._loop_eval_error is not None: if self._loop_eval_error is not None:
# Display the error from the conditional as well to prevent
# losing information useful for debugging.
display.v(to_text(e))
raise self._loop_eval_error # pylint: disable=raising-bad-type raise self._loop_eval_error # pylint: disable=raising-bad-type
raise raise