0

I am trying to get the OS family of my host machine using ansible. This is the command I use.

ansible my-host -i hosts.ini -m setup | grep ansible_os_family

This is what my host file looks like.

[my-host] myhostvm.com  ansible_ssh_pass=mypw ansible_ssh_user=root

I however get this message:

"ansible_os_family": "NA",

I try to run this as well.

ansible my-host -i hosts.ini -m setup | grep ansible_distribution

This is the result:

"ansible_distribution": "NA", "ansible_distribution_major_version": "NA", "ansible_distribution_release": "NA", "ansible_distribution_version": "NA",

Can someone explain to me why it doesn't return any OS family?

1 Answers1

1

The Ansible code to get the value for ansible_os_family is in lib/ansible/module_utils/facts.py.

If the os family of the target system is not contained in the OS_FAMILY list you will need to patch the Ansible code to add your os family. Currently the list contains:

OS_FAMILY = dict(
    RedHat = 'RedHat', Fedora = 'RedHat', CentOS = 'RedHat', Scientific = 'RedHat',
    SLC = 'RedHat', Ascendos = 'RedHat', CloudLinux = 'RedHat', PSBM = 'RedHat',
    OracleLinux = 'RedHat', OVS = 'RedHat', OEL = 'RedHat', Amazon = 'RedHat',
    XenServer = 'RedHat', Ubuntu = 'Debian', Debian = 'Debian', Raspbian = 'Debian', Slackware = 'Slackware', SLES = 'Suse',
    SLED = 'Suse', openSUSE = 'Suse', SuSE = 'Suse', SLES_SAP = 'Suse', Gentoo = 'Gentoo', Funtoo = 'Gentoo',
    Archlinux = 'Archlinux', Manjaro = 'Archlinux', Mandriva = 'Mandrake', Mandrake = 'Mandrake', Altlinux = 'Altlinux',
    Solaris = 'Solaris', Nexenta = 'Solaris', OmniOS = 'Solaris', OpenIndiana = 'Solaris',
    SmartOS = 'Solaris', AIX = 'AIX', Alpine = 'Alpine', MacOSX = 'Darwin', FreeBSD = 'FreeBSD', HPUX = 'HP-UX', openSUSE_Leap = 'Suse'

Ansible checks for /etc/$OS-release to determine the os. If the OS family of your target system is in the OS_FAMILY list you should check if the /etc/$OS-release is correct.

Henrik Pingel
  • 9,380
  • 2
  • 28
  • 39