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:
Jordan Borean
2019-02-26 16:22:32 +10:00
committed by GitHub
parent 344a81daec
commit d55ddec923
5 changed files with 23 additions and 3 deletions

View File

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

View File

@@ -0,0 +1,9 @@
- block:
- name: EXPECTED FAILURE
fail:
msg: failure
always:
- name: run always task
debug:
msg: TEST COMPLETE

View File

@@ -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' ')" ]