always preserve certain keys (#33637)

* always preserve certain keys

fixes #33433

* results
This commit is contained in:
Brian Coca 2017-12-12 13:01:52 -05:00 committed by GitHub
parent 7bc7c347dd
commit 8d78a829c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,6 +11,7 @@ from ansible.parsing.dataloader import DataLoader
from ansible.vars.clean import strip_internal_keys
_IGNORE = ('failed', 'skipped')
_PRESERVE = ('attempts', 'changed', 'retries')
class TaskResult:
@ -90,7 +91,11 @@ class TaskResult:
ignore = _IGNORE
if self._result.get('_ansible_no_log', False):
result._result = {"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"}
for preserve in _PRESERVE:
if preserve in self._result:
x[preserve] = self._result[preserve]
result._result = x
elif self._result:
result._result = deepcopy(self._result)