Thank you for the details. I am wondering how to pass file name in one role 
to another role as variable parameter.

As mentioned in previous post, take example of configuring webserver for a 
particular application. webserver setup remains same for multiple 
applications except configuration file. So if we develop a webserver role 
that accepts file path parameter, then same webserver role could be reused 
by other application roles. Now it makes sense to keep application specific 
webserver configuration file inside application role and pass it's path to 
webserver role. This helps in keeping all application specific 
configuration files inside a single role.

If Ansible had some roles path variable or special path 'role', then it 
would make above pattern easy. So we could say something like 
src=ROLES/myapp/files/testfile .

It seems like that is not possible with Ansible.

- N


On Thursday, July 14, 2016 at 7:10:54 AM UTC-7, Dick Davies wrote:
>
> On 13 July 2016 at 22:09, Neubyr N <[email protected] <javascript:>> 
> wrote: 
> > 
> >Right now file name 
> > passed to the webserver role is relative path from the playbook file. Is 
> > there any way to make this path independent of playbook location and 
> > reference it using role directory? 
>
> Yes - if you have tasks in a role 'thingy' like this: 
>
> - name: config 
>   copy: src=etc/file.conf 
>             dest=/etc/file.conf 
>
> - name: more config 
>    template: src=etc/file2.conf.j2 
>                    dest=/etc/file2.conf 
>
>
> then 
>
> * the copy task will load its source file from 
> roles/thingy/files/etc/file.conf 
> * the template task will load its template from 
> roles/thingy/templates/etc/file2.conf.j2 
>

-- 
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/9f5b3456-091e-446a-98be-e49379b7b10a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to