
Operating system family
We have looked at the setup module in previous chapters; this is the module that gathers facts about our target hosts. One of these facts is ansible_os_family; this tells us the type of operating system we are running. Let's check on both of our boxes:
$ ansible -i production centos -m setup | grep ansible_os_family
$ ansible -i production ubuntu -m setup | grep ansible_os_family
As you can see from the following Terminal output, the CentOS box returns Red Hat, which is expected. However, the Ubuntu box does not return any information:

Let's take a look at why this is. First of all, we can rerun the command, but this time minus the grep so we can see the full output:
$ ansible -i production ubuntu -m setup
This should give you something like the following results:

Oh, we are getting an error. Why is it reporting there is no Python installed? Running the following will SSH into the box:
$ vagrant ssh ubuntu
Once logged in using SSH, running which python will show us the path to the Python binary. As you can see, there isn't one installed as we get no path returned. So what about Python 3? Running which python3 does return a binary:

Let's close our SSH session by running exit.
What should we do about this? As we are running a version of Ansible that is later than 2.2, we can tell Ansible to use /usr/bin/python3 rather than its default of /usr/bin/python. To do this, we need to update our host inventory file so that just the Ubuntu host gets the ansible_python_interpreter variable added along with the updated path.
There are a few ways to achieve this; however, for now, let's just update the following line in the production host inventory file:
ubuntu ansible_host=192.168.50.7.nip.io
So it reads as follows:
ubuntu ansible_host=192.168.50.7.nip.io ansible_python_interpreter=/usr/bin/python3
Once updated, we should be able to run the following command:
$ ansible -i production wordpress -m setup | grep ansible_os_family
The following screenshot shows an output for the preceding command:

As you can see, we are targeting the host group of wordpress, which contains both of our boxes in it, and, as expected, we get RedHat for the CentOS box and the Ubuntu box is now returning Debian. Now that we have a way of identifying which operating system is in use on each host, we can make a start adapting the roles.