I like Ubuntu but I want to switch to Fedora. I’m trying to port my playbooks that I wrote to work on Ubuntu and port them to Fedora. Here is the most I’ve been able to factor my roles down to:
I believe your approach to be the most robust and standard within the community.
There is this concept of DRY that I feel too many people get captured in. In general I would say that much of The Zen of Python applies to overthinking playbooks too.
One thing that you need to take into account is that package names are also often different between OSes, there are ways to get around it, but I think I would consider them a bit too clever and would potentially create confusion with maintaining the plays down the road.
This has been repeated way too often, but think about how package managers change between systems and how those packages are actually managed differently.
Apache is worlds different between Red Hat and Ubuntu for instance.
Awareness of what operating system you are on, and where you are getting packages from is of vital importance, which is also the same reason “yum and pip” don’t just pick packages from “somewhere”, etc.