avoid showing invokation when no_log is set or verbosity is low

This commit is contained in:
Brian Coca 2015-10-23 14:05:57 -04:00
parent 63ea614b4c
commit 275764d4a5

View file

@ -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):