Recently I have been watching some ansible conference recordings and reading about best practices and I have a question.
How do you write your playbooks/roles to for cross platform use and be able to not to turn your specification to code with frequent "if"s and to not write too much boilerplate for each OS?
Ok I can abstract out package managers for example and just use package module, but still package naming sometimes will occur, or system will not be compatible with some module.
Is this even possible to write such roles? Or is there any guidelines that help avoid code overhead?
Sadly I didn’t found any material on that matter.
Or the only way is writing separate tasks for OS-dependent “native” stuff and adding "if"s on top role level?
What type of OS’s are you referring to ? If you are staying within the realm of Linux’s you can gather facts and then do when statement. It might also be good to just create separate named roles for the different OS.
I was afraid that there wasn’t a way to go without "if"s on low levels and it is only possible by separating it to playbooks. Looks like I will need to redesign my project structure to account that.