Skip to content

Commit

Permalink
Properly fail out of the task loop in the linear strategy on failures…
Browse files Browse the repository at this point in the history
… (v2)
  • Loading branch information
jimi-c committed May 5, 2015
1 parent fba5588 commit 8fae2ab
Showing 3 changed files with 19 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/ansible/executor/playbook_executor.py
Original file line number Diff line number Diff line change
@@ -117,15 +117,17 @@ def run(self):
if len(batch) == 0:
self._tqm.send_callback('v2_playbook_on_play_start', new_play)
self._tqm.send_callback('v2_playbook_on_no_hosts_matched')
result = 0
result = 1
break
# restrict the inventory to the hosts in the serialized batch
self._inventory.restrict_to_hosts(batch)
# and run it...
result = self._tqm.run(play=play)
# if the last result wasn't zero, break out of the serial batch loop
if result != 0:
break

# if the last result wasn't zero, break out of the play loop
if result != 0:
break

@@ -134,6 +136,10 @@ def run(self):
if entry:
entrylist.append(entry) # per playbook

# if the last result wasn't zero, break out of the playbook file name loop
if result != 0:
break

if entrylist:
return entrylist

3 changes: 3 additions & 0 deletions lib/ansible/plugins/strategies/linear.py
Original file line number Diff line number Diff line change
@@ -226,6 +226,9 @@ def __repr__(self):
# FIXME: this should also be moved to the base class in a method
included_files = []
for res in host_results:
if res.is_failed():
return 1

if res._task.action == 'include':
if res._task.loop:
include_results = res._result['results']
9 changes: 9 additions & 0 deletions samples/test_play_failure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- hosts: localhost
gather_facts: no
tasks:
- fail:

- hosts: localhost
gather_facts: no
tasks:
- debug: msg="you should not see me..."

0 comments on commit 8fae2ab

Please sign in to comment.