summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/ansible/plugins/strategy/linear.py3
-rw-r--r--test/integration/targets/blocks/main.yml14
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/ansible/plugins/strategy/linear.py b/lib/ansible/plugins/strategy/linear.py
index 9bdc1274f4..3409888fa0 100644
--- a/lib/ansible/plugins/strategy/linear.py
+++ b/lib/ansible/plugins/strategy/linear.py
@@ -389,9 +389,10 @@ class StrategyModule(StrategyBase):
# if any_errors_fatal and we had an error, mark all hosts as failed
if any_errors_fatal and (len(failed_hosts) > 0 or len(unreachable_hosts) > 0):
+ dont_fail_states = frozenset([iterator.ITERATING_RESCUE, iterator.ITERATING_ALWAYS])
for host in hosts_left:
(s, _) = iterator.get_next_task_for_host(host, peek=True)
- if s.run_state != iterator.ITERATING_RESCUE or \
+ if s.run_state not in dont_fail_states or \
s.run_state == iterator.ITERATING_RESCUE and s.fail_state & iterator.FAILED_RESCUE != 0:
self._tqm._failed_hosts[host.name] = True
result |= self._tqm.RUN_FAILED_BREAK_PLAY
diff --git a/test/integration/targets/blocks/main.yml b/test/integration/targets/blocks/main.yml
index a80a62b753..496586828f 100644
--- a/test/integration/targets/blocks/main.yml
+++ b/test/integration/targets/blocks/main.yml
@@ -10,6 +10,7 @@
tasks_run_after_failure: false
rescue_run_after_failure: false
always_run_after_failure: false
+ nested_block_fail_always: false
tasks:
- block:
- name: set block tasks run flag
@@ -46,6 +47,18 @@
# always_run_after_failure: true
- meta: clear_host_errors
+ # https://github.com/ansible/ansible/issues/35148
+ - block:
+ - block:
+ - name: EXPECTED FAILURE test triggering always by failing in nested block with run_once set
+ fail:
+ run_once: true
+ always:
+ - name: set block fail always run flag
+ set_fact:
+ nested_block_fail_always: true
+ - meta: clear_host_errors
+
post_tasks:
- assert:
that:
@@ -56,6 +69,7 @@
- not tasks_run_after_failure
- not rescue_run_after_failure
- not always_run_after_failure
+ - nested_block_fail_always
- debug: msg="TEST COMPLETE"
- name: block with includes