FWIW, we have the following at the top of all of our tasks/main.yml: # include the distro-specific stuff - include: debian.yml when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- include: rhel.yml when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' And then do "distro specific" stuff in those files. Anything that can be done across both distro types is set out as tasks *after* the above includes. Cheers, Matt On Sunday, 4 January 2015 05:19:22 UTC, Francisco Reyes wrote: > > Was going over different posts on how to handle different OS within a role. > > In this thread: > https://groups.google.com/forum/#!searchin/ansible-project/group_by$20role|sort:relevance|spell:false/ansible-project/OPCESPvMppg/5ueNHQf_oSAJ > > I see: > >You can do things like > > - include: "{{ ansible_os_family }}.yml" > > Yet when I tried in a role I got: > ERROR: file could not read: /roles/postgres/tasks/{{ ansible_os_family > }}.yml > > If I hard code it like: > - include: Ubuntu.yml > > it works. > > The calling playbook has > gather_facts: True > > Any suggestions? > > ansible 1.9 (devel 3b80f63e22) last updated 2014/12/06 23:08:13 (GMT +000) > lib/ansible/modules/core: (detached HEAD b766390ae2) last updated > 2014/12/06 23:08:14 (GMT +000) > lib/ansible/modules/extras: (detached HEAD 19e688b017) last updated > 2014/12/06 23:08:16 (GMT +000) > v2/ansible/modules/core: (detached HEAD cb69744bce) last updated > 2014/12/06 23:08:17 (GMT +000) > v2/ansible/modules/extras: (detached HEAD 8a4f07eecd) last updated > 2014/12/06 23:08:19 (GMT +000) > configured module search path = /ansible/library:/usr/share/ansible/ > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/0fa09e5e-ee5c-4b30-aed5-da98bfadfd13%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
