diff --git a/test/integration/targets/ignore_errors/meta/main.yml b/test/integration/targets/ignore_errors/meta/main.yml deleted file mode 100644 index 07faa217762..00000000000 --- a/test/integration/targets/ignore_errors/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: - - prepare_tests diff --git a/test/integration/targets/ignore_errors/runme.sh b/test/integration/targets/ignore_errors/runme.sh new file mode 100755 index 00000000000..efdf1edd7a3 --- /dev/null +++ b/test/integration/targets/ignore_errors/runme.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set -eux + +ansible-playbook -i ../../inventory test_ignore_errors.yml "$@" + +if ansible-playbook -i ../../inventory test_ignore_errors_false.yml "$@" > out.txt; then + echo 'Playbook expected to fail succeeded' + exit 1 +fi +# The first task should fail and not be ignored +grep out.txt -e 'ok=0' | grep 'ignored=0' | grep 'failed=1' diff --git a/test/integration/targets/ignore_errors/test_ignore_errors.yml b/test/integration/targets/ignore_errors/test_ignore_errors.yml new file mode 100644 index 00000000000..7092048d472 --- /dev/null +++ b/test/integration/targets/ignore_errors/test_ignore_errors.yml @@ -0,0 +1,4 @@ +- hosts: all + tasks: + - include_tasks: + file: tasks/main.yml diff --git a/test/integration/targets/ignore_errors/test_ignore_errors_false.yml b/test/integration/targets/ignore_errors/test_ignore_errors_false.yml new file mode 100644 index 00000000000..76ca9d697d3 --- /dev/null +++ b/test/integration/targets/ignore_errors/test_ignore_errors_false.yml @@ -0,0 +1,18 @@ +- name: "Test case for https://github.com/ansible/ansible/issues/32384" + hosts: all + gather_facts: no + vars: + ignore_assertion_errors: false + tasks: + - name: Test using a variable with ignore_errors that evaluates to false + assert: + that: item < 2 + msg: "{{ item }} isn't < 2" + ignore_errors: "{{ ignore_assertion_errors }}" + with_items: + - 1 + - 2 + + - name: Fail if the previous task doesn't end the play + fail: + msg: Previous task was expected to fail