From 40e5d2c951d5bc35d98fc47f66557713789f65c1 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Tue, 30 Oct 2018 11:51:25 -0500 Subject: [PATCH] Do not filter out exception, warnings, deprecations on failure when using debug (#47588) * Do not filter out exception, warnings, deprecations on failure when using debug. Fixes #47576 * Add changelog fragment --- changelogs/fragments/callback-keep-more-debug-keys.yml | 2 ++ lib/ansible/plugins/callback/__init__.py | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/callback-keep-more-debug-keys.yml diff --git a/changelogs/fragments/callback-keep-more-debug-keys.yml b/changelogs/fragments/callback-keep-more-debug-keys.yml new file mode 100644 index 00000000000..c8bf0796b13 --- /dev/null +++ b/changelogs/fragments/callback-keep-more-debug-keys.yml @@ -0,0 +1,2 @@ +bugfixes: +- callbacks - Do not filter out exception, warnings, deprecations on failure when using debug (https://github.com/ansible/ansible/issues/47576) diff --git a/lib/ansible/plugins/callback/__init__.py b/lib/ansible/plugins/callback/__init__.py index 3720e6f9934..88c864a0aeb 100644 --- a/lib/ansible/plugins/callback/__init__.py +++ b/lib/ansible/plugins/callback/__init__.py @@ -49,6 +49,9 @@ except ImportError: __all__ = ["CallbackBase"] +_DEBUG_ALLOWED_KEYS = frozenset(('msg', 'exception', 'warnings', 'deprecations')) + + class CallbackBase(AnsiblePlugin): ''' @@ -234,11 +237,11 @@ class CallbackBase(AnsiblePlugin): ''' removes data from results for display ''' # mostly controls that debug only outputs what it was meant to - if task_name in ['debug']: + if task_name == 'debug': if 'msg' in result: # msg should be alone for key in list(result.keys()): - if key != 'msg' and not key.startswith('_'): + if key not in _DEBUG_ALLOWED_KEYS and not key.startswith('_'): result.pop(key) else: # 'var' value as field, so eliminate others and what is left should be varname