# Current failure count?

**URL:** <https://forum.ansible.com/t/current-failure-count/15270>\
**Category:** Ansible Project\
**Created:** [May 19, 2014, 6:45pm UTC](https://forum.ansible.com/t/current-failure-count/15270 "2014-05-19T18:45:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Titus](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@Mike\_Titus](https://forum.ansible.com/u/Mike_Titus)\
**Post date:** [May 19, 2014, 6:45pm UTC](https://forum.ansible.com/t/current-failure-count/15270/1 "2014-05-19T18:45:39Z")

</div>

Is there any way, during the execution of a playbook, to access the current failure count? The final failure count is displayed in the PLAY RECAP section of the log output:

xxx.xx.xx.xxx : ok=37 changed=1 unreachable=0 failed=3

Before the playbook completes, I want to check the failure count and send an alert if n \> 1.

Thanks,

Mike

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [May 19, 2014, 7:16pm UTC](https://forum.ansible.com/t/current-failure-count/15270/2 "2014-05-19T19:16:48Z")

</div>

You would need to utilize a callback plugin.

Your CallbackModule class could implement a counter attribute, and runner\_on\_failed could increment and check the count.

If it exceeds a threshold, fire off some form of message.

You can see some examples at [https://github.com/ansible/ansible/tree/devel/plugins/callbacks](https://github.com/ansible/ansible/tree/devel/plugins/callbacks)

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [May 21, 2014, 9:50pm UTC](https://forum.ansible.com/t/current-failure-count/15270/3 "2014-05-21T21:50:53Z")

</div>

Currently yes. I’m not opposed to the callback system being modified to keep these kind of counts, however, though I believe currently callback plugins do live in fork memory, thus it might not be possible.

Would have to dive in deeper.

Callback plugin is a possible answer.

---

<div class="post-metadata">

**Author:** ![Mike\_Titus](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@Mike\_Titus](https://forum.ansible.com/u/Mike_Titus)\
**Post date:** [May 21, 2014, 10:48pm UTC](https://forum.ansible.com/t/current-failure-count/15270/4 "2014-05-21T22:48:16Z")

</div>

Actually, I was just hoping for an $ansible\_something variable that I could use in a module like sns / pagerduty / etc.

Mike

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [May 23, 2014, 12:12pm UTC](https://forum.ansible.com/t/current-failure-count/15270/5 "2014-05-23T12:12:09Z")

</div>

See my previous response, first sentence.
