Properly fail out of the task loop in the linear strategy on failures (v2)
This commit is contained in:
parent
fba5588028
commit
8fae2abed4
3 changed files with 19 additions and 1 deletions
|
@ -117,15 +117,17 @@ class PlaybookExecutor:
|
||||||
if len(batch) == 0:
|
if len(batch) == 0:
|
||||||
self._tqm.send_callback('v2_playbook_on_play_start', new_play)
|
self._tqm.send_callback('v2_playbook_on_play_start', new_play)
|
||||||
self._tqm.send_callback('v2_playbook_on_no_hosts_matched')
|
self._tqm.send_callback('v2_playbook_on_no_hosts_matched')
|
||||||
result = 0
|
result = 1
|
||||||
break
|
break
|
||||||
# restrict the inventory to the hosts in the serialized batch
|
# restrict the inventory to the hosts in the serialized batch
|
||||||
self._inventory.restrict_to_hosts(batch)
|
self._inventory.restrict_to_hosts(batch)
|
||||||
# and run it...
|
# and run it...
|
||||||
result = self._tqm.run(play=play)
|
result = self._tqm.run(play=play)
|
||||||
|
# if the last result wasn't zero, break out of the serial batch loop
|
||||||
if result != 0:
|
if result != 0:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
# if the last result wasn't zero, break out of the play loop
|
||||||
if result != 0:
|
if result != 0:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -134,6 +136,10 @@ class PlaybookExecutor:
|
||||||
if entry:
|
if entry:
|
||||||
entrylist.append(entry) # per playbook
|
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:
|
if entrylist:
|
||||||
return entrylist
|
return entrylist
|
||||||
|
|
||||||
|
|
|
@ -226,6 +226,9 @@ class StrategyModule(StrategyBase):
|
||||||
# FIXME: this should also be moved to the base class in a method
|
# FIXME: this should also be moved to the base class in a method
|
||||||
included_files = []
|
included_files = []
|
||||||
for res in host_results:
|
for res in host_results:
|
||||||
|
if res.is_failed():
|
||||||
|
return 1
|
||||||
|
|
||||||
if res._task.action == 'include':
|
if res._task.action == 'include':
|
||||||
if res._task.loop:
|
if res._task.loop:
|
||||||
include_results = res._result['results']
|
include_results = res._result['results']
|
||||||
|
|
9
samples/test_play_failure.yml
Normal file
9
samples/test_play_failure.yml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
- hosts: localhost
|
||||||
|
gather_facts: no
|
||||||
|
tasks:
|
||||||
|
- fail:
|
||||||
|
|
||||||
|
- hosts: localhost
|
||||||
|
gather_facts: no
|
||||||
|
tasks:
|
||||||
|
- debug: msg="you should not see me..."
|
Loading…
Reference in a new issue