# Smart file paths in lookup plugins.

**URL:** <https://forum.ansible.com/t/smart-file-paths-in-lookup-plugins/12690>\
**Category:** Ansible Project\
**Created:** [April 16, 2013, 6:09pm UTC](https://forum.ansible.com/t/smart-file-paths-in-lookup-plugins/12690 "2013-04-16T18:09:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![C\_Morgan\_Hamill](https://avatars.discourse-cdn.com/v4/letter/c/ebca7d/32.png) [@C\_Morgan\_Hamill](https://forum.ansible.com/u/C_Morgan_Hamill)\
**Post date:** [April 16, 2013, 6:09pm UTC](https://forum.ansible.com/t/smart-file-paths-in-lookup-plugins/12690/1 "2013-04-16T18:09:24Z")

</div>

Howdy (again),

It seems like it would be nice if things like:

&nbsp;&nbsp;&nbsp;&nbsp;{{ lookup('file', 'foo.txt') }}

looked for 'foo.txt' in roles/curr\_role/files/ before falling back to  
looking in 'basedir'.

I'd be happy to write a patch to do so, but it doesn't seem like there's  
a simple way to get the name of the role from any of the places where  
the calls to run the plugin are made.

Is there any simple way of passing the role name (or the role's  
directory) to a lookup plugin at run time?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [April 16, 2013, 6:40pm UTC](https://forum.ansible.com/t/smart-file-paths-in-lookup-plugins/12690/2 "2013-04-16T18:40:58Z")

</div>

It would be better if it just worked automagically in both basedirs.

Not sure what that takes presently, please make sure there is a github ticket.

---

<div class="post-metadata">

**Author:** ![C\_Morgan\_Hamill](https://avatars.discourse-cdn.com/v4/letter/c/ebca7d/32.png) [@C\_Morgan\_Hamill](https://forum.ansible.com/u/C_Morgan_Hamill)\
**Post date:** [April 16, 2013, 6:49pm UTC](https://forum.ansible.com/t/smart-file-paths-in-lookup-plugins/12690/3 "2013-04-16T18:49:25Z")

</div>

Excerpts from Michael DeHaan's message of 2013-04-16 14:40:58 -0400:

> It would be better if it just worked automagically in both basedirs.
> 
> Not sure what that takes presently, please make sure there is a github  
> ticket.

There you go.  
\<[https://github.com/ansible/ansible/issues/2697&gt](https://github.com/ansible/ansible/issues/2697&gt);
