remove extra fields from debug output

fixes #35493

updated tests
This commit is contained in:
Brian Coca 2018-02-16 09:59:54 -05:00 committed by Brian Coca
parent 6af5693dc2
commit a79378fccb
3 changed files with 7 additions and 7 deletions

View file

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

View file

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

View file

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