From 4c9f58a1524454e0b8a8ee4e7a4ab6c31cacbd59 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Fri, 2 Oct 2015 09:09:40 -0400 Subject: [PATCH] added no_log censoring to item output should be last commit that fixes #12214 --- lib/ansible/plugins/callback/__init__.py | 15 +++++++++++---- lib/ansible/plugins/callback/default.py | 7 +++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/ansible/plugins/callback/__init__.py b/lib/ansible/plugins/callback/__init__.py index 3e71d5e3d4b..4c736999fcf 100644 --- a/lib/ansible/plugins/callback/__init__.py +++ b/lib/ansible/plugins/callback/__init__.py @@ -107,10 +107,19 @@ class CallbackBase: except UnicodeDecodeError: ret.append(">> the files are different, but the diff library cannot compare unicode strings\n\n") + def _get_item(self, result): + if '_ansible_no_log' in result: + item = "(censored due to no_log)" + else: + item = getattr(result, 'item', "(censored due to no_log)") + + return item + def _process_items(self, result): for res in result._result['results']: newres = deepcopy(result) + res['item'] = self._get_item(res) newres._result = res if 'failed' in res and res['failed']: self.v2_playbook_item_on_failed(newres) @@ -119,7 +128,7 @@ class CallbackBase: else: self.v2_playbook_item_on_ok(newres) - #del result._result['results'] + del result._result['results'] def set_play_context(self, play_context): pass @@ -202,9 +211,7 @@ class CallbackBase: def v2_runner_on_skipped(self, result): if C.DISPLAY_SKIPPED_HOSTS: host = result._host.get_name() - #FIXME, get item to pass through - item = None - self.runner_on_skipped(host, item) + self.runner_on_skipped(host, self._get_item(getattr(result._result,'results',{}))) def v2_runner_on_unreachable(self, result): host = result._host.get_name() diff --git a/lib/ansible/plugins/callback/default.py b/lib/ansible/plugins/callback/default.py index ea18134b5c0..8a66f9ba623 100644 --- a/lib/ansible/plugins/callback/default.py +++ b/lib/ansible/plugins/callback/default.py @@ -89,8 +89,11 @@ class CallbackModule(CallbackBase): def v2_runner_on_skipped(self, result): if C.DISPLAY_SKIPPED_HOSTS: msg = "skipping: [%s]" % result._host.get_name() - if (self._display.verbosity > 0 or '_ansible_verbose_always' in result._result) and not '_ansible_verbose_override' in result._result: - msg += " => %s" % self._dump_results(result._result) + if result._task.loop and 'results' in result._result: + self._process_items(result) + else: + if (self._display.verbosity > 0 or '_ansible_verbose_always' in result._result) and not '_ansible_verbose_override' in result._result: + msg += " => %s" % self._dump_results(result._result) self._display.display(msg, color='cyan') def v2_runner_on_unreachable(self, result):