0

I see different ways of checking for the OS. Some use ansible_facts["os_name"] while others use ansible_os_family. Is there a preferred one to use?

Zeitounator
  • 38,476
  • 7
  • 53
  • 66
user1074593
  • 446
  • 1
  • 9
  • 23
  • 1
    _I see different ways of checking for the OS. Some use `ansible_facts["os_name"]`_ Do you have any reference for this? Where do you see such? – U880D May 13 '23 at 19:37
  • 1
    `ansible_os_name` is not returned on a linux host (at least not on my current Ubuntu station). I suspect it is specific to windows. You can also have a look at all `ansible_distribution_*` facts as well as the `ansible_lsb` dict (probably linux specific...). As a conclusion: there are plenty of facts you can use depending on your situation and how specific you want to be in your test. Just choose wisely the one(s) relevant to your use case. – Zeitounator May 14 '23 at 11:23

1 Answers1

1

... others use ansible_os_family. Is there a preferred one to use?

The documentation about Ansible Facts reference only os_family.

Also Getting full name of the OS using Ansible facts reference only os_family.

Based on that I would assume there is no such fact like os_name, can't be used therefore and os_familiy should be preferred.

Similar Q&A

U880D
  • 8,601
  • 6
  • 24
  • 40