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:
parent
3b16036ce2
commit
4adb7cfb5f
2 changed files with 14 additions and 8 deletions
2
changelogs/fragments/always_keep_subset.yml
Normal file
2
changelogs/fragments/always_keep_subset.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- keep results subset also when not no_log.
|
|
@ -119,6 +119,15 @@ class TaskResult:
|
|||
else:
|
||||
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):
|
||||
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:
|
||||
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
|
||||
elif 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
|
||||
strip_internal_keys(result._result, exceptions=CLEAN_EXCEPTIONS)
|
||||
|
||||
# keep subset
|
||||
result._result.update(subset)
|
||||
|
||||
return result
|
||||
|
|
Loading…
Reference in a new issue