mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Leverage cowsay if installed.
This commit is contained in:
parent
960e7c331c
commit
0972b761de
3 changed files with 21 additions and 7 deletions
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 '''
|
||||
|
|
Loading…
Reference in a new issue