Fix callout json plugin show global stats (#43123)

* fix callback Plugin json to support global stat set by set_stats module

* refactor to not break compatiblity, add trailing comma on output dict

* Remove sorted, as it not needed

* refactor, to sivels better code

* clean some code messup

* add changelog fragment

* added missing new line

* fix pep8 stuff
pull/44123/merge
David Baumann 6 years ago committed by Matt Martz
parent 6b00d4df5d
commit c97f2b4c01

@ -0,0 +1,3 @@
---
minor_changes:
- Add support for per_host:no stats for the callback plugin **json** (https://github.com/ansible/ansible/pull/43123)

@ -101,14 +101,17 @@ class CallbackModule(CallbackBase):
summary[h] = s summary[h] = s
custom_stats = {} custom_stats = {}
global_custom_stats = {}
if self.get_option('show_custom_stats') and stats.custom: if self.get_option('show_custom_stats') and stats.custom:
custom_stats.update(dict((self._convert_host_to_name(k), v) for k, v in stats.custom.items())) custom_stats.update(dict((self._convert_host_to_name(k), v) for k, v in stats.custom.items()))
custom_stats.pop('_run', None) global_custom_stats.update(custom_stats.pop('_run', {}))
output = { output = {
'plays': self.results, 'plays': self.results,
'stats': summary, 'stats': summary,
'custom_stats': custom_stats, 'custom_stats': custom_stats,
'global_custom_stats': global_custom_stats,
} }
self._display.display(json.dumps(output, indent=4, sort_keys=True)) self._display.display(json.dumps(output, indent=4, sort_keys=True))

Loading…
Cancel
Save