If all hosts in a play fail, fail the whole playbook and don't bother printing out every remaining task.

This commit is contained in:
Michael DeHaan 2012-09-30 21:06:00 -04:00
parent 22f3aef4dc
commit a2f76c1c69
3 changed files with 7 additions and 9 deletions

View file

@ -122,9 +122,11 @@ def main(args):
print '\n'
return 0
try:
pb.run()
hosts = sorted(pb.stats.processed.keys())
print callbacks.banner("PLAY RECAP")
playbook_cb.on_stats(pb.stats)

View file

@ -376,7 +376,7 @@ class PlaybookRunnerCallbacks(DefaultRunnerCallbacks):
super(PlaybookRunnerCallbacks, self).on_skipped(host, item)
def on_no_hosts(self):
print stringc("no hosts matched or remaining\n", 'red')
print stringc("FATAL: no hosts matched or all hosts have already failed -- aborting playbook\n", 'red')
super(PlaybookRunnerCallbacks, self).on_no_hosts()
def on_async_poll(self, host, res, jid, clock):

View file

@ -181,7 +181,8 @@ class PlayBook(object):
raise errors.AnsibleError(msg % (unknown, unmatched))
for play in plays:
self._run_play(play)
if not self._run_play(play):
break
# summarize the results
results = {}
@ -360,16 +361,12 @@ class PlayBook(object):
play_hosts.append(all_hosts.pop())
serialized_batch.append(play_hosts)
hosts_remaining = True
for on_hosts in serialized_batch:
self.inventory.also_restrict_to(on_hosts)
for task in play.tasks():
if not hosts_remaining:
continue
# only run the task if the requested tags match
should_run = False
for x in self.only_tags:
@ -379,16 +376,15 @@ class PlayBook(object):
break
if should_run:
if not self._run_task(play, task, False):
hosts_remaining = False
return False
# run notify actions
for handler in play.handlers():
if not hosts_remaining:
continue
if len(handler.notified_by) > 0:
self.inventory.restrict_to(handler.notified_by)
self._run_task(play, handler, True)
self.inventory.lift_restriction()
self.inventory.lift_also_restriction()
return True