mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Stop evaluating a host in a playbook when it encounters the first failure.
This commit is contained in:
parent
ada866be46
commit
1caafb7bd9
3 changed files with 14 additions and 2 deletions
|
@ -15,6 +15,9 @@
|
|||
- name: execute bin false
|
||||
comment: call something that will fail just to demo failure counts and such
|
||||
action: command /bin/false
|
||||
- name: execute bin true
|
||||
comment: this will never be executed because previous will fail
|
||||
action: command /bin/true
|
||||
handlers:
|
||||
- name: restart apache
|
||||
action: service name=httpd state=restarted
|
||||
|
|
|
@ -110,6 +110,14 @@ class PlayBook(object):
|
|||
# actions where not all hosts have changed
|
||||
# though top-level tasks will pass in "None" here
|
||||
host_list = self.host_list
|
||||
host_list = ansible.runner.Runner.parse_hosts(host_list)
|
||||
|
||||
# do not continue to run tasks on hosts that have had failures
|
||||
new_hosts = []
|
||||
for x in host_list:
|
||||
if not self.failures.has_key(x):
|
||||
new_hosts.append(x)
|
||||
host_list = new_hosts
|
||||
|
||||
# load the module name and parameters from the task
|
||||
# entry
|
||||
|
|
|
@ -66,7 +66,7 @@ class Runner(object):
|
|||
'''
|
||||
|
||||
# save input values
|
||||
self.host_list = self._parse_hosts(host_list)
|
||||
self.host_list = self.parse_hosts(host_list)
|
||||
self.module_path = module_path
|
||||
self.module_name = module_name
|
||||
self.forks = forks
|
||||
|
@ -78,7 +78,8 @@ class Runner(object):
|
|||
self.remote_pass = remote_pass
|
||||
self._tmp_paths = {}
|
||||
|
||||
def _parse_hosts(self, host_list):
|
||||
@classmethod
|
||||
def parse_hosts(cls, host_list):
|
||||
''' parse the host inventory file if not sent as an array '''
|
||||
|
||||
# if the host list is given as a string load the host list
|
||||
|
|
Loading…
Reference in a new issue