Hi,
I'm wondering if there's a better way to install packages on multiple operating systems.
TL;DR: I'm looking for a method to abstract the OS differences to avoid duplicating files and templates all over the place.
Here's what I'm currently doing:
- name: Install OpenJDK
apt: pkg={{ item }} state=present
with_items:
- openjdk-7-jdk
tags:
- java
when: ansible_distribution == 'Ubuntu'
- name: Install OpenJDK
yum: name=java-1.7.0-openjdk state=present
tags:
- java
when: ansible_distribution == 'CentOS'
This works fine when you only have 1 task or 1 role, but I currently have 10 roles with multiple configurations, and each role has its own set of tasks, files, templates, etc.
I considered creating separate directories in each role, for each OS, but then handlers, templates and other files will need to be duplicated.
Is there a "package" module to replace "yum/apt" ? If not, can someone recommend a better approach? So far all the solutions I've found are only good as "examples", but far from ideal in the real world.
Thanks