Merge pull request #1222 from alopropoz/devel

Indicate errors with exit code.
This commit is contained in:
Michael DeHaan 2012-10-04 16:26:00 -07:00
commit 0592e1be79
2 changed files with 9 additions and 0 deletions

View file

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

View file

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