1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

intg tests for 'any_errors_fatal' (#25813)

* start adding intg tests for any_errors_fatal

* updates

* show captured output

flip conditional for on_includes

* cleanup/ci poke

* fix typos

* Add 'EXPECTED FAILURE' to tasks names for expected failures
This commit is contained in:
Adrian Likins 2018-01-29 15:47:13 -05:00 committed by ansibot
parent 923174a856
commit b20ba105c2
7 changed files with 107 additions and 0 deletions

View file

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

View file

@ -0,0 +1 @@
posix/ci/group3

View file

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

View file

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

View file

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

View file

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

View file

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