allow modules to set custom stats (#18946)

can be per run or per host, also aggregate or not
set_stats action plugin as reference implementation
added doc stub
display stats in calblack
made custom stats showing configurable
This commit is contained in:
Brian Coca 2017-01-05 16:38:36 -05:00 committed by GitHub
parent 1154aca746
commit 08e0f6ada5
9 changed files with 233 additions and 16 deletions

View file

@ -268,6 +268,22 @@ class CallbackModule(CallbackBase):
self._display.display("", screen_only=True)
# print custom stats
if C.SHOW_CUSTOM_STATS and stats.custom:
self._display.banner("CUSTOM STATS: ")
# per host
#TODO: come up with 'pretty format'
for k in sorted(stats.custom.keys()):
if k == '_run':
continue
self._display.display('\t%s: %s' % (k, self._dump_results(stats.custom[k], indent=1).replace('\n','')))
# print per run custom stats
if '_run' in stats.custom:
self._display.display("", screen_only=True)
self._display.display('\tRUN: %s' % self._dump_results(stats.custom['_run'], indent=1).replace('\n',''))
self._display.display("", screen_only=True)
def v2_playbook_on_start(self, playbook):
if self._display.verbosity > 1:
from os.path import basename