always preserve certain keys (#33637)

* always preserve certain keys

fixes #33433

* results
pull/4420/head
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
1 changed files with 6 additions and 1 deletions

View File

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