So how do we go about building the logic into our roles to only execute certain parts of the roles on different operating systems, and also as we know that package names will be different? How do we define different sets of variables per operating system?
Adapting the roles
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...