mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-28 11:10:21 -07:00
simplified invocation removal, added no_log awareness
This commit is contained in:
parent
9f9655d3db
commit
b97887ba41
1 changed files with 7 additions and 10 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue