Add a test using ignore_errors as a variable (#84175)

* Add a regression test for https://github.com/ansible/ansible/issues/32384
pull/75742/head
Sloane Hertel 3 weeks ago committed by GitHub
parent 3a40ba3b2c
commit a3b58fb67c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,2 +0,0 @@
dependencies:
- prepare_tests

@ -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'

@ -0,0 +1,4 @@
- hosts: all
tasks:
- include_tasks:
file: tasks/main.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
Loading…
Cancel
Save