Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add last error to rescue block #12341

Closed
kai11 opened this issue Sep 13, 2015 · 5 comments
Closed

add last error to rescue block #12341

kai11 opened this issue Sep 13, 2015 · 5 comments
Labels
feature This issue/PR relates to a feature request.
Milestone

Comments

@kai11
Copy link
Contributor

kai11 commented Sep 13, 2015

Issue Type: Feature Idea

Ansible Version: 2.0.0

Ansible Configuration: not modified

Environment: Ubuntu 14.04

Summary: add last error to rescue block

Steps To Reproduce:
Rescue block described at http://docs.ansible.com/ansible/playbooks_blocks.html have no way to retrieve last error.
I think error notification will be frequent use case for blocks.

Something like this:

tasks:
  - block:
      - command: /bin/false
    rescue:
      - debug: var=ansible_last_error

Expected Results:
Last error - playbook, task name, failure message.

Actual Results:
No variable defined

@jimi-c
Copy link
Member

jimi-c commented Sep 16, 2015

I was just mentioning to someone last night that this might be useful... not sure if we'll get it in by 2.0 but we'll keep this open.

Thanks!

@jimi-c jimi-c removed the P3 label Dec 7, 2015
@dmsimard
Copy link
Contributor

Love this, +1.

@jimi-c jimi-c added this to the next milestone Dec 18, 2015
@sccu
Copy link

sccu commented Feb 22, 2016

+1. I love this, too.

jimi-c added a commit that referenced this issue Mar 28, 2016
`ansible_failed_task`:
   Contains the task data, essentially a serialized view of the Task() object.
`ansible_failed_result`:
   Contains the result of the task failure, which is identical in function
   to registering the result. Doing so automatically like this saves the user
   from having to register every result in a block and then trying to figure
   out which result had the failure

Similar to the way try/except/finally work, these variables will not be
available in the `always` portion of a block unless there is a corresponding
`rescue` first.

Fixes #12341
@dearlordylord
Copy link

+1.

@jimi-c jimi-c closed this as completed in 0656d14 Mar 31, 2016
@jimi-c
Copy link
Member

jimi-c commented Mar 31, 2016

Closing This Ticket

Hi!

We believe the above commit should resolve this problem for you. This will also be included in the next release.

If you continue seeing any problems related to this issue, or if you have any further questions, please let us know by stopping by one of the two mailing lists, as appropriate:

Because this project is very active, we're unlikely to see comments made on closed tickets, but the mailing list is a great way to ask questions, or post if you don't think this particular issue is resolved.

Thank you!

@ansibot ansibot added feature This issue/PR relates to a feature request. and removed feature_idea labels Mar 2, 2018
@ansible ansible locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature This issue/PR relates to a feature request.
Projects
None yet
Development

No branches or pull requests

6 participants