summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael DeHaan <michael.dehaan@gmail.com>2012-11-28 05:07:23 -0800
committerMichael DeHaan <michael.dehaan@gmail.com>2012-11-28 05:07:23 -0800
commit93fe43f0c4f3402003c148f2feb2ee5ebb895c4c (patch)
treebb8fca699c75fc6217d79126c68008893a8a9d35
parent8690854662563a552fc9a9b7bb5c428c1cc25023 (diff)
parent9070875a6f9bc3700d228a820b63ee291f6020cc (diff)
downloadansible-93fe43f0c4f3402003c148f2feb2ee5ebb895c4c.tar.gz
Merge pull request #1701 from dhozac/serial-skip-failed
Skip already failed hosts for serial
-rw-r--r--lib/ansible/playbook/__init__.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/ansible/playbook/__init__.py b/lib/ansible/playbook/__init__.py
index fe4a3711ce..e5fee92ec9 100644
--- a/lib/ansible/playbook/__init__.py
+++ b/lib/ansible/playbook/__init__.py
@@ -239,10 +239,17 @@ class PlayBook(object):
# *****************************************************
+ def _list_available_hosts(self):
+ ''' returns a list of hosts that haven't failed and aren't dark '''
+
+ return [ h for h in self.inventory.list_hosts() if (h not in self.stats.failures) and (h not in self.stats.dark)]
+
+ # *****************************************************
+
def _run_task_internal(self, task):
''' run a particular module step in a playbook '''
- hosts = [ h for h in self.inventory.list_hosts() if (h not in self.stats.failures) and (h not in self.stats.dark)]
+ hosts = self._list_available_hosts()
self.inventory.restrict_to(hosts)
runner = ansible.runner.Runner(
@@ -340,8 +347,7 @@ class PlayBook(object):
def _do_setup_step(self, play):
''' get facts from the remote system '''
- host_list = [ h for h in self.inventory.list_hosts(play.hosts)
- if not (h in self.stats.failures or h in self.stats.dark) ]
+ host_list = self._list_available_hosts()
if play.gather_facts is False:
return {}
@@ -390,7 +396,7 @@ class PlayBook(object):
# now with that data, handle contentional variable file imports!
- all_hosts = self.inventory.list_hosts(play.hosts)
+ all_hosts = self._list_available_hosts()
play.update_vars_files(all_hosts)
serialized_batch = []
@@ -425,8 +431,7 @@ class PlayBook(object):
# just didn't match anything and that's ok
return False
- host_list = [ h for h in self.inventory.list_hosts(play.hosts)
- if not (h in self.stats.failures or h in self.stats.dark) ]
+ host_list = self._list_available_hosts()
# if no hosts remain, drop out
if not host_list: