diff --git a/lib/ansible/callbacks.py b/lib/ansible/callbacks.py index 4fe2523fc6..9ffcdf58c4 100644 --- a/lib/ansible/callbacks.py +++ b/lib/ansible/callbacks.py @@ -376,7 +376,7 @@ class PlaybookRunnerCallbacks(DefaultRunnerCallbacks): super(PlaybookRunnerCallbacks, self).on_skipped(host, item) def on_no_hosts(self): - print stringc("FATAL: no hosts matched or all hosts have already failed -- aborting playbook\n", 'red') + print stringc("FATAL: no hosts matched or all hosts have already failed -- aborting\n", 'red') super(PlaybookRunnerCallbacks, self).on_no_hosts() def on_async_poll(self, host, res, jid, clock): diff --git a/lib/ansible/playbook/__init__.py b/lib/ansible/playbook/__init__.py index f591920468..f3bb504495 100644 --- a/lib/ansible/playbook/__init__.py +++ b/lib/ansible/playbook/__init__.py @@ -115,6 +115,9 @@ class PlayBook(object): (self.playbook, self.play_basedirs) = self._load_playbook_from_file(playbook) self.module_path = self.module_path + os.pathsep + os.path.join(self.basedir, "library") + # which task we are currently executing + self.task_counter = 0 + # ***************************************************** def _load_playbook_from_file(self, path): @@ -236,6 +239,8 @@ class PlayBook(object): # if not polling, playbook requested fire and forget, so don't poll results = self._async_poll(poller, task.async_seconds, task.async_poll_interval) + self.task_counter = self.task_counter + 1 + contacted = results.get('contacted',{}) dark = results.get('dark', {}) @@ -376,7 +381,10 @@ class PlayBook(object): break if should_run: if not self._run_task(play, task, False): - return False + # whether no hosts matched is fatal or not depends if it was on the initial step. + # if we got exactly no hosts on the first step (setup!) then the host group + # just didn't match anything and that's ok + return (self.task_counter <= 1) # run notify actions for handler in play.handlers():