summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSloane Hertel <19572925+s-hertel@users.noreply.github.com>2024-10-29 16:32:17 +0100
committerGitHub <noreply@github.com>2024-10-29 16:32:17 +0100
commita3b58fb67c98e9f4c81beb73bebb616295d0803f (patch)
treeb51e2d5788ee6e79c74c4c3c473f100bf6e8f4b1
parentRemove deprecated pycompat24 and importlib (#84161) (diff)
downloadansible-a3b58fb67c98e9f4c81beb73bebb616295d0803f.tar.xz
ansible-a3b58fb67c98e9f4c81beb73bebb616295d0803f.zip
Add a test using ignore_errors as a variable (#84175)
* Add a regression test for https://github.com/ansible/ansible/issues/32384
-rw-r--r--test/integration/targets/ignore_errors/meta/main.yml2
-rwxr-xr-xtest/integration/targets/ignore_errors/runme.sh11
-rw-r--r--test/integration/targets/ignore_errors/test_ignore_errors.yml4
-rw-r--r--test/integration/targets/ignore_errors/test_ignore_errors_false.yml18
4 files changed, 33 insertions, 2 deletions
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 07faa21776..0000000000
--- 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 0000000000..efdf1edd7a
--- /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 0000000000..7092048d47
--- /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 0000000000..76ca9d697d
--- /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