diff options
author | Brian Coca <brian.coca+git@gmail.com> | 2018-02-16 09:59:54 -0500 |
---|---|---|
committer | Brian Coca <brian.coca+git@gmail.com> | 2018-02-20 08:46:12 -0500 |
commit | 0ee677165968eb3300d699abcc3be60cab8b0252 (patch) | |
tree | 32d794c84fe39a4f3b5b40018c7c34151c1c9138 | |
parent | 6d1a9a821119323bdeb36f2df0660e9af71a3409 (diff) | |
download | ansible-0ee677165968eb3300d699abcc3be60cab8b0252.tar.gz |
remove extra fields from debug output
fixes #35493
updated tests
(cherry picked from commit a79378fccbd656692e48a9bbd5e8a40946a40379)
-rw-r--r-- | lib/ansible/plugins/callback/__init__.py | 6 | ||||
-rw-r--r-- | lib/ansible/plugins/callback/default.py | 4 | ||||
-rw-r--r-- | test/units/plugins/callback/test_callback.py | 4 |
3 files changed, 7 insertions, 7 deletions
diff --git a/lib/ansible/plugins/callback/__init__.py b/lib/ansible/plugins/callback/__init__.py index 14f1b9d0bd..6c9efeeb2a 100644 --- a/lib/ansible/plugins/callback/__init__.py +++ b/lib/ansible/plugins/callback/__init__.py @@ -55,7 +55,6 @@ class CallbackBase(AnsiblePlugin): ''' def __init__(self, display=None, options=None): - if display: self._display = display else: @@ -78,6 +77,8 @@ class CallbackBase(AnsiblePlugin): if options is not None: self.set_options(options) + self._hide_in_debug = ('changed', 'failed', 'item', 'skipped', 'invocation') + ''' helper for callbacks, so they don't all have to include deepcopy ''' _copy_result = deepcopy @@ -236,7 +237,8 @@ class CallbackBase(AnsiblePlugin): def _clean_results(self, result, task_name): ''' removes data from results for display ''' if task_name in ['debug']: - result.pop('invocation', None) + for hideme in self._hide_in_debug: + result.pop(hideme, None) def set_play_context(self, play_context): pass diff --git a/lib/ansible/plugins/callback/default.py b/lib/ansible/plugins/callback/default.py index daf11514e8..c38e1c58a4 100644 --- a/lib/ansible/plugins/callback/default.py +++ b/lib/ansible/plugins/callback/default.py @@ -68,7 +68,6 @@ class CallbackModule(CallbackBase): def v2_runner_on_ok(self, result): delegated_vars = result._result.get('_ansible_delegated_vars', None) - self._clean_results(result._result, result._task.action) if self._play.strategy == 'free' and self._last_task_banner != result._task._uuid: self._print_task_banner(result._task) @@ -93,10 +92,9 @@ class CallbackModule(CallbackBase): if result._task.loop and 'results' in result._result: self._process_items(result) else: + self._clean_results(result._result, result._task.action) if (self._display.verbosity > 0 or '_ansible_verbose_always' in result._result) and '_ansible_verbose_override' not in result._result: - if result._task.action == 'debug' and 'changed' in result._result: - del result._result['changed'] msg += " => %s" % (self._dump_results(result._result),) self._display.display(msg, color=color) diff --git a/test/units/plugins/callback/test_callback.py b/test/units/plugins/callback/test_callback.py index 9ccf868753..86fbe508e7 100644 --- a/test/units/plugins/callback/test_callback.py +++ b/test/units/plugins/callback/test_callback.py @@ -81,7 +81,7 @@ class TestCallbackResults(unittest.TestCase): self.assertTrue('a' in result) self.assertTrue('b' in result) self.assertFalse('invocation' in result) - self.assertTrue('changed' in result) + self.assertFalse('changed' in result) def test_clean_results_debug_task_no_invocation(self): cb = CallbackBase() @@ -93,7 +93,7 @@ class TestCallbackResults(unittest.TestCase): cb._clean_results(result, 'debug') self.assertTrue('a' in result) self.assertTrue('b' in result) - self.assertTrue('changed' in result) + self.assertFalse('changed' in result) self.assertFalse('invocation' in result) def test_clean_results_debug_task_empty_results(self): |