diff --git a/bin/ansible-playbook b/bin/ansible-playbook index 31f45d4235c..8df340df4e9 100755 --- a/bin/ansible-playbook +++ b/bin/ansible-playbook @@ -84,7 +84,7 @@ def main(args): pb.run() hosts = sorted(pb.stats.processed.keys()) - print "\n\nPLAY RECAP **********************\n\n" + print callbacks.banner("PLAY RECAP") for h in hosts: t = pb.stats.summarize(h) print "%-30s : ok=%4s changed=%4s unreachable=%4s failed=%4s " % (h, diff --git a/lib/ansible/callbacks.py b/lib/ansible/callbacks.py index 37c6666062a..c981aabb7e1 100644 --- a/lib/ansible/callbacks.py +++ b/lib/ansible/callbacks.py @@ -20,6 +20,8 @@ import utils import sys import getpass +import os +import subprocess ####################################################### @@ -74,6 +76,18 @@ class AggregateStats(object): ######################################################################## +def banner(msg): + res = "" + if os.path.exists("/usr/bin/cowsay"): + cmd = subprocess.Popen("/usr/bin/cowsay -W 60 \"%s\"" % msg, + stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) + (out, err) = cmd.communicate() + res = "%s\n" % out + else: + res = "%s ********************* \n" % msg + return res + + class DefaultRunnerCallbacks(object): ''' no-op callbacks for API usage of Runner() if no callbacks are specified ''' @@ -226,7 +240,7 @@ class PlaybookCallbacks(object): pass def on_task_start(self, name, is_conditional): - print utils.task_start_msg(name, is_conditional) + print banner(utils.task_start_msg(name, is_conditional)) def on_vars_prompt(self, varname, private=True): msg = 'input for %s: ' % varname @@ -235,10 +249,10 @@ class PlaybookCallbacks(object): return raw_input(msg) def on_setup_primary(self): - print "SETUP PHASE ****************************\n" + print banner("SETUP PHASE") def on_setup_secondary(self): - print "\nVARIABLE IMPORT PHASE ******************\n" + print banner("VARIABLE IMPORT PHASE") def on_import_for_host(self, host, imported_file): print "%s: importing %s" % (host, imported_file) @@ -247,4 +261,4 @@ class PlaybookCallbacks(object): print "%s: not importing file: %s" % (host, missing_file) def on_play_start(self, pattern): - print "PLAY [%s] ****************************\n" % pattern + print banner("PLAY [%s]" % pattern) diff --git a/lib/ansible/utils.py b/lib/ansible/utils.py index c25d93c2450..c507103d677 100644 --- a/lib/ansible/utils.py +++ b/lib/ansible/utils.py @@ -65,9 +65,9 @@ def smjson(result): def task_start_msg(name, conditional): if conditional: - return "\nNOTIFIED: [%s] **********\n" % name + return "NOTIFIED: [%s]" % name else: - return "\nTASK: [%s] *********\n" % name + return "TASK: [%s]" % name def regular_generic_msg(hostname, result, oneline, caption): ''' output on the result of a module run that is not command '''