Ricardo Gerardi is Technical Community Advocate for Enable Sysadmin and Enable Architect. He was previously a principal consultant at Red Hat Canada, where he specialized in IT automation with Ansible and OpenShift.
He has been a Linux and open source enthusiast and contributor for over 20 years. He is currently interested in hacking stuff using the Go programming language, and he's the author of the book Powerful Command-Line Applications in Go. Ricardo also writes regularly about Linux, Vim, and command line tools for the community publications Opensource.com and Enable Sysadmin.
Ricardo enjoys spending time with his daughters, reading science fiction books, and playing video games.
Authored Comments
Hey Ben. Great question. Thank you.
I usually create a variable to represent the list of packages to install, for example "package_list" and define it in an OS specific var file, such as "RedHat.yaml" or "Debian.yaml".
Then you include the vars file in your playbook/role based on the Operating System family retrieved as Ansible fact using this syntax: "{{ ansible_os_family }}.yaml".
This way you have a different "package_list" version per distribution. You could even include the OS version in the file name in case the package name is different across multiple version of the same distribution.
Hey Ben. Great question. Thank you.
I usually create a variable to represent the list of packages to install, for example "package_list" and define it in an OS specific var file, such as "RedHat.yaml" or "Debian.yaml".
Then you include the vars file in your playbook/role based on the Operating System family retrieved as Ansible fact using this syntax: "{{ ansible_os_family }}.yaml".
This way you have a different "package_list" version per distribution. You could even include the OS version in the file name in case the package name is different across multiple version of the same distribution.