Coverage for lib/ansible/plugins/callback/json.py : 53%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# (c) 2016, Matt Martz <matt@sivel.net> # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Make coding more python3-ish
callback: json short_description: Ansible screen output as JSON version_added: "2.2" description: - This callback converts all events into JSON output to stdout type: stdout requirements: - Set as stdout in config '''
super(CallbackModule, self).__init__(display) self.results = []
return { 'play': { 'name': play.name, 'id': str(play._uuid) }, 'tasks': [] }
return { 'task': { 'name': task.name, 'id': str(task._uuid) }, 'hosts': {} }
self.results.append(self._new_play(play))
self.results[-1]['tasks'].append(self._new_task(task))
self.results[-1]['tasks'].append(self._new_task(task))
host = result._host self.results[-1]['tasks'][-1]['hosts'][host.name] = result._result
"""Display info about playbook statistics"""
hosts = sorted(stats.processed.keys())
summary = {} for h in hosts: s = stats.summarize(h) summary[h] = s
output = { 'plays': self.results, 'stats': summary }
self._display.display(json.dumps(output, indent=4, sort_keys=True))
|