# Allow some %age of failures before quitting the playbook

**URL:** <https://forum.ansible.com/t/allow-some-age-of-failures-before-quitting-the-playbook/13169>\
**Category:** Ansible Project\
**Created:** [July 20, 2013, 4:23am UTC](https://forum.ansible.com/t/allow-some-age-of-failures-before-quitting-the-playbook/13169 "2013-07-20T04:23:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kavin\_Kankeshwar](https://avatars.discourse-cdn.com/v4/letter/k/35a633/32.png) [@Kavin\_Kankeshwar](https://forum.ansible.com/u/Kavin_Kankeshwar)\
**Post date:** [July 20, 2013, 4:23am UTC](https://forum.ansible.com/t/allow-some-age-of-failures-before-quitting-the-playbook/13169/1 "2013-07-20T04:23:36Z")

</div>

Hi,

I am trying to see how best I can quit running a playbook , if some %age of nodes have failed and not proceed with upgrading hosts.

Use case: Upgrading a Java webapp in rolling fashion, But if some %age of nodes have failed to quit the playbook and not go to other nodes.

Any recommendations?

Regards,

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 20, 2013, 3:43pm UTC](https://forum.ansible.com/t/allow-some-age-of-failures-before-quitting-the-playbook/13169/2 "2013-07-20T15:43:48Z")

</div>

Ansible is somewhat smart about a rolling update batch size already.

So if you have 200 nodes and set “serial: 10” it will quit if all 10 in the block fail.

It sounds like you want to quit the rolling update if you have less than 10% fail. I’m open to this idea.

You should file a feature request in github to make this configurable.

---

<div class="post-metadata">

**Author:** ![Kavin\_Kankeshwar](https://avatars.discourse-cdn.com/v4/letter/k/35a633/32.png) [@Kavin\_Kankeshwar](https://forum.ansible.com/u/Kavin_Kankeshwar)\
**Post date:** [July 21, 2013, 1:45am UTC](https://forum.ansible.com/t/allow-some-age-of-failures-before-quitting-the-playbook/13169/3 "2013-07-21T01:45:48Z")

</div>

Thanks, Yes. But i was not sure if “serial: 10” and 5 servers fail in each time, how would it behave.

So basically yes, saying at max from reachable nodes only max 10 % can fail, if from the first 50 nodes 10% fail, Stop the playbook and trigger some notification for investigation.

I created [feature request](https://github.com/ansible/ansible/issues/3609) on Github and just for my understanding: If this had to be implemented, The changes would be in this file right ? lib/ansible/playbook/ **init**.py around line 545 ? or it would be somewhere else ?

Regards,

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 21, 2013, 4:22pm UTC](https://forum.ansible.com/t/allow-some-age-of-failures-before-quitting-the-playbook/13169/4 "2013-07-21T16:22:35Z")

</div>

Right, playbook batch handling is around there, exactly.

Currently it will go on with the update if the batch size has some successes, so your RFE is accurate.

---

<div class="post-metadata">

**Author:** ![Kavin\_Kankeshwar](https://avatars.discourse-cdn.com/v4/letter/k/35a633/32.png) [@Kavin\_Kankeshwar](https://forum.ansible.com/u/Kavin_Kankeshwar)\
**Post date:** [July 23, 2013, 11:22pm UTC](https://forum.ansible.com/t/allow-some-age-of-failures-before-quitting-the-playbook/13169/5 "2013-07-23T23:22:57Z")

</div>

I attempted to put this check: [commit link](https://github.com/kavink/ansible/commit/89b26e27b8f878603ac0e089de06939348da4a09) . I did not spend much time/ Dont know internals too well.

But what this is trying to do is, if you put max\_fail\_pct: 10 and have 100 nodes in your inventory, with serial as 10. Then if more than 10 nodes have fail in first 2 batches, It will bail out and not go to the third batch.

I could not test it in larger scale, just did with max\_fail\_pct:25, 4 nodes and serial: 2 .

Let me know if i should send a pull request or do other changes ?

Regards,

---

<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:** [July 24, 2013, 1:06am UTC](https://forum.ansible.com/t/allow-some-age-of-failures-before-quitting-the-playbook/13169/6 "2013-07-24T01:06:58Z")

</div>

IMHO, the percentage should be a percentage of each batch size, rather than the total.

Seems possibly easier to follow, and would not require adjusting so much?

–Michael

---

<div class="post-metadata">

**Author:** ![Kavin\_Kankeshwar](https://avatars.discourse-cdn.com/v4/letter/k/35a633/32.png) [@Kavin\_Kankeshwar](https://forum.ansible.com/u/Kavin_Kankeshwar)\
**Post date:** [July 24, 2013, 2:46am UTC](https://forum.ansible.com/t/allow-some-age-of-failures-before-quitting-the-playbook/13169/7 "2013-07-24T02:46:20Z")

</div>

Yes, Thanks that makes sense, But for my understanding is it ideal to keep continuing for rolling updates and keep removing servers from list till all fail or its better to fail by default (i.e. max\_fail\_pct: 0) , unless explicitly given ignore\_errors: yes

current behavior (v1.2.2 ) is like (i.e. max\_fail\_pct: 100)

Regards,

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 24, 2013, 3:01pm UTC](https://forum.ansible.com/t/allow-some-age-of-failures-before-quitting-the-playbook/13169/8 "2013-07-24T15:01:20Z")

</div>

I think the choice of this should be up to the organization.

Right now if you are doing a rolling update on 200 and block size is 10, and a block fails it will not continue, which DOES catch fatal playbook errors before going on to another block, but does allow for one server to be down.

I think it should be up to the org.

Good thing is this proposal does that.
