Ansible - Only do action if on specific distribution (Debian, Ubuntu, CentOS or RHEL) or distribution version (ubuntu precise, ubuntu trusty)

This ansible playbook example helps you execute actions only if you are on a certain distribution. You might have a mixed environment with CentOS and Debian, when using ansible to execute actions on different servers you don't need to run yum on debian, or apt on CentOS. Some package names are different and such, so this helps you with a when statement to select a specific distribution. As a bonus, you also get a when for specific distribution versions, like Ubuntu precise (12.04 LTS) or Ubuntu trusty (14.04 LTS).

Top News