# calculating the 'serial'?

**URL:** <https://forum.ansible.com/t/calculating-the-serial/18070>\
**Category:** Ansible Project\
**Created:** [April 24, 2015, 7:01am UTC](https://forum.ansible.com/t/calculating-the-serial/18070 "2015-04-24T07:01:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ted\_Timmons](https://avatars.discourse-cdn.com/v4/letter/t/9e8a1a/32.png) [@Ted\_Timmons](https://forum.ansible.com/u/Ted_Timmons)\
**Post date:** [April 24, 2015, 7:01am UTC](https://forum.ansible.com/t/calculating-the-serial/18070/1 "2015-04-24T07:01:04Z")

</div>

I'm trying to calculate a serial number and having trouble. I'm unsure  
of the jinja filter pipeline. Here's what I'm trying:

serial: "{{play\_hosts|length|float/2|round(0, 'ceil')|int}}"

here's the error:

ValueError: invalid literal for int() with base 10:  
"{{default(length(play\_hosts), 1)/2|round(0, 'ceil')|int}}"

If I put that jinja string in a debug, it is ending with a float- for  
instance, if there are 10 play\_hosts, the output is 5.0. That seems  
strange given the 'int'. I wonder if that's what is causing it to  
fail.

-ted

---

<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:** [April 24, 2015, 1:01pm UTC](https://forum.ansible.com/t/calculating-the-serial/18070/2 "2015-04-24T13:01:24Z")

</div>

It appears as though serial cannot be templated. Note that you can use a percentage there already. So just specify 50% and I think that should match what you want.

[https://docs.ansible.com/playbooks\_delegation.html#rolling-update-batch-size](https://docs.ansible.com/playbooks_delegation.html#rolling-update-batch-size)
