I'm facing somewhat similar challange, with a workaround - I've used the 
full-path expression, but in my case I have single template that is used 
for 2 roles. So I assumed one role to be primary and store such template 
and the other role is using roles/my_pri_role/templates/foo.j2 I guess for 
common templates one could use  top-level "templates" dir or somesuch, but 
if felt bit more natural to store it within appropriate roles. I do realize 
symlinks could've helped, but with version controll - that is not the most 
elegant solution either IMO. 

... just bringing more usecases ;)

On Thursday, June 26, 2014 10:59:58 AM UTC-6, Michael DeHaan wrote:
>
> "Would be great to have a magic variable to obtain the path to roles 
> tasks, to allow for things like:"
>
> I feel it would be pretty esoteric and infrequently used, we tend to push 
> back on extra magic until enough use cases for them start to appear.
>
> Usually roles don't import tasks straight out of other roles, and would 
> use role dependencies in the cases where they did.
>
> You should be able to know the relative pathing in nearly all cases though.
>
>
>
>
> On Thu, Jun 26, 2014 at 12:54 PM, "F.L. Jonathan Araña Cruz" <
> [email protected] <javascript:>> wrote:
>
>>  On 26/06/14 14:25, Michael DeHaan wrote:
>>  
>> It's not a bug.    
>>
>>  It's also a little weird, it's not expected that you would manually 
>> include a task file from a role directory without using roles, but if you 
>> wanted to, you would have to path it in the various subdirectories.
>>  
>>
>> Would be great to have a magic variable to obtain the path to roles 
>> tasks, to allow for things like:
>>
>> - hosts: hosts
>>   roles:
>>     - role-apache
>>     - role-other
>>    tasks:
>>     - include: "{{roles_paths['role-apache']}}/create_virtualhost.yml" 
>> servername=example.com
>>
>> There's an issue asking for this, although a bit tangled: 
>> https://github.com/ansible/ansible/issues/6955
>>  
>>   
>>   
>>
>> On Wed, Jun 25, 2014 at 7:03 AM, Руслан Закиров <[email protected] 
>> <javascript:>> wrote:
>>
>>> Hi, 
>>>
>>>  I hoped for the following to work from a playbook:
>>>
>>>  - hosts: backends
>>>   roles:
>>>     - common
>>>     - perl-app
>>>   tasks:
>>>     - include: a_task_that_sits_in_xxx_role.yml
>>>
>>>  But I get:
>>>
>>>  ERROR: file could not read: .../my-ansible/a_task_that_sits_in_xxx_role
>>> .yml
>>>
>>> What I expected is that an include in a playbook will search for a task 
>>> to include in play's roles.
>>>
>>> Is it a bug?
>>>   -- 
>>> 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] <javascript:>.
>>> To post to this group, send email to [email protected] 
>>> <javascript:>.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/ansible-project/67cb019c-471b-46ca-82d0-46760f8f4677%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/ansible-project/67cb019c-471b-46ca-82d0-46760f8f4677%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>  
>>  -- 
>> 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] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgw_Tu3Jbf9-JsYLp6Kc_h%3D4Vchy5jabzavuE21NRMq1rw%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgw_Tu3Jbf9-JsYLp6Kc_h%3D4Vchy5jabzavuE21NRMq1rw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>  -- 
>> 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] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/53AC502A.6010300%40faita.net
>>  
>> <https://groups.google.com/d/msgid/ansible-project/53AC502A.6010300%40faita.net?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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/f9dbbecb-4e09-43d6-ba93-8366f3bb2c50%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to