changed verbose_override to the new _ansible_verbose_override to keep in line with previous changes
output now defaults back to having indent=4
This commit is contained in:
parent
8746e692c1
commit
5f8db9cd4b
5 changed files with 15 additions and 18 deletions
|
@ -2874,6 +2874,6 @@ def get_all_facts(module):
|
|||
setup_result['ansible_facts'][k] = v
|
||||
|
||||
# hack to keep --verbose from showing all the setup module results
|
||||
setup_result['verbose_override'] = True
|
||||
setup_result['_ansible_verbose_override'] = True
|
||||
|
||||
return setup_result
|
||||
|
|
|
@ -50,20 +50,17 @@ 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):
|
||||
def _dump_results(self, result, indent=4, sort_keys=True):
|
||||
|
||||
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"))
|
||||
else:
|
||||
if '_ansible_verbose_always' in result:
|
||||
indent = 4
|
||||
# all result keys stating with _ansible_ are internal, so remove
|
||||
# them from the result before we output anything. We have to save
|
||||
# the keys off first, as we're modifying the dict (so iteritems()
|
||||
# won't work here)
|
||||
for k in result.keys():
|
||||
if isinstance(k, string_types) and k.startswith('_ansible_'):
|
||||
del result[k]
|
||||
return json.dumps(result, indent=indent, ensure_ascii=False, sort_keys=sort_keys)
|
||||
|
||||
# All result keys stating with _ansible_ are internal, so remove them from the result before we output anything.
|
||||
for k in result.keys():
|
||||
if isinstance(k, string_types) and k.startswith('_ansible_'):
|
||||
del result[k]
|
||||
|
||||
return json.dumps(result, indent=indent, ensure_ascii=False, sort_keys=sort_keys)
|
||||
|
||||
def _handle_warnings(self, res):
|
||||
''' display warnings, if enabled and any exist in the result '''
|
||||
|
|
|
@ -63,7 +63,7 @@ class CallbackModule(CallbackBase):
|
|||
msg = "ok: [%s]" % result._host.get_name()
|
||||
color = 'green'
|
||||
|
||||
if (self._display.verbosity > 0 or '_ansible_verbose_always' in result._result) and result._task.action not in ('setup', 'include'):
|
||||
if (self._display.verbosity > 0 or '_ansible_verbose_always' in result._result) and not '_ansible_verbose_override' in result._result and result._task.action != 'include':
|
||||
msg += " => %s" % self._dump_results(result._result)
|
||||
self._display.display(msg, color=color)
|
||||
|
||||
|
@ -71,7 +71,7 @@ class CallbackModule(CallbackBase):
|
|||
|
||||
def v2_runner_on_skipped(self, result):
|
||||
msg = "skipping: [%s]" % result._host.get_name()
|
||||
if self._display.verbosity > 0 or '_ansible_verbose_always' in result._result:
|
||||
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')
|
||||
|
||||
|
|
|
@ -48,8 +48,8 @@ class CallbackModule(CallbackBase):
|
|||
|
||||
def log(self, host, category, data):
|
||||
if type(data) == dict:
|
||||
if 'verbose_override' in data:
|
||||
# avoid logging extraneous data from facts
|
||||
if '_ansible_verbose_override' in data:
|
||||
# avoid logging extraneous data
|
||||
data = 'omitted'
|
||||
else:
|
||||
data = data.copy()
|
||||
|
|
|
@ -63,7 +63,7 @@ class CallbackModule(CallbackBase):
|
|||
msg = "ok: [%s]" % result._host.get_name()
|
||||
color = 'green'
|
||||
|
||||
if (self._display.verbosity > 0 or '_ansible_verbose_always' in result._result) and result._task.action not in ('setup', 'include'):
|
||||
if (self._display.verbosity > 0 or '_ansible_verbose_always' in result._result) and not '_ansible_verbose_override' in result._result and result._task.action != 'include':
|
||||
msg += " => %s" % self._dump_results(result._result)
|
||||
|
||||
self._display.display(msg, color=color)
|
||||
|
|
Loading…
Reference in a new issue