# Ansible Facts vs Ansible OS

**URL:** <https://forum.ansible.com/t/ansible-facts-vs-ansible-os/33960>\
**Category:** Ansible Project\
**Created:** [October 5, 2020, 12:48pm UTC](https://forum.ansible.com/t/ansible-facts-vs-ansible-os/33960 "2020-10-05T12:48:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Keith\_Mills](https://avatars.discourse-cdn.com/v4/letter/k/b77776/32.png) [@Keith\_Mills](https://forum.ansible.com/u/Keith_Mills)\
**Post date:** [October 5, 2020, 12:48pm UTC](https://forum.ansible.com/t/ansible-facts-vs-ansible-os/33960/1 "2020-10-05T12:48:48Z")

</div>

Hello All,

I have a general question!

When should I use ansible\_facts.distribution vs ansible\_os\_family or are they interchangeable? Is one better than the other?

Thanks,

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [October 7, 2020, 8:26pm UTC](https://forum.ansible.com/t/ansible-facts-vs-ansible-os/33960/2 "2020-10-07T20:26:13Z")

</div>

ansible\_facts.distribution (aka ansible\_distribution) and  
ansible\_facts.os\_family (aka ansible\_os\_family) are just 2 diff sets  
of data.

For example on Ubuntu, family will be 'debian' while distribution will  
be 'ubuntu', sometimes they can be the same (i.e while using debian)  
but they are meant to indicate specific things that are different.

As to when to use them .. that depends on your context, what  
distinction is needed.

---

<div class="post-metadata">

**Author:** ![Alex\_Cernat](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@Alex\_Cernat](https://forum.ansible.com/u/Alex_Cernat)\
**Post date:** [October 8, 2020, 9:14am UTC](https://forum.ansible.com/t/ansible-facts-vs-ansible-os/33960/3 "2020-10-08T09:14:15Z")

</div>

ansible\_os\_family is for assigning tasks, variables etc. to a family of operating systems (i.e Debian, RedHat etc)  
Debian will match Debian, Ubuntu, any other derived Debian distribution  
RedHat will match RedHat, CentOS, Fedora, any other derived RedHat distribution  
the assumption is that in the same family the things are the same (i.e. apache is apache2 in Debian family, but httpd in RedHat family)

if you need finer grain you could use ansible\_distribution, which will give you the exact linux distribution

in most cases os\_family will be enough, but when it comes to package versions (like php-7.x) maybe you will need also ansible\_distribution\_major\_version

Alex

Pe luni, 5 octombrie 2020, la 15:48:48 UTC+3, [mills....@gmail.com](mailto:mills....@gmail.com) a scris:

---

<div class="post-metadata">

**Author:** ![Keith\_Mills](https://avatars.discourse-cdn.com/v4/letter/k/b77776/32.png) [@Keith\_Mills](https://forum.ansible.com/u/Keith_Mills)\
**Post date:** [October 8, 2020, 3:44pm UTC](https://forum.ansible.com/t/ansible-facts-vs-ansible-os/33960/4 "2020-10-08T15:44:42Z")

</div>

Thanks Brian! That helped a lot.

---

<div class="post-metadata">

**Author:** ![Keith\_Mills](https://avatars.discourse-cdn.com/v4/letter/k/b77776/32.png) [@Keith\_Mills](https://forum.ansible.com/u/Keith_Mills)\
**Post date:** [October 8, 2020, 3:45pm UTC](https://forum.ansible.com/t/ansible-facts-vs-ansible-os/33960/5 "2020-10-08T15:45:06Z")

</div>

Thanks Alex! that helped a lot.
