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:
Brian Coca 2015-07-11 00:47:59 -04:00
parent fdea00880b
commit 1274ce565d
7 changed files with 31 additions and 19 deletions

View file

@ -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