Super important Ansible facts
There are some facts that I use very frequently, they are super important to me.
This is more a therapeutic post for me, than it’s a great read to you. ;-)
Sometimes, actually most of the times, each operating system or distribution needs something specific. For example Apache httpd has different package named for mostly every distribution. This mapping (distro:packagename) can be done using this variable: ansible_os_family.
Try to select packages/service-names/directories/files/etc based on the most general level and work your way down to more specific when required. This results in a sort of priority list:
- General variable, not related to a distribution. For example:
postfix_package. ansible_os_familyvariable, related to the type of distribution, for example:httpd_packagewhich differs for Alpine, Archlinux, Debian, Suse and RedHat. (But is’t the same for docker imagesdebianandubuntu.)ansible_distributionvariable when each distribution has differences. For example:reboot_requirements. CentOS needsyum-utils, but Fedora needsdnf-utils.ansible_distributionandansible_distribution_major_versionwhen there are differences per distribution release. For examplefirewall_packages. CentOS 6 and CentOS 7 need to have a different package.
Here is a list of containers and their ansible_os_family.
| Container image | ansible_os_family |
|---|---|
alpine |
Alpine |
archlinux/base |
Archlinux |
centos |
RedHat |
debian |
Debian |
fedora |
RedHat |
opensuse/leap |
Suse |
ubuntu |
Debian |