1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Always keep subset data for callbacks (#56881)

results were only being preserved during no_log
  fixes #56704
This commit is contained in:
Brian Coca 2019-05-23 17:15:04 -04:00 committed by GitHub
parent 3b16036ce2
commit 4adb7cfb5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 8 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- keep results subset also when not no_log.

View file

@ -119,6 +119,15 @@ class TaskResult:
else: else:
ignore = _IGNORE ignore = _IGNORE
subset = {}
# preserve subset for later
for sub in _SUB_PRESERVE:
if sub in self._result:
subset[sub] = {}
for key in _SUB_PRESERVE[sub]:
if key in self._result[sub]:
subset[sub][key] = self._result[sub][key]
if isinstance(self._task.no_log, bool) and self._task.no_log or self._result.get('_ansible_no_log', False): if isinstance(self._task.no_log, bool) and self._task.no_log or self._result.get('_ansible_no_log', False):
x = {"censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result"} x = {"censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result"}
@ -127,14 +136,6 @@ class TaskResult:
if preserve in self._result: if preserve in self._result:
x[preserve] = self._result[preserve] x[preserve] = self._result[preserve]
# preserve subset
for sub in _SUB_PRESERVE:
if sub in self._result:
x[sub] = {}
for key in _SUB_PRESERVE[sub]:
if key in self._result[sub]:
x[sub][key] = self._result[sub][key]
result._result = x result._result = x
elif self._result: elif self._result:
result._result = module_response_deepcopy(self._result) result._result = module_response_deepcopy(self._result)
@ -147,4 +148,7 @@ class TaskResult:
# remove almost ALL internal keys, keep ones relevant to callback # remove almost ALL internal keys, keep ones relevant to callback
strip_internal_keys(result._result, exceptions=CLEAN_EXCEPTIONS) strip_internal_keys(result._result, exceptions=CLEAN_EXCEPTIONS)
# keep subset
result._result.update(subset)
return result return result