Browse code

Merge pull request #1701 from dhozac/serial-skip-failed

Skip already failed hosts for serial

Michael DeHaan authored on 2012/11/28 22:07:23
Showing 1 changed files
... ...
@@ -239,10 +239,17 @@ class PlayBook(object):
239 239
 
240 240
     # *****************************************************
241 241
 
242
+    def _list_available_hosts(self):
243
+        ''' returns a list of hosts that haven't failed and aren't dark '''
244
+
245
+        return [ h for h in self.inventory.list_hosts() if (h not in self.stats.failures) and (h not in self.stats.dark)]
246
+
247
+    # *****************************************************
248
+
242 249
     def _run_task_internal(self, task):
243 250
         ''' run a particular module step in a playbook '''
244 251
 
245
-        hosts = [ h for h in self.inventory.list_hosts() if (h not in self.stats.failures) and (h not in self.stats.dark)]
252
+        hosts = self._list_available_hosts()
246 253
         self.inventory.restrict_to(hosts)
247 254
 
248 255
         runner = ansible.runner.Runner(
... ...
@@ -340,8 +347,7 @@ class PlayBook(object):
340 340
     def _do_setup_step(self, play):
341 341
         ''' get facts from the remote system '''
342 342
 
343
-        host_list = [ h for h in self.inventory.list_hosts(play.hosts)
344
-            if not (h in self.stats.failures or h in self.stats.dark) ]
343
+        host_list = self._list_available_hosts()
345 344
 
346 345
         if play.gather_facts is False:
347 346
             return {}
... ...
@@ -390,7 +396,7 @@ class PlayBook(object):
390 390
 
391 391
         # now with that data, handle contentional variable file imports!
392 392
 
393
-        all_hosts = self.inventory.list_hosts(play.hosts)
393
+        all_hosts = self._list_available_hosts()
394 394
         play.update_vars_files(all_hosts)
395 395
 
396 396
         serialized_batch = []
... ...
@@ -425,8 +431,7 @@ class PlayBook(object):
425 425
                         # just didn't match anything and that's ok
426 426
                         return False
427 427
 
428
-                host_list = [ h for h in self.inventory.list_hosts(play.hosts)
429
-                    if not (h in self.stats.failures or h in self.stats.dark) ]
428
+                host_list = self._list_available_hosts()
430 429
 
431 430
                 # if no hosts remain, drop out
432 431
                 if not host_list: