mirror of
https://github.com/ansible/ansible.git
synced 2026-08-03 08:03:05 +02:00
test: error handling in include_role (#84737)
Signed-off-by: Abhijeet Kasurde <Akasurde@redhat.com>
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
---
|
||||
- hosts: all
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- block:
|
||||
- name: Setup
|
||||
fail:
|
||||
rescue:
|
||||
- name: "Error handler"
|
||||
include_role:
|
||||
name: "error_handler"
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: Check if we get correct failed_task details
|
||||
assert:
|
||||
that:
|
||||
- ansible_failed_task.name == "Setup"
|
||||
- ansible_failed_task.action == "fail"
|
||||
vars:
|
||||
ansible_connection: local
|
||||
@@ -61,3 +61,6 @@ done
|
||||
|
||||
[ "$(ansible localhost -m meta -a end_role 2>&1 | grep -c "ERROR! Cannot execute 'end_role' from outside of a role")" = "1" ]
|
||||
[ "$(ansible-playbook end_role_handler_error.yml 2>&1 | grep -c "ERROR! Cannot execute 'end_role' from a handler")" = "1" ]
|
||||
|
||||
# include_role should work in rescue, even if error is from magic variable templating
|
||||
ansible-playbook 75240.yml -i ../../inventory "$@"
|
||||
|
||||
Reference in New Issue
Block a user