Hi Yoshi,

role variables are accessible only in roles, thats why create a fact that
is accessible to host (and thru hostvars from other hosts if needed).
Personally I always scope role variables with role name, easier for me to
read host_vars/ group_vars files.

David Karban
Linux server specialist/Specialista na správu linuxových serverů
www.karban.eu

2016-01-05 18:36 GMT+01:00 Yoshi Spendiff <[email protected]>:

> Thanks David,
>
> That's quite a reasonable solution actually, for one it works but also it
> makes you consider naming conventions for the facts and dependencies that
> will use it.
>
> I had to quote the {{ role_path }} in defaults/main.yml for it to work for
> me.
>
> So variables defined in defaults/main.yml are scoped only for the
> execution of tasks in that role?
>
> Regards,
> Yoshi
>
> On 5 January 2016 at 02:44, David Karban <[email protected]> wrote:
>
>> Hi,
>>
>> I would try to get paths for files into variables in meta roles and
>> export it as facts:
>>
>> defaults/main.yml:
>> rolename_path: {{ role_path }}
>>
>> tasks/main.yml:
>>   - set_fact: rolename_path={{ rolename_path }}
>>
>> And that use this variable to get file:
>> {{ rolepath_name + 'files/filename.txt' }}
>>
>> Could work.
>>
>> David Karban
>> Linux server specialist/Specialista na správu linuxových serverů
>> www.karban.eu
>>
>> 2016-01-05 2:32 GMT+01:00 Yoshi Spendiff <[email protected]>:
>>
>>> Hi,
>>>
>>> I'm wondering if anyone knows of any tricks for neatly handling common
>>> file dependencies for roles. I initially thought having a common dependent
>>> role in meta/main.yml would facilitate this but apparently dependencies
>>> don't apply to files (which does make sense if roles are though of as
>>> totally isolated), but is there some way to achieve this? Or is there some
>>> way to specify search paths for files inside a role or something?
>>>
>>> So far the best I've come up with is putting a *files *and/or
>>> *templates *directory in the root of the ansible directory and then
>>> referencing files/templates with *src=file/myfile.txt *and/or 
>>> *src=templates/mytemplate.txt
>>> *(I've also seen the recommendation to use *src={{ inventory_dir
>>> }}/files/myfile.txt *but that doesn't seem necessary). The problem with
>>> this is that it doesn't really organise dependencies for roles but rather
>>> just lumps everything into one directory and makes it difficult to share
>>> roles externally.
>>>
>>> Alternatively, is there some way to specify multiple task files in a
>>> role so that all other components can be shared, i.e. something like the
>>> following (or Chef cookbook recipes really)
>>>
>>> - name: myplay
>>>   roles:
>>>     - myrole.create (roles/myrole/tasks/create.yml)
>>>     - myrole (roles/myrole/tasks/main.yml)
>>>     - myrole.delete (roles/myrole/tasks/delete.yml)
>>>
>>> Regards,
>>> Yoshi
>>>
>>> --
>>> 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/a1264234-c753-4402-974c-7b1f8c7fc142%40googlegroups.com
>>> <https://groups.google.com/d/msgid/ansible-project/a1264234-c753-4402-974c-7b1f8c7fc142%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 a topic in the
>> Google Groups "Ansible Project" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/ansible-project/Nijxp6RA_68/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, 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/CAOBFM9545G97n09c9Oc1Y3_-sgNyc7w6uhy8Wjq3SvcJcJ_tgw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/ansible-project/CAOBFM9545G97n09c9Oc1Y3_-sgNyc7w6uhy8Wjq3SvcJcJ_tgw%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].
> 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/CAPED8tA_ZQD4e2x5ymO%2BrFeBza5ALnbbJTWNKuBgVMQVzAVDjA%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAPED8tA_ZQD4e2x5ymO%2BrFeBza5ALnbbJTWNKuBgVMQVzAVDjA%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].
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/CAOBFM96DeKNUV%3DNGdsrjn2OghZG16z_sj6RPo%3DXOnp8-tu2oMg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to