mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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
This commit is contained in:
parent
6b00d4df5d
commit
c97f2b4c01
2 changed files with 7 additions and 1 deletions
|
@ -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…
Reference in a new issue