group_by is awesome.
- hosts: webservers
group_by: key=webservers_{{ ansible_os_family }}
- hosts: webservers_RedHat
roles:
- ...
On Thu, Jun 19, 2014 at 11:56 AM, James Cammarata
wrote:
> You can achieve pretty much the same thing by using group_by or
> conditional includes along
You can achieve pretty much the same thing by using group_by or conditional
includes along with the variable structure you've defined, without loosing
the benefits Michael mentioned.
It should work fine with the apt or yum (or other package modules).
On Thu, Jun 19, 2014 at 11:53 AM, Maciej Delm
Will this work ok if I use apt: module directly instead? For different
package lists in Debian and Ubuntu, for example.
19 cze 2014 18:49 "Michael DeHaan" napisaĆ(a):
> Never do this, ansible_pkg_mgr does not allow the with_items block to be
> grouped into a single yum/apt transaction, which resu
Never do this, ansible_pkg_mgr does not allow the with_items block to be
grouped into a single yum/apt transaction, which results in much slower
package installations.
I understand why it's appealing, but really don't ... you'll also find that
the yum and apt modules have different options you may
How about this solution?
In `defaults/main.yml`:
java_distribution_packages:
Debian: [ 'openjdk-7', 'java-stuff' ]
RefHat: [ 'java-runtime-7', 'other-stuff' ]
And then, in `tasks/main.yml`:
- {{ ansible_pkg_mgr }}: name={{ item }} state=latest
witn_items: java_distribu
The technique I usually use for making a role work cross-distro is to do
two things:
*For variables*: Include a variables file named {{ ansible_os_family }}.yml
(then stick 'Debian.yml' and 'RedHat.yml', etc. into the role's vars folder.
*For tasks*: Add "when: ansible_os_family == 'Distributio