# Variables and serial: keyword

**URL:** <https://forum.ansible.com/t/variables-and-serial-keyword/19993>\
**Category:** Ansible Project\
**Created:** [December 11, 2015, 5:29pm UTC](https://forum.ansible.com/t/variables-and-serial-keyword/19993 "2015-12-11T17:29:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eugene\_Zhulkov](https://avatars.discourse-cdn.com/v4/letter/e/e68b1a/32.png) [@Eugene\_Zhulkov](https://forum.ansible.com/u/Eugene_Zhulkov)\
**Post date:** [December 11, 2015, 5:29pm UTC](https://forum.ansible.com/t/variables-and-serial-keyword/19993/1 "2015-12-11T17:29:11Z")

</div>

I’ve been struggling with passing variable to serial for the whole day.

All I need is to pass group’s length, I’ve tried  
`serial: "{{ groups['appserver']|length }}"`

and got a runtime error.

Finally I come up with this code:

`serial: "{{ lookup('group_size', 'appserver') }}"`

, where **group\_size** is a custom lookup plugin.

Now I have another problem - how can I get access to inventory instance inside lookup plugin? I don’t understand API design - all plugins have “runner” instance in constructor except LookupModule.

So my questions are:

- can I parameterize serial?
- can I access inventory inside LookupModule?

Thank you!

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [December 11, 2015, 5:57pm UTC](https://forum.ansible.com/t/variables-and-serial-keyword/19993/2 "2015-12-11T17:57:46Z")

</div>

yes  
no

parameters to serial cannot depend on inventory as it gets read AFTER  
the play is evaluated (serial value is assigned). So use extra vars to  
set serial dynamically.
