Ansible Facts vs Ansible OS

292 views
Skip to first unread message

Keith Mills

unread,
Oct 5, 2020, 8:48:48 AM10/5/20
to Ansible Project
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,

Brian Coca

unread,
Oct 7, 2020, 4:26:59 PM10/7/20
to Ansible Project
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.
--
----------
Brian Coca

Alex Cernat

unread,
Oct 8, 2020, 5:14:16 AM10/8/20
to Ansible Project
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

Keith Mills

unread,
Oct 8, 2020, 11:44:42 AM10/8/20
to Ansible Project
Thanks Brian! That helped a lot.

Keith Mills

unread,
Oct 8, 2020, 11:45:06 AM10/8/20
to Ansible Project
Thanks Alex! that helped a lot.
Reply all
Reply to author
Forward
0 new messages