From 8d78a829c60cc63e668683fb5d626eba942e6a39 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 12 Dec 2017 13:01:52 -0500 Subject: [PATCH] always preserve certain keys (#33637) * always preserve certain keys fixes #33433 * results --- lib/ansible/executor/task_result.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/ansible/executor/task_result.py b/lib/ansible/executor/task_result.py index ef35a7f1182..4abfa45c734 100644 --- a/lib/ansible/executor/task_result.py +++ b/lib/ansible/executor/task_result.py @@ -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)