Indicate errors with exit code.

pull/1222/head
Aleksej Romanov 12 years ago
parent 53d24ef002
commit 01e922aa69

@ -127,6 +127,11 @@ if __name__ == '__main__':
(options, args) = cli.parse() (options, args) = cli.parse()
try: try:
(runner, results) = cli.run(options, args) (runner, results) = cli.run(options, args)
for result in results['contacted'].values():
if 'failed' in result or result.get('rc', 0) != 0:
sys.exit(1)
if results['dark']:
sys.exit(1)
except errors.AnsibleError, e: except errors.AnsibleError, e:
# Generic handler for ansible specific errors # Generic handler for ansible specific errors
print "ERROR: %s" % str(e) print "ERROR: %s" % str(e)

@ -140,6 +140,10 @@ def main(args):
colorize('failed', t['failures'], 'red')) colorize('failed', t['failures'], 'red'))
print "\n" print "\n"
for h in hosts:
stats = pb.stats.summarize(h)
if stats['failures'] != 0 or stats['unreachable'] != 0:
sys.exit(1)
except errors.AnsibleError, e: except errors.AnsibleError, e:
print >>sys.stderr, "ERROR: %s" % e print >>sys.stderr, "ERROR: %s" % e

Loading…
Cancel
Save