1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

preserve delegation info on no_log (#42577)

* preserve delegation info on no_log

fixes #42344
This commit is contained in:
Brian Coca 2018-07-11 20:41:37 -04:00 committed by GitHub
parent 028f79a86b
commit e115e6496f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- preseve delegation info on nolog https://github.com/ansible/ansible/issues/42344

View file

@ -13,6 +13,7 @@ from ansible.vars.clean import strip_internal_keys
_IGNORE = ('failed', 'skipped')
_PRESERVE = ('attempts', 'changed', 'retries')
_SUB_PRESERVE = {'_ansible_delegated_vars': ('ansible_host', 'ansible_port', 'ansible_user', 'ansible_connection')}
class TaskResult:
@ -114,9 +115,19 @@ class TaskResult:
if 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"}
# preserve full
for preserve in _PRESERVE:
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]:
x[sub][key] = self._result[sub][key]
result._result = x
elif self._result:
result._result = deepcopy(self._result)