mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-27 18:50:21 -07:00
added result sanitation to registered var and to callbacks
removed time display as it only is provided by command module
This commit is contained in:
parent
fdea00880b
commit
1274ce565d
7 changed files with 31 additions and 19 deletions
|
@ -19,8 +19,13 @@
|
|||
from __future__ import (absolute_import, division)
|
||||
__metaclass__ = type
|
||||
|
||||
import json
|
||||
|
||||
from ansible import constants as C
|
||||
|
||||
__all__ = ["CallbackBase"]
|
||||
|
||||
|
||||
class CallbackBase:
|
||||
|
||||
'''
|
||||
|
@ -40,6 +45,16 @@ class CallbackBase:
|
|||
version = getattr(self, 'CALLBACK_VERSION', 'unknwon')
|
||||
self._display.vvvv('Loaded callback %s of type %s, v%s' % (name, ctype, version))
|
||||
|
||||
def _dump_results(self, result, sanitize=True, indent=4, sort_keys=True):
|
||||
if sanitize:
|
||||
res = self._sanitize_result(result)
|
||||
else:
|
||||
res = results
|
||||
return json.dumps(res, indent=indent, ensure_ascii=False, sort_keys=sort_keys)
|
||||
|
||||
def _sanitize_result(self, result):
|
||||
return {k: result[k] for k in set(result.keys()).difference(C.RESULT_SANITIZE)}
|
||||
|
||||
def set_connection_info(self, conn_info):
|
||||
pass
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue