From bc0be456dab6bf001db0e9db80b31c7a4dd90d25 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Sat, 6 Apr 2013 18:52:30 -0400 Subject: [PATCH] Modify output banners to have constant length and use dashes instead of "-" to be less visually heavy (unless cowsay is installed of course) --- bin/ansible-playbook | 10 +++++----- lib/ansible/callbacks.py | 6 +++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/bin/ansible-playbook b/bin/ansible-playbook index 98916e254e2..a80bbf6ab8b 100755 --- a/bin/ansible-playbook +++ b/bin/ansible-playbook @@ -39,12 +39,12 @@ def colorize(lead, num, color): def hostcolor(host, stats): if ANSIBLE_COLOR: if stats['failures'] != 0 or stats['unreachable'] != 0: - return "%-41s" % stringc(host, 'red') + return "%-37s" % stringc(host, 'red') elif stats['changed'] != 0: - return "%-41s" % stringc(host, 'yellow') + return "%-37s" % stringc(host, 'yellow') else: - return "%-41s" % stringc(host, 'green') - return "%-30s" % host + return "%-37s" % stringc(host, 'green') + return "%-26s" % host def main(args): @@ -184,7 +184,7 @@ def main(args): playbook_cb.on_stats(pb.stats) for h in hosts: t = pb.stats.summarize(h) - print "%-30s : %s %s %s %s " % ( + print "%s : %s %s %s %s" % ( hostcolor(h, t), colorize('ok', t['ok'], 'green'), colorize('changed', t['changed'], 'yellow'), diff --git a/lib/ansible/callbacks.py b/lib/ansible/callbacks.py index 5fd1c27bf71..1f0b664c104 100644 --- a/lib/ansible/callbacks.py +++ b/lib/ansible/callbacks.py @@ -143,7 +143,11 @@ def banner(msg): (out, err) = cmd.communicate() return "%s\n" % out else: - return "\n%s ********************* " % msg + width = 78 - len(msg) + if width < 3: + width = 3 + filler = "-" * width + return "\n%s %s " % (msg, filler) def command_generic_msg(hostname, result, oneline, caption): ''' output the result of a command run '''