22 from __future__
import (absolute_import, division, print_function)
23 from ansible.plugins.callback
import CallbackBase
39 CALLBACK_NAME =
'pretty_print' 40 CALLBACK_TYPE =
'notification' 41 CALLBACK_VERSION = 2.0
42 CALLBACK_NEEDS_WHITELIST =
False 49 if type(data)
is dict:
51 no_log = data.get(
'_ansible_no_log',
False)
52 if rec
in data
and data[rec]
and not no_log:
53 output = self.
_format(data[rec]).replace(
"\\n",
"\n")
54 self._display.display(
"{0}: {1}".
format(rec, output),
57 def _format(self, output):
58 if type(output)
is dict:
59 return json.dumps(output, indent=2, sort_keys=
True)
62 if type(output)
is list
and type(output[0])
is dict:
64 for i, elem
in enumerate(output):
65 if type(elem)
is dict:
66 for rec
in set(RECORDS) & set(elem):
67 formatted_output.append( self.
_format(elem[rec]) )
68 if len(formatted_output) == 1:
69 return formatted_output[0]
71 return '\n ' +
'\n '.join(formatted_output)
73 if type(output)
is list
and type(output[0])
is not dict:
77 return '\n ' +
'\n '.join(output)
def runner_on_async_ok(self, host, res, jid)
def runner_on_failed(self, host, res, ignore_errors=False)
def v2_runner_on_ok(self, result)
def v2_runner_on_unreachable(self, result)
def runner_on_async_poll(self, host, res, jid, clock)
def v2_runner_on_failed(self, result, ignore_errors=False)
def pretty_print(self, data)
def v2_runner_on_async_ok(self, host, result)
def runner_on_unreachable(self, host, res)
def runner_on_async_failed(self, host, res, jid)
def runner_on_ok(self, host, res)
def _format(self, output)
def v2_runner_on_async_poll(self, result)
def v2_runner_on_async_failed(self, result)