diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:04:21 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:04:21 +0000 |
commit | 8a754e0858d922e955e71b253c139e071ecec432 (patch) | |
tree | 527d16e74bfd1840c85efd675fdecad056c54107 /test/integration/targets/blocks | |
parent | Initial commit. (diff) | |
download | ansible-core-c3bc180c49b5e6182a7c66bb8b645fe013614adc.tar.xz ansible-core-c3bc180c49b5e6182a7c66bb8b645fe013614adc.zip |
Adding upstream version 2.14.3.upstream/2.14.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
30 files changed, 591 insertions, 0 deletions
diff --git a/test/integration/targets/blocks/43191-2.yml b/test/integration/targets/blocks/43191-2.yml new file mode 100644 index 0000000..4beda4e --- /dev/null +++ b/test/integration/targets/blocks/43191-2.yml @@ -0,0 +1,17 @@ +- hosts: localhost + gather_facts: false + tasks: + - block: + - block: + - name: EXPECTED FAILURE + fail: + always: + - block: + - debug: + always: + - debug: + rescue: + - assert: + that: + - ansible_failed_task is defined + - ansible_failed_result is defined diff --git a/test/integration/targets/blocks/43191.yml b/test/integration/targets/blocks/43191.yml new file mode 100644 index 0000000..d69e438 --- /dev/null +++ b/test/integration/targets/blocks/43191.yml @@ -0,0 +1,18 @@ +- hosts: localhost + gather_facts: false + tasks: + - block: + - block: + - name: EXPECTED FAILURE + fail: + always: + - block: + - block: + - debug: + rescue: + - block: + - block: + - assert: + that: + - ansible_failed_task is defined + - ansible_failed_result is defined diff --git a/test/integration/targets/blocks/69848.yml b/test/integration/targets/blocks/69848.yml new file mode 100644 index 0000000..3b43eeb --- /dev/null +++ b/test/integration/targets/blocks/69848.yml @@ -0,0 +1,5 @@ +- hosts: host1,host2 + gather_facts: no + roles: + - role-69848-1 + - role-69848-2 diff --git a/test/integration/targets/blocks/72725.yml b/test/integration/targets/blocks/72725.yml new file mode 100644 index 0000000..54a70c6 --- /dev/null +++ b/test/integration/targets/blocks/72725.yml @@ -0,0 +1,24 @@ +- hosts: host1,host2 + gather_facts: no + tasks: + - block: + - block: + - name: EXPECTED FAILURE host1 fails + fail: + when: inventory_hostname == 'host1' + + - set_fact: + only_host2_fact: yes + + - name: should not fail + fail: + when: only_host2_fact is not defined + always: + - block: + - meta: clear_host_errors + + - assert: + that: + - only_host2_fact is defined + when: + - inventory_hostname == 'host2' diff --git a/test/integration/targets/blocks/72781.yml b/test/integration/targets/blocks/72781.yml new file mode 100644 index 0000000..f124cce --- /dev/null +++ b/test/integration/targets/blocks/72781.yml @@ -0,0 +1,13 @@ +- hosts: all + gather_facts: no + any_errors_fatal: true + tasks: + - block: + - block: + - fail: + when: inventory_hostname == 'host1' + rescue: + - fail: + - block: + - debug: + msg: "SHOULD NOT HAPPEN" diff --git a/test/integration/targets/blocks/78612.yml b/test/integration/targets/blocks/78612.yml new file mode 100644 index 0000000..38efc6b --- /dev/null +++ b/test/integration/targets/blocks/78612.yml @@ -0,0 +1,16 @@ +- hosts: all + gather_facts: false + tasks: + - block: + - fail: + when: inventory_hostname == 'host1' + rescue: + - block: + - fail: + when: inventory_hostname == 'host1' + + - assert: + that: + - "'host1' not in ansible_play_hosts" + - "'host1' not in ansible_play_batch" + success_msg: PASSED diff --git a/test/integration/targets/blocks/79711.yml b/test/integration/targets/blocks/79711.yml new file mode 100644 index 0000000..ca9bfbb --- /dev/null +++ b/test/integration/targets/blocks/79711.yml @@ -0,0 +1,17 @@ +- hosts: localhost + gather_facts: false + tasks: + - block: + - block: + - debug: + - name: EXPECTED FAILURE + fail: + rescue: + - debug: + - debug: + - name: EXPECTED FAILURE + fail: + always: + - debug: + always: + - debug: diff --git a/test/integration/targets/blocks/aliases b/test/integration/targets/blocks/aliases new file mode 100644 index 0000000..1d28bdb --- /dev/null +++ b/test/integration/targets/blocks/aliases @@ -0,0 +1,2 @@ +shippable/posix/group5 +context/controller diff --git a/test/integration/targets/blocks/always_failure_no_rescue_rc.yml b/test/integration/targets/blocks/always_failure_no_rescue_rc.yml new file mode 100644 index 0000000..924643c --- /dev/null +++ b/test/integration/targets/blocks/always_failure_no_rescue_rc.yml @@ -0,0 +1,13 @@ +- hosts: localhost + gather_facts: no + tasks: + - block: + - name: EXPECTED FAILURE + fail: + msg: Failure in block + always: + - name: EXPECTED FAILURE + fail: + msg: Failure in always + - debug: + msg: DID NOT RUN diff --git a/test/integration/targets/blocks/always_failure_with_rescue_rc.yml b/test/integration/targets/blocks/always_failure_with_rescue_rc.yml new file mode 100644 index 0000000..f3029cb --- /dev/null +++ b/test/integration/targets/blocks/always_failure_with_rescue_rc.yml @@ -0,0 +1,16 @@ +- hosts: localhost + gather_facts: no + tasks: + - block: + - name: EXPECTED FAILURE + fail: + msg: Failure in block + rescue: + - debug: + msg: Rescue + always: + - name: EXPECTED FAILURE + fail: + msg: Failure in always + - debug: + msg: DID NOT RUN diff --git a/test/integration/targets/blocks/always_no_rescue_rc.yml b/test/integration/targets/blocks/always_no_rescue_rc.yml new file mode 100644 index 0000000..a4e8641 --- /dev/null +++ b/test/integration/targets/blocks/always_no_rescue_rc.yml @@ -0,0 +1,12 @@ +- hosts: localhost + gather_facts: no + tasks: + - block: + - name: EXPECTED FAILURE + fail: + msg: Failure in block + always: + - debug: + msg: Always + - debug: + msg: DID NOT RUN diff --git a/test/integration/targets/blocks/block_fail.yml b/test/integration/targets/blocks/block_fail.yml new file mode 100644 index 0000000..6b84d05 --- /dev/null +++ b/test/integration/targets/blocks/block_fail.yml @@ -0,0 +1,5 @@ +--- +- name: Include tasks that have a failure in a block + hosts: localhost + tasks: + - include_tasks: block_fail_tasks.yml diff --git a/test/integration/targets/blocks/block_fail_tasks.yml b/test/integration/targets/blocks/block_fail_tasks.yml new file mode 100644 index 0000000..6e70dc2 --- /dev/null +++ b/test/integration/targets/blocks/block_fail_tasks.yml @@ -0,0 +1,9 @@ +- block: + - name: EXPECTED FAILURE + fail: + msg: failure + + always: + - name: run always task + debug: + msg: TEST COMPLETE diff --git a/test/integration/targets/blocks/block_in_rescue.yml b/test/integration/targets/blocks/block_in_rescue.yml new file mode 100644 index 0000000..1536030 --- /dev/null +++ b/test/integration/targets/blocks/block_in_rescue.yml @@ -0,0 +1,33 @@ +- hosts: localhost + gather_facts: no + tasks: + - block: + - name: "EXPECTED FAILURE" + fail: + msg: "fail to test single level block in rescue" + rescue: + - block: + - debug: + msg: Rescued! + + - block: + - name: "EXPECTED FAILURE" + fail: + msg: "fail to test multi-level block in rescue" + rescue: + - block: + - block: + - debug: + msg: Rescued! + + - name: "Outer block" + block: + - name: "Inner block" + block: + - name: "EXPECTED FAILURE" + fail: + msg: "fail to test multi-level block" + rescue: + - name: "Rescue block" + block: + - debug: msg="Inner block rescue" diff --git a/test/integration/targets/blocks/block_rescue_vars.yml b/test/integration/targets/blocks/block_rescue_vars.yml new file mode 100644 index 0000000..404f7a3 --- /dev/null +++ b/test/integration/targets/blocks/block_rescue_vars.yml @@ -0,0 +1,16 @@ +- hosts: localhost + gather_facts: no + tasks: + - block: + - name: EXPECTED FAILURE + fail: + rescue: + - name: Assert that ansible_failed_task is defined + assert: + that: + - ansible_failed_task is defined + + - name: Assert that ansible_failed_result is defined + assert: + that: + - ansible_failed_result is defined diff --git a/test/integration/targets/blocks/fail.yml b/test/integration/targets/blocks/fail.yml new file mode 100644 index 0000000..ae94655 --- /dev/null +++ b/test/integration/targets/blocks/fail.yml @@ -0,0 +1,2 @@ +- name: EXPECTED FAILURE + fail: msg="{{msg}}" diff --git a/test/integration/targets/blocks/finalized_task.yml b/test/integration/targets/blocks/finalized_task.yml new file mode 100644 index 0000000..300401b --- /dev/null +++ b/test/integration/targets/blocks/finalized_task.yml @@ -0,0 +1,17 @@ +- hosts: localhost + gather_facts: false + tasks: + - block: + - include_role: + name: '{{ item }}' + loop: + - fail + rescue: + - debug: + msg: "{{ ansible_failed_task.name }}" + + - assert: + that: + - ansible_failed_task.name == "Fail" + - ansible_failed_task.action == "fail" + - ansible_failed_task.parent is not defined diff --git a/test/integration/targets/blocks/inherit_notify.yml b/test/integration/targets/blocks/inherit_notify.yml new file mode 100644 index 0000000..d8e8742 --- /dev/null +++ b/test/integration/targets/blocks/inherit_notify.yml @@ -0,0 +1,19 @@ +- hosts: localhost + gather_facts: false + tasks: + - name: test notify inheritance in block + notify: hello + block: + - debug: msg='trigger it' + changed_when: true + + handlers: + - name: hello + set_fact: hello=world + + post_tasks: + - name: ensure handler ran + assert: + that: + - hello is defined + - "hello == 'world'" diff --git a/test/integration/targets/blocks/issue29047.yml b/test/integration/targets/blocks/issue29047.yml new file mode 100644 index 0000000..9743773 --- /dev/null +++ b/test/integration/targets/blocks/issue29047.yml @@ -0,0 +1,4 @@ +- hosts: localhost + gather_facts: no + tasks: + - include_tasks: issue29047_tasks.yml diff --git a/test/integration/targets/blocks/issue29047_tasks.yml b/test/integration/targets/blocks/issue29047_tasks.yml new file mode 100644 index 0000000..3470d86 --- /dev/null +++ b/test/integration/targets/blocks/issue29047_tasks.yml @@ -0,0 +1,13 @@ +--- +- name: "EXPECTED FAILURE" + block: + - fail: + msg: "EXPECTED FAILURE" + rescue: + - name: Assert that ansible_failed_task is defined + assert: + that: ansible_failed_task is defined + + - name: Assert that ansible_failed_result is defined + assert: + that: ansible_failed_result is defined diff --git a/test/integration/targets/blocks/issue71306.yml b/test/integration/targets/blocks/issue71306.yml new file mode 100644 index 0000000..9762f6e --- /dev/null +++ b/test/integration/targets/blocks/issue71306.yml @@ -0,0 +1,16 @@ +- hosts: all + gather_facts: no + tasks: + - block: + - block: + - block: + - name: EXPECTED FAILURE + fail: + when: ansible_host == "host1" + + - debug: + msg: "I am successful!" + run_once: true + rescue: + - debug: + msg: "Attemp 1 failed!" diff --git a/test/integration/targets/blocks/main.yml b/test/integration/targets/blocks/main.yml new file mode 100644 index 0000000..efe358a --- /dev/null +++ b/test/integration/targets/blocks/main.yml @@ -0,0 +1,128 @@ +- name: simple block test + hosts: testhost + gather_facts: yes + strategy: "{{test_strategy|default('linear')}}" + vars: + block_tasks_run: false + block_rescue_run: false + block_always_run: false + nested_block_always_run: false + 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 + set_fact: + block_tasks_run: true + - name: EXPECTED FAILURE fail in tasks + fail: + - name: tasks flag should not be set after failure + set_fact: + tasks_run_after_failure: true + rescue: + - name: set block rescue run flag + set_fact: + block_rescue_run: true + - name: EXPECTED FAILURE fail in rescue + fail: + - name: tasks flag should not be set after failure in rescue + set_fact: + rescue_run_after_failure: true + always: + - name: set block always run flag + set_fact: + block_always_run: true + #- block: + # - meta: noop + # always: + # - name: set nested block always run flag + # set_fact: + # nested_block_always_run: true + # - name: fail in always + # fail: + # - name: tasks flag should not be set after failure in always + # set_fact: + # 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 + + - block: + - block: + - name: EXPECTED FAILURE test triggering always by failing in nested block with any_errors_fatal set + fail: + any_errors_fatal: true + always: + - name: set block fail always run flag + set_fact: + nested_block_fail_always: true + - meta: clear_host_errors + + post_tasks: + - assert: + that: + - block_tasks_run + - block_rescue_run + - block_always_run + #- nested_block_always_run + - 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 + hosts: testhost + gather_facts: yes + strategy: "{{test_strategy|default('linear')}}" + vars: + rescue_run_after_include_fail: false + always_run_after_include_fail_in_rescue: false + tasks_run_after_failure: false + rescue_run_after_failure: false + always_run_after_failure: false + tasks: + - block: + - name: include fail.yml in tasks + import_tasks: fail.yml + vars: + msg: "failed from tasks" + - name: tasks flag should not be set after failure + set_fact: + tasks_run_after_failure: true + rescue: + - set_fact: + rescue_run_after_include_fail: true + - name: include fail.yml in rescue + import_tasks: fail.yml + vars: + msg: "failed from rescue" + - name: flag should not be set after failure in rescue + set_fact: + rescue_run_after_failure: true + always: + - set_fact: + always_run_after_include_fail_in_rescue: true + - meta: clear_host_errors + + post_tasks: + - assert: + that: + - rescue_run_after_include_fail + - always_run_after_include_fail_in_rescue + - not tasks_run_after_failure + - not rescue_run_after_failure + - not always_run_after_failure + - debug: msg="TEST COMPLETE" diff --git a/test/integration/targets/blocks/nested_fail.yml b/test/integration/targets/blocks/nested_fail.yml new file mode 100644 index 0000000..12e33cb --- /dev/null +++ b/test/integration/targets/blocks/nested_fail.yml @@ -0,0 +1,3 @@ +- import_tasks: fail.yml + vars: + msg: "nested {{msg}}" diff --git a/test/integration/targets/blocks/nested_nested_fail.yml b/test/integration/targets/blocks/nested_nested_fail.yml new file mode 100644 index 0000000..f63fa5c --- /dev/null +++ b/test/integration/targets/blocks/nested_nested_fail.yml @@ -0,0 +1,3 @@ +- import_tasks: nested_fail.yml + vars: + msg: "nested {{msg}}" diff --git a/test/integration/targets/blocks/roles/fail/tasks/main.yml b/test/integration/targets/blocks/roles/fail/tasks/main.yml new file mode 100644 index 0000000..176fe54 --- /dev/null +++ b/test/integration/targets/blocks/roles/fail/tasks/main.yml @@ -0,0 +1,3 @@ +- name: Fail + fail: + msg: fail diff --git a/test/integration/targets/blocks/roles/role-69848-1/meta/main.yml b/test/integration/targets/blocks/roles/role-69848-1/meta/main.yml new file mode 100644 index 0000000..d34d662 --- /dev/null +++ b/test/integration/targets/blocks/roles/role-69848-1/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - role: role-69848-3 diff --git a/test/integration/targets/blocks/roles/role-69848-2/meta/main.yml b/test/integration/targets/blocks/roles/role-69848-2/meta/main.yml new file mode 100644 index 0000000..d34d662 --- /dev/null +++ b/test/integration/targets/blocks/roles/role-69848-2/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - role: role-69848-3 diff --git a/test/integration/targets/blocks/roles/role-69848-3/tasks/main.yml b/test/integration/targets/blocks/roles/role-69848-3/tasks/main.yml new file mode 100644 index 0000000..0d01b74 --- /dev/null +++ b/test/integration/targets/blocks/roles/role-69848-3/tasks/main.yml @@ -0,0 +1,8 @@ +- block: + - debug: + msg: Tagged task + tags: + - foo + +- debug: + msg: Not tagged task diff --git a/test/integration/targets/blocks/runme.sh b/test/integration/targets/blocks/runme.sh new file mode 100755 index 0000000..820107b --- /dev/null +++ b/test/integration/targets/blocks/runme.sh @@ -0,0 +1,138 @@ +#!/usr/bin/env bash + +set -eux + +# This test does not use "$@" to avoid further increasing the verbosity beyond what is required for the test. +# Increasing verbosity from -vv to -vvv can increase the line count from ~400 to ~9K on our centos6 test container. + +# remove old output log +rm -f block_test.out +# run the test and check to make sure the right number of completions was logged +ansible-playbook -vv main.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)" = "$(grep -E '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ] +# cleanup the output log again, to make sure the test is clean +rm -f block_test.out block_test_wo_colors.out +# run test with free strategy and again count the completions +ansible-playbook -vv main.yml -i ../../inventory -e test_strategy=free | 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)" = "$(grep -E '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ] +# cleanup the output log again, to make sure the test is clean +rm -f block_test.out block_test_wo_colors.out +# run test with host_pinned strategy and again count the completions +ansible-playbook -vv main.yml -i ../../inventory -e test_strategy=host_pinned | 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)" = "$(grep -E '^[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)" = "$(grep -E '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ] + +ansible-playbook -vv block_rescue_vars.yml + +# https://github.com/ansible/ansible/issues/70000 +set +e +exit_code=0 +ansible-playbook -vv always_failure_with_rescue_rc.yml > rc_test.out || exit_code=$? +set -e +cat rc_test.out +[ $exit_code -eq 2 ] +[ "$(grep -c 'Failure in block' rc_test.out )" -eq 1 ] +[ "$(grep -c 'Rescue' rc_test.out )" -eq 1 ] +[ "$(grep -c 'Failure in always' rc_test.out )" -eq 1 ] +[ "$(grep -c 'DID NOT RUN' rc_test.out )" -eq 0 ] +rm -f rc_test_out + +set +e +exit_code=0 +ansible-playbook -vv always_no_rescue_rc.yml > rc_test.out || exit_code=$? +set -e +cat rc_test.out +[ $exit_code -eq 2 ] +[ "$(grep -c 'Failure in block' rc_test.out )" -eq 1 ] +[ "$(grep -c 'Always' rc_test.out )" -eq 1 ] +[ "$(grep -c 'DID NOT RUN' rc_test.out )" -eq 0 ] +rm -f rc_test.out + +set +e +exit_code=0 +ansible-playbook -vv always_failure_no_rescue_rc.yml > rc_test.out || exit_code=$? +set -e +cat rc_test.out +[ $exit_code -eq 2 ] +[ "$(grep -c 'Failure in block' rc_test.out )" -eq 1 ] +[ "$(grep -c 'Failure in always' rc_test.out )" -eq 1 ] +[ "$(grep -c 'DID NOT RUN' rc_test.out )" -eq 0 ] +rm -f rc_test.out + +# https://github.com/ansible/ansible/issues/29047 +ansible-playbook -vv issue29047.yml -i ../../inventory + +# https://github.com/ansible/ansible/issues/61253 +ansible-playbook -vv block_in_rescue.yml -i ../../inventory > rc_test.out +cat rc_test.out +[ "$(grep -c 'rescued=3' rc_test.out)" -eq 1 ] +[ "$(grep -c 'failed=0' rc_test.out)" -eq 1 ] +rm -f rc_test.out + +# https://github.com/ansible/ansible/issues/71306 +set +e +exit_code=0 +ansible-playbook -i host1,host2 -vv issue71306.yml > rc_test.out || exit_code=$? +set -e +cat rc_test.out +[ $exit_code -eq 0 ] +rm -f rc_test_out + +# https://github.com/ansible/ansible/issues/69848 +ansible-playbook -i host1,host2 --tags foo -vv 69848.yml > role_complete_test.out +cat role_complete_test.out +[ "$(grep -c 'Tagged task' role_complete_test.out)" -eq 2 ] +[ "$(grep -c 'Not tagged task' role_complete_test.out)" -eq 0 ] +rm -f role_complete_test.out + +# test notify inheritance +ansible-playbook inherit_notify.yml "$@" + +ansible-playbook unsafe_failed_task.yml "$@" + +ansible-playbook finalized_task.yml "$@" + +# https://github.com/ansible/ansible/issues/72725 +ansible-playbook -i host1,host2 -vv 72725.yml + +# https://github.com/ansible/ansible/issues/72781 +set +e +ansible-playbook -i host1,host2 -vv 72781.yml > 72781.out +set -e +cat 72781.out +[ "$(grep -c 'SHOULD NOT HAPPEN' 72781.out)" -eq 0 ] +rm -f 72781.out + +set +e +ansible-playbook -i host1,host2 -vv 78612.yml | tee 78612.out +set -e +[ "$(grep -c 'PASSED' 78612.out)" -eq 1 ] +rm -f 78612.out + +ansible-playbook -vv 43191.yml +ansible-playbook -vv 43191-2.yml + +# https://github.com/ansible/ansible/issues/79711 +set +e +ANSIBLE_FORCE_HANDLERS=0 ansible-playbook -vv 79711.yml | tee 79711.out +set -e +[ "$(grep -c 'ok=5' 79711.out)" -eq 1 ] +[ "$(grep -c 'failed=1' 79711.out)" -eq 1 ] +[ "$(grep -c 'rescued=1' 79711.out)" -eq 1 ] +rm -f 79711.out diff --git a/test/integration/targets/blocks/unsafe_failed_task.yml b/test/integration/targets/blocks/unsafe_failed_task.yml new file mode 100644 index 0000000..adfa492 --- /dev/null +++ b/test/integration/targets/blocks/unsafe_failed_task.yml @@ -0,0 +1,17 @@ +- hosts: localhost + gather_facts: false + vars: + - data: {} + tasks: + - block: + - name: template error + debug: + msg: "{{ data.value }}" + rescue: + - debug: + msg: "{{ ansible_failed_task.action }}" + + - assert: + that: + - ansible_failed_task.name == "template error" + - ansible_failed_task.action == "debug" |