# Can we rely on using indices to refer a particular host?

**URL:** <https://forum.ansible.com/t/can-we-rely-on-using-indices-to-refer-a-particular-host/13705>\
**Category:** Ansible Project\
**Created:** [October 17, 2013, 10:44am UTC](https://forum.ansible.com/t/can-we-rely-on-using-indices-to-refer-a-particular-host/13705 "2013-10-17T10:44:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sundar1](https://avatars.discourse-cdn.com/v4/letter/s/8dc957/32.png) [@Sundar1](https://forum.ansible.com/u/Sundar1)\
**Post date:** [October 17, 2013, 10:44am UTC](https://forum.ansible.com/t/can-we-rely-on-using-indices-to-refer-a-particular-host/13705/1 "2013-10-17T10:44:06Z")

</div>

My hosts file is this

[prod\_webservers]  
1.1.1.1  
2.2.2.2  
3.3.3.3  
4.4.4.4  
5.5.5.5

If my playbook is like this,

---

<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:** [October 17, 2013, 5:53pm UTC](https://forum.ansible.com/t/can-we-rely-on-using-indices-to-refer-a-particular-host/13705/2 "2013-10-17T17:53:08Z")

</div>

Order is pinned properly in 1.4 (so indexing is safe and it’s in order), but inconsistent in earlier versions – where things may sort. In 1.4 the input order will be used.

In the case of a dynamic inventory plugin, these are typically returned as hashes, and thus should come out sorted.

---

<div class="post-metadata">

**Author:** ![Sundar1](https://avatars.discourse-cdn.com/v4/letter/s/8dc957/32.png) [@Sundar1](https://forum.ansible.com/u/Sundar1)\
**Post date:** [October 18, 2013, 9:41am UTC](https://forum.ansible.com/t/can-we-rely-on-using-indices-to-refer-a-particular-host/13705/3 "2013-10-18T09:41:33Z")

</div>

Thanks Michael.
