From 4e5c9c3d0dd2b87cb1b0f3a89c878fcbbebdb84c Mon Sep 17 00:00:00 2001 From: Pilou Date: Wed, 8 Feb 2017 16:58:39 +0100 Subject: [PATCH] default and minimal callback: display warnings in a consistent manner (#21144) * default/minimal callback: don't display warnings twice * minimal callback: display warnings raised by MODULE_NO_JSON modules --- lib/ansible/plugins/callback/default.py | 8 +++++--- lib/ansible/plugins/callback/minimal.py | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/ansible/plugins/callback/default.py b/lib/ansible/plugins/callback/default.py index 4b763735ef5..1a02b5a625d 100644 --- a/lib/ansible/plugins/callback/default.py +++ b/lib/ansible/plugins/callback/default.py @@ -56,6 +56,8 @@ class CallbackModule(CallbackBase): self._display.display(msg, color=C.COLOR_ERROR) + self._handle_warnings(result._result) + if result._task.loop and 'results' in result._result: self._process_items(result) @@ -92,6 +94,8 @@ class CallbackModule(CallbackBase): msg = "ok: [%s]" % result._host.get_name() color = C.COLOR_OK + self._handle_warnings(result._result) + if result._task.loop and 'results' in result._result: self._process_items(result) else: @@ -100,8 +104,6 @@ class CallbackModule(CallbackBase): msg += " => %s" % (self._dump_results(result._result),) self._display.display(msg, color=color) - self._handle_warnings(result._result) - def v2_runner_on_skipped(self, result): if C.DISPLAY_SKIPPED_HOSTS: if self._play.strategy == 'free' and self._last_task_banner != result._task._uuid: @@ -227,8 +229,8 @@ class CallbackModule(CallbackBase): else: msg += "[%s]" % (result._host.get_name()) - self._display.display(msg + " (item=%s) => %s" % (self._get_item(result._result), self._dump_results(result._result)), color=C.COLOR_ERROR) self._handle_warnings(result._result) + self._display.display(msg + " (item=%s) => %s" % (self._get_item(result._result), self._dump_results(result._result)), color=C.COLOR_ERROR) def v2_runner_item_on_skipped(self, result): if C.DISPLAY_SKIPPED_HOSTS: diff --git a/lib/ansible/plugins/callback/minimal.py b/lib/ansible/plugins/callback/minimal.py index 9d7ec1d4523..9df64d3cc0c 100644 --- a/lib/ansible/plugins/callback/minimal.py +++ b/lib/ansible/plugins/callback/minimal.py @@ -55,6 +55,8 @@ class CallbackModule(CallbackBase): self._display.display(msg, color=C.COLOR_ERROR) + self._handle_warnings(result._result) + if result._task.action in C.MODULE_NO_JSON and 'module_stderr' not in result._result: self._display.display(self._command_generic_msg(result._host.get_name(), result._result, "FAILED"), color=C.COLOR_ERROR) else: @@ -62,6 +64,9 @@ class CallbackModule(CallbackBase): def v2_runner_on_ok(self, result): self._clean_results(result._result, result._task.action) + + self._handle_warnings(result._result) + if result._task.action in C.MODULE_NO_JSON: self._display.display(self._command_generic_msg(result._host.get_name(), result._result, "SUCCESS"), color=C.COLOR_OK) else: @@ -69,7 +74,6 @@ class CallbackModule(CallbackBase): self._display.display("%s | SUCCESS => %s" % (result._host.get_name(), self._dump_results(result._result, indent=4)), color=C.COLOR_CHANGED) else: self._display.display("%s | SUCCESS => %s" % (result._host.get_name(), self._dump_results(result._result, indent=4)), color=C.COLOR_OK) - self._handle_warnings(result._result) def v2_runner_on_skipped(self, result): self._display.display("%s | SKIPPED" % (result._host.get_name()), color=C.COLOR_SKIP)