# cleanup action

**URL:** <https://forum.ansible.com/t/cleanup-action/12228>\
**Category:** Ansible Project\
**Created:** [January 22, 2013, 12:06am UTC](https://forum.ansible.com/t/cleanup-action/12228 "2013-01-22T00:06:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yves\_Dorfsman](https://avatars.discourse-cdn.com/v4/letter/y/9de0a6/32.png) [@Yves\_Dorfsman](https://forum.ansible.com/u/Yves_Dorfsman)\
**Post date:** [January 22, 2013, 12:06am UTC](https://forum.ansible.com/t/cleanup-action/12228/1 "2013-01-22T00:06:13Z")

</div>

Is there a way to execute a cleanup action on a host, if any rule in a playbook fails?

Kind of like an except clause in programming languages?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [January 22, 2013, 12:41pm UTC](https://forum.ansible.com/t/cleanup-action/12228/2 "2013-01-22T12:41:03Z")

</div>

You can ignore\_errors: True / register: result on the first action and  
have two following tasks, one if it succeeds and one if it fails.

when\_integer: ${command.rc} \> 0

when\_integer: ${command.rc} == 0

etc
