diff --git a/lib/ansible/plugins/callback/__init__.py b/lib/ansible/plugins/callback/__init__.py index aaea1a525c..677eeaedea 100644 --- a/lib/ansible/plugins/callback/__init__.py +++ b/lib/ansible/plugins/callback/__init__.py @@ -49,25 +49,22 @@ class CallbackBase: version = getattr(self, 'CALLBACK_VERSION', '1.0') self._display.vvvv('Loaded callback %s of type %s, v%s' % (name, ctype, version)) - def _dump_results(self, result, indent=None, sort_keys=True, keep_invocation=None): + def _dump_results(self, result, indent=None, sort_keys=True, keep_invocation=False): if result.get('_ansible_no_log', False): 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']: indent = 4 + # no_log trumps invocation + if '_ansible_no_log' in result and result['_ansible_no_log']: + keep_invocation = False + # All result keys stating with _ansible_ are internal, so remove them from the result before we output anything. abridged_result = strip_internal_keys(result) - # Remove invocation unless verbosity is turned up or the specific - # callback wants to keep it - if keep_invocation is None: - if self._display.verbosity < 3: - keep_invocation = False - else: - keep_invocation = True - - if not keep_invocation and 'invocation' in result: + # remove invocation unless specifically wanting it + if not keep_invocation and self._display.verbosity < 3 and 'invocation' in result: del abridged_result['invocation'] return json.dumps(abridged_result, indent=indent, ensure_ascii=False, sort_keys=sort_keys)