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/any_errors_fatal | |
parent | Initial commit. (diff) | |
download | ansible-core-8a754e0858d922e955e71b253c139e071ecec432.tar.xz ansible-core-8a754e0858d922e955e71b253c139e071ecec432.zip |
Adding upstream version 2.14.3.upstream/2.14.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
8 files changed, 125 insertions, 0 deletions
diff --git a/test/integration/targets/any_errors_fatal/50897.yml b/test/integration/targets/any_errors_fatal/50897.yml new file mode 100644 index 0000000..1d09eb1 --- /dev/null +++ b/test/integration/targets/any_errors_fatal/50897.yml @@ -0,0 +1,19 @@ +- hosts: testhost,testhost2 + gather_facts: no + any_errors_fatal: yes + tasks: + - name: EXPECTED FAILURE include_role that doesn't exist + include_role: + name: 'non-existant-role' + when: + - inventory_hostname == 'testhost2' + - test_name == 'test_include_role' + + - name: EXPECTED FAILURE include_tasks that don't exist + include_tasks: non-existant.yml + when: + - inventory_hostname == 'testhost2' + - test_name == 'test_include_tasks' + + - debug: + msg: 'any_errors_fatal_this_should_never_be_reached' diff --git a/test/integration/targets/any_errors_fatal/aliases b/test/integration/targets/any_errors_fatal/aliases new file mode 100644 index 0000000..1d28bdb --- /dev/null +++ b/test/integration/targets/any_errors_fatal/aliases @@ -0,0 +1,2 @@ +shippable/posix/group5 +context/controller 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 0000000..8c6fbff --- /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/inventory b/test/integration/targets/any_errors_fatal/inventory new file mode 100644 index 0000000..3ae8d9c --- /dev/null +++ b/test/integration/targets/any_errors_fatal/inventory @@ -0,0 +1,6 @@ +[local] +testhost ansible_connection=local host_var_role_name=role3 +testhost2 ansible_connection=local host_var_role_name=role2 + +[local:vars] +ansible_python_interpreter="{{ ansible_playbook_python }}" 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 0000000..cbc51cb --- /dev/null +++ b/test/integration/targets/any_errors_fatal/on_includes.yml @@ -0,0 +1,7 @@ +--- +# based on https://github.com/ansible/ansible/issues/22924 +- name: Test any errors fatal + hosts: testhost,testhost2 + any_errors_fatal: True + tasks: + - import_tasks: test_fatal.yml 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 0000000..d5a8920 --- /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 0000000..c54ea8d --- /dev/null +++ b/test/integration/targets/any_errors_fatal/runme.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -ux +ansible-playbook -i inventory "$@" 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 "$@" 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 "$@" always_block.yml | tee out.txt | grep 'any_errors_fatal_always_block_start' +res=$? +cat out.txt + +if [ "${res}" -ne 0 ] ; then + exit 1 +fi + +set -ux + +for test_name in test_include_role test_include_tasks; do + ansible-playbook -i inventory "$@" -e test_name=$test_name 50897.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 +done 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 0000000..a12d741 --- /dev/null +++ b/test/integration/targets/any_errors_fatal/test_fatal.yml @@ -0,0 +1,12 @@ +--- +- name: Setting the fact for 'test' to 'test value' + set_fact: + test: "test value" + when: inventory_hostname == 'testhost2' + +- name: EXPECTED FAILURE ejinja eval of a var that should not exist + debug: msg="{{ test }}" + +- name: testhost should never reach here as testhost2 failure above should end play + debug: + msg: "any_errors_fatal_this_should_never_be_reached" |