If I may ask a related question, I'm using include / when for my tasks, but 
I noticed that when I do the same for handlers ( include / when ), it gets 
called only on first match. If 1st match is not matching my 
ansible_distribution from tasks, I have a problem.

For instance in my task for OpenBSD.yml I have notify handler "restart pf". 
I have handler "restart pf" with the same name in FreeBSD.yml and 
OpenBSD.yml, both included from handlers/main.yml. First one evaluated is 
FreeBSD.yml, that one gets "skipped" and 2nd handler with the same name in 
OpenBSD.yml is never called.

Just want to make sure, if this is feature or bug. If I rename hander so 
they don't have identical names, it works as expected.

On Friday, January 9, 2015 at 11:02:37 AM UTC+1, Matthew Macdonald-Wallace 
wrote:
>
> 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/7779aba3-728a-4792-b43e-88282139d2fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to