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
|
setup_result['ansible_facts'][k] = v
|
||||||
|
|
||||||
# hack to keep --verbose from showing all the setup module results
|
# 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
|
return setup_result
|
||||||
|
|
|
@ -50,20 +50,17 @@ class CallbackBase:
|
||||||
version = getattr(self, 'CALLBACK_VERSION', '1.0')
|
version = getattr(self, 'CALLBACK_VERSION', '1.0')
|
||||||
self._display.vvvv('Loaded callback %s of type %s, v%s' % (name, ctype, version))
|
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):
|
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"))
|
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:
|
# All result keys stating with _ansible_ are internal, so remove them from the result before we output anything.
|
||||||
indent = 4
|
for k in result.keys():
|
||||||
# all result keys stating with _ansible_ are internal, so remove
|
if isinstance(k, string_types) and k.startswith('_ansible_'):
|
||||||
# them from the result before we output anything. We have to save
|
del result[k]
|
||||||
# the keys off first, as we're modifying the dict (so iteritems()
|
|
||||||
# won't work here)
|
return json.dumps(result, indent=indent, ensure_ascii=False, sort_keys=sort_keys)
|
||||||
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):
|
def _handle_warnings(self, res):
|
||||||
''' display warnings, if enabled and any exist in the result '''
|
''' display warnings, if enabled and any exist in the result '''
|
||||||
|
|
|
@ -63,7 +63,7 @@ class CallbackModule(CallbackBase):
|
||||||
msg = "ok: [%s]" % result._host.get_name()
|
msg = "ok: [%s]" % result._host.get_name()
|
||||||
color = 'green'
|
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)
|
msg += " => %s" % self._dump_results(result._result)
|
||||||
self._display.display(msg, color=color)
|
self._display.display(msg, color=color)
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ class CallbackModule(CallbackBase):
|
||||||
|
|
||||||
def v2_runner_on_skipped(self, result):
|
def v2_runner_on_skipped(self, result):
|
||||||
msg = "skipping: [%s]" % result._host.get_name()
|
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)
|
msg += " => %s" % self._dump_results(result._result)
|
||||||
self._display.display(msg, color='cyan')
|
self._display.display(msg, color='cyan')
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,8 @@ class CallbackModule(CallbackBase):
|
||||||
|
|
||||||
def log(self, host, category, data):
|
def log(self, host, category, data):
|
||||||
if type(data) == dict:
|
if type(data) == dict:
|
||||||
if 'verbose_override' in data:
|
if '_ansible_verbose_override' in data:
|
||||||
# avoid logging extraneous data from facts
|
# avoid logging extraneous data
|
||||||
data = 'omitted'
|
data = 'omitted'
|
||||||
else:
|
else:
|
||||||
data = data.copy()
|
data = data.copy()
|
||||||
|
|
|
@ -63,7 +63,7 @@ class CallbackModule(CallbackBase):
|
||||||
msg = "ok: [%s]" % result._host.get_name()
|
msg = "ok: [%s]" % result._host.get_name()
|
||||||
color = 'green'
|
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)
|
msg += " => %s" % self._dump_results(result._result)
|
||||||
|
|
||||||
self._display.display(msg, color=color)
|
self._display.display(msg, color=color)
|
||||||
|
|
Loading…
Add table
Reference in a new issue