diff --git a/test/integration/targets/any_errors_fatal/18602.yml b/test/integration/targets/any_errors_fatal/18602.yml new file mode 100644 index 00000000000..66bcb88b6fb --- /dev/null +++ b/test/integration/targets/any_errors_fatal/18602.yml @@ -0,0 +1,21 @@ +--- + - hosts: localhost + any_errors_fatal: true + tasks: + - block: + - debug: msg='i execute normally' + - name: EXPECTED FAILURE primary block command + command: /bin/false + - debug: msg='i never execute, cause ERROR!' + rescue: + - name: rescue block debug + debug: msg='I caught an error' + - name: EXPECTED FAILURE rescue block command + command: /bin/false + - debug: msg='I also never execute :-(' + always: + - name: A debug task in the always block + debug: msg="this always executes" + + - set_fact: + always_ran: true diff --git a/test/integration/targets/any_errors_fatal/aliases b/test/integration/targets/any_errors_fatal/aliases new file mode 100644 index 00000000000..79d8b9285eb --- /dev/null +++ b/test/integration/targets/any_errors_fatal/aliases @@ -0,0 +1 @@ +posix/ci/group3 diff --git a/test/integration/targets/any_errors_fatal/always_block.yml b/test/integration/targets/any_errors_fatal/always_block.yml new file mode 100644 index 00000000000..8c6fbffa96a --- /dev/null +++ b/test/integration/targets/any_errors_fatal/always_block.yml @@ -0,0 +1,27 @@ +--- +- hosts: testhost + gather_facts: false + any_errors_fatal: true + tasks: + - block: + - name: initial block debug + debug: msg='any_errors_fatal_block, i execute normally' + + - name: EXPECTED FAILURE any_errors_fatal, initial block, bin/false to simulate failure + command: /bin/false + + - name: after a task that fails I should never execute + debug: + msg: 'any_errors_fatal_block_post_fail ... i never execute, cause ERROR!' + rescue: + - name: any_errors_fatal_rescue_block debug + debug: msg='any_errors_fatal_rescue_block_start ... I caught an error' + + - name: EXPECTED FAILURE any_errors_fatal in rescue block, using bin/false to simulate error + command: /bin/false + + - name: any_errors_fatal post debug + debug: msg='any_errors_fatal_rescue_block_post_fail ... I also never execute :-(' + always: + - name: any errors fatal always block debug + debug: msg='any_errors_fatal_always_block_start' diff --git a/test/integration/targets/any_errors_fatal/on_includes.yml b/test/integration/targets/any_errors_fatal/on_includes.yml new file mode 100644 index 00000000000..cc5a355971f --- /dev/null +++ b/test/integration/targets/any_errors_fatal/on_includes.yml @@ -0,0 +1,9 @@ +--- +# based on https://github.com/ansible/ansible/issues/22924 +- name: Test any errors fatal + hosts: testhost + any_errors_fatal: True + tasks: + - include: test_fatal.yml + # tags: + # - any_errors_fatal_includes diff --git a/test/integration/targets/any_errors_fatal/play_level.yml b/test/integration/targets/any_errors_fatal/play_level.yml new file mode 100644 index 00000000000..d5a89206df1 --- /dev/null +++ b/test/integration/targets/any_errors_fatal/play_level.yml @@ -0,0 +1,15 @@ +- hosts: testhost + gather_facts: no + any_errors_fatal: true + tasks: + - name: EXPECTED FAILURE shell exe of /bin/false for testhost + shell: '{{ "/bin/false" if inventory_hostname == "testhost" else "/bin/true" }}' + + - debug: + msg: "any_errors_fatal_play_level_post_fail" + +- hosts: testhost + any_errors_fatal: true + tasks: + - debug: + msg: "and in another play" diff --git a/test/integration/targets/any_errors_fatal/runme.sh b/test/integration/targets/any_errors_fatal/runme.sh new file mode 100755 index 00000000000..1eb9948a0ac --- /dev/null +++ b/test/integration/targets/any_errors_fatal/runme.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -ux +ansible-playbook -i ../../inventory -e @../../integration_config.yml "$@" play_level.yml| tee out.txt | grep 'any_errors_fatal_play_level_post_fail' +res=$? +cat out.txt +if [ "${res}" -eq 0 ] ; then + exit 1 +fi + +ansible-playbook -i ../../inventory -e @../../integration_config.yml "$@" on_includes.yml | tee out.txt | grep 'any_errors_fatal_this_should_never_be_reached' +res=$? +cat out.txt +if [ "${res}" -eq 0 ] ; then + exit 1 +fi + +set -ux + +ansible-playbook -i ../../inventory -e @../../integration_config.yml "$@" always_block.yml | tee out.txt | grep 'any_errors_fatal_always_block_start' +res=$? +cat out.txt +exit $res diff --git a/test/integration/targets/any_errors_fatal/test_fatal.yml b/test/integration/targets/any_errors_fatal/test_fatal.yml new file mode 100644 index 00000000000..c8bfa9ccef4 --- /dev/null +++ b/test/integration/targets/any_errors_fatal/test_fatal.yml @@ -0,0 +1,11 @@ +--- +- name: Setting the fact for 'test' to 'test value' + set_fact: + test: "test value" + when: "inventory_hostname == groups.all.0" + +- name: EXPECTED FAILURE echo jinja eval of a var that should not exist + shell: "echo {{ test }}" + +- debug: + msg: "any_errors_fatal_this_should_never_be_reached"