# order of IPs in ansible\_all\_ipv\*\_addresses facts

**URL:** <https://forum.ansible.com/t/order-of-ips-in-ansible-all-ipv-addresses-facts/27366>\
**Category:** Ansible Project\
**Tags:** fedora, ubuntu\
**Created:** [April 25, 2018, 9:53am UTC](https://forum.ansible.com/t/order-of-ips-in-ansible-all-ipv-addresses-facts/27366 "2018-04-25T09:53:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nusenu](https://avatars.discourse-cdn.com/v4/letter/n/4da419/32.png) [@nusenu](https://forum.ansible.com/u/nusenu)\
**Post date:** [April 25, 2018, 9:53am UTC](https://forum.ansible.com/t/order-of-ips-in-ansible-all-ipv-addresses-facts/27366/1 "2018-04-25T09:53:00Z")

</div>

Hi,

since I make use of the ansible facts containing the list of IP  
addresses to bind services to IPs I want to make sure that the IP addresses  
are always returned the same way,  
- regardless how often you run the playbook  
- or if you choose to add additional interfaces or IP addresses (aliases) in the future.

I didn't find specific information about how the content of  
ansible\_all\_ipv4\_addresses and  
ansible\_all\_ipv6\_addresses  
is put together.

My questions are:  
- Is there documentation that does not require to read the code [1]?  
- How is the order of the IP addresses determined is it deterministic?  
- Will this remain unchanged in future ansible versions?  
- Do any of the filters  
ansible\_all\_ipv4\_addresses| ipv4('address') | ipv4('public')  
ansible\_all\_ipv6\_addresses| ipv6('public') | ipv6('address')  
have an influence on the order?  
- Are there best practices when adding new interfaces or aliases to ensure  
that the order of IPs in these facts does not get affected?  
(I make use of the first N IPs)

Since my role [2] supports multiple platforms I also  
care if the answer to these questions are platform specific.  
Relevant platforms:  
- Debian / Ubuntu  
- FreeBSD  
- OpenBSD  
- CentOS  
- Fedora

thanks!  
nusenu

[1] [https://github.com/ansible/ansible/blob/devel/lib/ansible/module\_utils/facts/network/linux.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/facts/network/linux.py)  
[2] [https://github.com/nusenu/ansible-relayor](https://github.com/nusenu/ansible-relayor)
