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

605 views
Skip to first unread message

Frank Perks

unread,
Sep 15, 2015, 9:03:04 AM9/15/15
to Ansible Project
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: <stuff>

- rescue:
  - name: Notify Slack it failed
    slack: <stuff>

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

This is running the latest devel. 

Brian Coca

unread,
Sep 15, 2015, 9:58:41 AM9/15/15
to Ansible Project
This is a bug, open a github issue please, using this template https://raw.githubusercontent.com/ansible/ansible/devel/ISSUE_TEMPLATE.md and supplying a minimal reproducible test will help us getting this fixed.

James Cammarata

unread,
Sep 15, 2015, 10:20:44 AM9/15/15
to ansible...@googlegroups.com
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?

Thanks!

James Cammarata
Director, Ansible Core Engineering
github: jimi-c

On Tue, Sep 15, 2015 at 9:58 AM, Brian Coca <bc...@ansible.com> wrote:
This is a bug, open a github issue please, using this template https://raw.githubusercontent.com/ansible/ansible/devel/ISSUE_TEMPLATE.md and supplying a minimal reproducible test will help us getting this fixed.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/9b081632-bbe0-4b56-9904-8205ae6b2717%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Frank Perks

unread,
Sep 15, 2015, 12:40:05 PM9/15/15
to Ansible Project
I am dumb, and the issue is because i have:

- rescue



when it should be:

 
rescue

My mistake.

Brian Coca

unread,
Sep 15, 2015, 12:54:58 PM9/15/15
to Ansible Project
he, no worries, I didn't catch that either

--
Brian Coca
Reply all
Reply to author
Forward
0 new messages