# Rescue block doesn't seem to work when error is in an included file

**URL:** <https://forum.ansible.com/t/rescue-block-doesnt-seem-to-work-when-error-is-in-an-included-file/19268>\
**Category:** Ansible Project\
**Created:** [September 15, 2015, 1:03pm UTC](https://forum.ansible.com/t/rescue-block-doesnt-seem-to-work-when-error-is-in-an-included-file/19268 "2015-09-15T13:03:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frank\_Perks](https://avatars.discourse-cdn.com/v4/letter/f/90ced4/32.png) [@Frank\_Perks](https://forum.ansible.com/u/Frank_Perks)\
**Post date:** [September 15, 2015, 1:03pm UTC](https://forum.ansible.com/t/rescue-block-doesnt-seem-to-work-when-error-is-in-an-included-file/19268/1 "2015-09-15T13:03:04Z")

</div>

So i was hoping to use blocks as an easy way to notify success/failure of ansible runs.

- block:

- include: build.yml

- include: deploy\_site.yml

- name: Notify Slack it successfully deployed  
slack: 

- rescue:

- name: Notify Slack it failed  
slack: 

When there is an error in ether of the included yml files. Rescue never seems to be executed.

This is running the latest devel.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [September 15, 2015, 1:58pm UTC](https://forum.ansible.com/t/rescue-block-doesnt-seem-to-work-when-error-is-in-an-included-file/19268/2 "2015-09-15T13:58:40Z")

</div>

This is a bug, open a github issue please, using this template [https://raw.githubusercontent.com/ansible/ansible/devel/ISSUE\_TEMPLATE.md](https://raw.githubusercontent.com/ansible/ansible/devel/ISSUE_TEMPLATE.md) and supplying a minimal reproducible test will help us getting this fixed.

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [September 15, 2015, 2:20pm UTC](https://forum.ansible.com/t/rescue-block-doesnt-seem-to-work-when-error-is-in-an-included-file/19268/3 "2015-09-15T14:20:37Z")

</div>

Hi Frank, I did just test this out on the latest version of devel, and it appears to be working for me just fine:

# cat fail.yml

- fail:

# cat test.yml

- hosts: localhost  
gather\_facts: no  
tasks:
- block:
- include: fail.yml
- debug: msg=“you should not see me”  
rescue:
- debug: msg=“here we are in the rescue”  
always:
- debug: msg=“here we are in the always”

TASK [include] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
included: fail.yml for localhost

TASK [fail] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [localhost]: FAILED! =\> {“changed”: false, “failed”: true, “msg”: “Failed as requested from task”}

TASK [debug msg=here we are in the rescue] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost] =\> {  
“changed”: false,  
“msg”: “here we are in the rescue”  
}

TASK [debug msg=here we are in the always] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost] =\> {  
“changed”: false,  
“msg”: “here we are in the always”  
}

Can you test against the latest pull from devel (if you’re not already), and share more information about what the include failures may involve?

---

<div class="post-metadata">

**Author:** ![Frank\_Perks](https://avatars.discourse-cdn.com/v4/letter/f/90ced4/32.png) [@Frank\_Perks](https://forum.ansible.com/u/Frank_Perks)\
**Post date:** [September 15, 2015, 4:40pm UTC](https://forum.ansible.com/t/rescue-block-doesnt-seem-to-work-when-error-is-in-an-included-file/19268/4 "2015-09-15T16:40:05Z")

</div>

I am dumb, and the issue is because i have:

`

- rescue

`

when it should be:

`rescue`

My mistake.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [September 15, 2015, 4:54pm UTC](https://forum.ansible.com/t/rescue-block-doesnt-seem-to-work-when-error-is-in-an-included-file/19268/5 "2015-09-15T16:54:53Z")

</div>

he, no worries, I didn't catch that either
