mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Revert Clear failed state in always only if we did rescue (#52968)
* Revert "Clear failed state in always only if we did rescue (#52829)"
This reverts commit f135960fc2
.
* Add tests for failed scenario
* Set failed task with EXPECTED FAILURE
This commit is contained in:
parent
344a81daec
commit
d55ddec923
5 changed files with 23 additions and 3 deletions
|
@ -1,2 +0,0 @@
|
||||||
bugfixes:
|
|
||||||
- Fix handlers on failed hosts with always section (https://github.com/ansible/ansible/issues/52561)
|
|
|
@ -484,7 +484,7 @@ class PlayIterator:
|
||||||
elif state.fail_state != self.FAILED_NONE:
|
elif state.fail_state != self.FAILED_NONE:
|
||||||
if state.run_state == self.ITERATING_RESCUE and state.fail_state & self.FAILED_RESCUE == 0:
|
if state.run_state == self.ITERATING_RESCUE and state.fail_state & self.FAILED_RESCUE == 0:
|
||||||
return False
|
return False
|
||||||
elif state.run_state == self.ITERATING_ALWAYS and state.fail_state & self.FAILED_ALWAYS == 0 and state.did_rescue:
|
elif state.run_state == self.ITERATING_ALWAYS and state.fail_state & self.FAILED_ALWAYS == 0:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return not state.did_rescue
|
return not state.did_rescue
|
||||||
|
|
5
test/integration/targets/blocks/block_fail.yml
Normal file
5
test/integration/targets/blocks/block_fail.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
- name: Include tasks that have a failure in a block
|
||||||
|
hosts: localhost
|
||||||
|
tasks:
|
||||||
|
- include_tasks: block_fail_tasks.yml
|
9
test/integration/targets/blocks/block_fail_tasks.yml
Normal file
9
test/integration/targets/blocks/block_fail_tasks.yml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
- block:
|
||||||
|
- name: EXPECTED FAILURE
|
||||||
|
fail:
|
||||||
|
msg: failure
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: run always task
|
||||||
|
debug:
|
||||||
|
msg: TEST COMPLETE
|
|
@ -26,3 +26,11 @@ env python -c \
|
||||||
'import sys, re; sys.stdout.write(re.sub("\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "", sys.stdin.read()))' \
|
'import sys, re; sys.stdout.write(re.sub("\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "", sys.stdin.read()))' \
|
||||||
<block_test.out >block_test_wo_colors.out
|
<block_test.out >block_test_wo_colors.out
|
||||||
[ "$(grep -c 'TEST COMPLETE' block_test.out)" = "$(egrep '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ]
|
[ "$(grep -c 'TEST COMPLETE' block_test.out)" = "$(egrep '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ]
|
||||||
|
|
||||||
|
# run test that includes tasks that fail inside a block with always
|
||||||
|
rm -f block_test.out block_test_wo_colors.out
|
||||||
|
ansible-playbook -vv block_fail.yml -i ../../inventory "$@" | tee block_test.out
|
||||||
|
env python -c \
|
||||||
|
'import sys, re; sys.stdout.write(re.sub("\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "", sys.stdin.read()))' \
|
||||||
|
<block_test.out >block_test_wo_colors.out
|
||||||
|
[ "$(grep -c 'TEST COMPLETE' block_test.out)" = "$(egrep '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ]
|
||||||
|
|
Loading…
Reference in a new issue