diff --git a/examples/playbook.yml b/examples/playbook.yml index 527c7bf1aa..daf91a028b 100644 --- a/examples/playbook.yml +++ b/examples/playbook.yml @@ -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 diff --git a/lib/ansible/playbook.py b/lib/ansible/playbook.py index be4a6420d0..1acf6d06ad 100755 --- a/lib/ansible/playbook.py +++ b/lib/ansible/playbook.py @@ -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 diff --git a/lib/ansible/runner.py b/lib/ansible/runner.py index f8d5cbcda8..e505ac7640 100755 --- a/lib/ansible/runner.py +++ b/lib/ansible/runner.py @@ -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