|
|
|
@ -28,16 +28,17 @@ from ansible import errors
|
|
|
|
|
from ansible import callbacks
|
|
|
|
|
from ansible import utils
|
|
|
|
|
from ansible.color import ANSIBLE_COLOR, stringc
|
|
|
|
|
from ansible.callbacks import display
|
|
|
|
|
|
|
|
|
|
def colorize(lead, num, color):
|
|
|
|
|
""" Print 'lead' = 'num' in 'color' """
|
|
|
|
|
if num != 0 and ANSIBLE_COLOR:
|
|
|
|
|
if num != 0 and ANSIBLE_COLOR and color is not None:
|
|
|
|
|
return "%s%s%-15s" % (stringc(lead, color), stringc("=", color), stringc(str(num), color))
|
|
|
|
|
else:
|
|
|
|
|
return "%s=%-4s" % (lead, str(num))
|
|
|
|
|
|
|
|
|
|
def hostcolor(host, stats):
|
|
|
|
|
if ANSIBLE_COLOR:
|
|
|
|
|
def hostcolor(host, stats, color=True):
|
|
|
|
|
if ANSIBLE_COLOR and color:
|
|
|
|
|
if stats['failures'] != 0 or stats['unreachable'] != 0:
|
|
|
|
|
return "%-37s" % stringc(host, 'red')
|
|
|
|
|
elif stats['changed'] != 0:
|
|
|
|
@ -180,7 +181,7 @@ def main(args):
|
|
|
|
|
pb.run()
|
|
|
|
|
|
|
|
|
|
hosts = sorted(pb.stats.processed.keys())
|
|
|
|
|
print callbacks.banner("PLAY RECAP")
|
|
|
|
|
display(callbacks.banner("PLAY RECAP"))
|
|
|
|
|
playbook_cb.on_stats(pb.stats)
|
|
|
|
|
|
|
|
|
|
for h in hosts:
|
|
|
|
@ -191,16 +192,28 @@ def main(args):
|
|
|
|
|
if len(failed_hosts) > 0:
|
|
|
|
|
filename = pb.generate_retry_inventory(failed_hosts)
|
|
|
|
|
if filename:
|
|
|
|
|
print " to retry, use: --limit @%s\n" % filename
|
|
|
|
|
display(" to retry, use: --limit @%s\n" % filename)
|
|
|
|
|
|
|
|
|
|
for h in hosts:
|
|
|
|
|
t = pb.stats.summarize(h)
|
|
|
|
|
print "%s : %s %s %s %s" % (
|
|
|
|
|
|
|
|
|
|
display("%s : %s %s %s %s" % (
|
|
|
|
|
hostcolor(h, t),
|
|
|
|
|
colorize('ok', t['ok'], 'green'),
|
|
|
|
|
colorize('changed', t['changed'], 'yellow'),
|
|
|
|
|
colorize('unreachable', t['unreachable'], 'red'),
|
|
|
|
|
colorize('failed', t['failures'], 'red'))
|
|
|
|
|
colorize('failed', t['failures'], 'red')),
|
|
|
|
|
screen_only=True
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
display("%s : %s %s %s %s" % (
|
|
|
|
|
hostcolor(h, t, False),
|
|
|
|
|
colorize('ok', t['ok'], None),
|
|
|
|
|
colorize('changed', t['changed'], None),
|
|
|
|
|
colorize('unreachable', t['unreachable'], None),
|
|
|
|
|
colorize('failed', t['failures'], None)),
|
|
|
|
|
log_only=True
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print ""
|
|
|
|
@ -208,16 +221,19 @@ def main(args):
|
|
|
|
|
return 2
|
|
|
|
|
|
|
|
|
|
except errors.AnsibleError, e:
|
|
|
|
|
print >>sys.stderr, "ERROR: %s" % e
|
|
|
|
|
display("ERROR: %s" % e, color='red')
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
display(" ", log_only=True)
|
|
|
|
|
display(" ".join(sys.argv), log_only=True)
|
|
|
|
|
display(" ", log_only=True)
|
|
|
|
|
try:
|
|
|
|
|
sys.exit(main(sys.argv[1:]))
|
|
|
|
|
except errors.AnsibleError, e:
|
|
|
|
|
print >>sys.stderr, "ERROR: %s" % e
|
|
|
|
|
display("ERROR: %s" % e, color='red', stderr=True)
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|