Hi Francisco
The {{ ansible_os_family }} fact is usually set to the parent (or other ancestor) distribution. For Ubuntu it will be set to “Debian”. You might want to use {{ ansible_distribution }} instead (or rename your included file to Debian.yml - given that there is typically little to no difference between them for most operations).
Regards
Tom
--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/60336baa-441c-42dd-9800-114e99c9bfc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
The
{{ ansible_os_family }}fact is usually set to the parent (or other ancestor) distribution. For Ubuntu it will be set to “Debian”. You might want to use{{ ansible_distribution }}
- name: Handle install for Ubuntu
include: Ubuntu.yml
when: ansible_distribution == "Ubuntu"Hi Francisco
I tried this with v1.8.2 and it failed as your attempt, apparently not expanding the variable. I thought this would have worked in previous releases, but I could be wrong.
- include: "{{ ansible_distribution }}.yml"
In such a case, I sometimes do conditional includes within roles if I really have to.
- include: MacOSX.yml
when: ansible_distribution == 'MacOSX'
This has the side effect of showing the tasks therein as ‘skipped’ when the conditional doesn’t match. So I keep them to a minimum and my roles platform-specific. My preference is for small (thin) roles and verbose playbooks, it makes for easier refactoring and reuse. In your playbooks, you can use dynamic groups to apply platform oriented roles, as detailed here: http://docs.ansible.com/playbooks_best_practices.html#operating-system-and-distribution-variance
Regards
Tom
--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d502c6fc-cf0b-4855-bdaa-5449c54f4608%40googlegroups.com.
I tried this with v1.8.2 and it failed as your attempt, apparently not expanding the variable. I thought this would have worked in previous releases, but I could be wrong.
- include: "{{ ansible_distribution }}.yml"
It looks like you are trying to dynamically include a task file. I am pretty sure that is not possible. You can only dynamically include vars files.
Michael DeHaan
Most all ansible modules already abstract out OS details.
Package managers we want you to know - not only do package names change, but the way you interact with those packages change - think of how different Apache is between Ubuntu and CentOS for instance.
You can do things like
- include: "{{ ansible_os_family }}.yml"
And you can also do things like use "include_vars" with similar tricks where you want to maintain differences.
In most cases you'll only differ by variables except having a few tasks with "when" statements on them keying off the OS - which will also minimize task duplication.