diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index 3928862d05..c651165fb0 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -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 diff --git a/lib/ansible/plugins/callback/__init__.py b/lib/ansible/plugins/callback/__init__.py index 0cb15931c2..841f345db4 100644 --- a/lib/ansible/plugins/callback/__init__.py +++ b/lib/ansible/plugins/callback/__init__.py @@ -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 ''' diff --git a/lib/ansible/plugins/callback/default.py b/lib/ansible/plugins/callback/default.py index b854c7c68b..c56e300468 100644 --- a/lib/ansible/plugins/callback/default.py +++ b/lib/ansible/plugins/callback/default.py @@ -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') diff --git a/lib/ansible/plugins/callback/log_plays.py b/lib/ansible/plugins/callback/log_plays.py index 7cdedcb00e..11e0accea5 100644 --- a/lib/ansible/plugins/callback/log_plays.py +++ b/lib/ansible/plugins/callback/log_plays.py @@ -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() diff --git a/lib/ansible/plugins/callback/skippy.py b/lib/ansible/plugins/callback/skippy.py index 06ebc078c9..db742a46ac 100644 --- a/lib/ansible/plugins/callback/skippy.py +++ b/lib/ansible/plugins/callback/skippy.py @@ -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)