From 275764d4a5bd5ff9a10f581507f6275fb55caf3f Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Fri, 23 Oct 2015 14:05:57 -0400 Subject: [PATCH] avoid showing invokation when no_log is set or verbosity is low --- lib/ansible/plugins/callback/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/callback/__init__.py b/lib/ansible/plugins/callback/__init__.py index bc70a195a28..183895e5fd4 100644 --- a/lib/ansible/plugins/callback/__init__.py +++ b/lib/ansible/plugins/callback/__init__.py @@ -50,7 +50,8 @@ class CallbackBase: def _dump_results(self, result, indent=None, sort_keys=True): - if result.get('_ansible_no_log', False): + no_log = result.get('_ansible_no_log', False): + if no_log: return json.dumps(dict(censored="the output has been hidden due to the fact that 'no_log: true' was specified for this result")) if not indent and '_ansible_verbose_always' in result and result['_ansible_verbose_always']: @@ -61,6 +62,10 @@ class CallbackBase: if isinstance(k, string_types) and k.startswith('_ansible_'): del result[k] + # remove invocation info unless its very very verbose + if 'invocation' in result and (self._display.verbosity < 3 or no_log): + del result['invocation'] + return json.dumps(result, indent=indent, ensure_ascii=False, sort_keys=sort_keys) def _handle_warnings(self, res):