mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07:00
Tweak location of stats callback execution and properly relocate stats output code
This commit is contained in:
parent
ea23159be4
commit
6671d78f95
2 changed files with 32 additions and 31 deletions
|
@ -21,6 +21,7 @@ __metaclass__ = type
|
|||
|
||||
from ansible import constants as C
|
||||
from ansible.plugins.callback import CallbackBase
|
||||
from ansible.utils.color import colorize, hostcolor
|
||||
|
||||
class CallbackModule(CallbackBase):
|
||||
|
||||
|
@ -193,3 +194,30 @@ class CallbackModule(CallbackBase):
|
|||
color = 'cyan'
|
||||
self._display.display(msg, color='cyan')
|
||||
|
||||
def v2_playbook_on_stats(self, stats):
|
||||
self._display.banner("PLAY RECAP")
|
||||
|
||||
hosts = sorted(stats.processed.keys())
|
||||
for h in hosts:
|
||||
t = stats.summarize(h)
|
||||
|
||||
self._display.display(u"%s : %s %s %s %s" % (
|
||||
hostcolor(h, t),
|
||||
colorize(u'ok', t['ok'], 'green'),
|
||||
colorize(u'changed', t['changed'], 'yellow'),
|
||||
colorize(u'unreachable', t['unreachable'], 'red'),
|
||||
colorize(u'failed', t['failures'], 'red')),
|
||||
screen_only=True
|
||||
)
|
||||
|
||||
self._display.display(u"%s : %s %s %s %s" % (
|
||||
hostcolor(h, t, False),
|
||||
colorize(u'ok', t['ok'], None),
|
||||
colorize(u'changed', t['changed'], None),
|
||||
colorize(u'unreachable', t['unreachable'], None),
|
||||
colorize(u'failed', t['failures'], None)),
|
||||
log_only=True
|
||||
)
|
||||
|
||||
self._display.display("", screen_only=True)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue