Always keep subset data for callbacks (#56881)

results were only being preserved during no_log
  fixes #56704
pull/56767/head
Brian Coca 6 years ago committed by GitHub
parent 3b16036ce2
commit 4adb7cfb5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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…
Cancel
Save