From 061c6c7c6fdb26ca572eba2ccff2557106435c44 Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Thu, 28 May 2020 23:13:39 +0200 Subject: [PATCH] Prevent losing error info by including both loop and cond error msgs (#68485) Fixes #66529 --- .../fragments/66529-display-both-loop-and-cond-errors.yml | 2 ++ lib/ansible/executor/task_executor.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/66529-display-both-loop-and-cond-errors.yml diff --git a/changelogs/fragments/66529-display-both-loop-and-cond-errors.yml b/changelogs/fragments/66529-display-both-loop-and-cond-errors.yml new file mode 100644 index 00000000000..fd8f7c04505 --- /dev/null +++ b/changelogs/fragments/66529-display-both-loop-and-cond-errors.yml @@ -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) diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py index d26d6523e0c..477a36b7b07 100644 --- a/lib/ansible/executor/task_executor.py +++ b/lib/ansible/executor/task_executor.py @@ -562,9 +562,12 @@ class TaskExecutor: if not self._task.evaluate_conditional(templar, variables): 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) - except AnsibleError: + except AnsibleError as e: # loop error takes precedence 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