# Getting hostvars when using serial

**URL:** <https://forum.ansible.com/t/getting-hostvars-when-using-serial/18561>\
**Category:** Ansible Project\
**Created:** [June 21, 2015, 8:31am UTC](https://forum.ansible.com/t/getting-hostvars-when-using-serial/18561 "2015-06-21T08:31:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan\_Dimitrov1](https://avatars.discourse-cdn.com/v4/letter/i/e79b87/32.png) [@Ivan\_Dimitrov1](https://forum.ansible.com/u/Ivan_Dimitrov1)\
**Post date:** [June 21, 2015, 8:31am UTC](https://forum.ansible.com/t/getting-hostvars-when-using-serial/18561/1 "2015-06-21T08:31:25Z")

</div>

Hello Group,

I’m looking for a way to access facts for my hostnames through the hostvars and groups methods. This all works well, but I’m stuck when I try to limit the batch size with the “serial” directive.

For example: I have 10 web servers that I want to do rolling update using the “serial: 50%”.

```auto
{% for host in groups['app_servers'] %}
   {{ hostvars[host]['ansible_eth0']['ipv4']['address'] }}
{% endfor %}

```

Using the above example will give me all hosts in the group “app\_servers” and there is no way to get only 50% of the hosts.

Is there a way to get facts information for “all hosts in the scope” and “all hosts outside of scope”?

---

<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:** [June 22, 2015, 4:15pm UTC](https://forum.ansible.com/t/getting-hostvars-when-using-serial/18561/2 "2015-06-22T16:15:08Z")

</div>

you could use the loop.index and compare against group[‘app\_servers’]|length to break the loop at the serial point.
