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
pull/52972/head
Jordan Borean 6 years ago committed by GitHub
parent 344a81daec
commit d55ddec923
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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:
if state.run_state == self.ITERATING_RESCUE and state.fail_state & self.FAILED_RESCUE == 0:
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
else:
return not state.did_rescue

@ -0,0 +1,5 @@
---
- name: Include tasks that have a failure in a block
hosts: localhost
tasks:
- include_tasks: block_fail_tasks.yml

@ -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()))' \
<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' ')" ]
# 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…
Cancel
Save