# src relative to current playbook?

**URL:** <https://forum.ansible.com/t/src-relative-to-current-playbook/12030>\
**Category:** Ansible Project\
**Created:** [October 25, 2012, 11:10pm UTC](https://forum.ansible.com/t/src-relative-to-current-playbook/12030 "2012-10-25T23:10:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nolan\_Darilek](https://avatars.discourse-cdn.com/v4/letter/n/919ad9/32.png) [@Nolan\_Darilek](https://forum.ansible.com/u/Nolan_Darilek)\
**Post date:** [October 25, 2012, 11:10pm UTC](https://forum.ansible.com/t/src-relative-to-current-playbook/12030/1 "2012-10-25T23:10:18Z")

</div>

Thanks for all your tips and advice so far. Here's something else I encountered that I'm not sure how to resolve.

I'm building my playbooks such that they can bootstrap a system mostly from scratch for even high-level tasks. For instance, my playbook which sets up a VCS repository expects that I'm running LightTPD, so it calls out to a generic playbook to ensure that Lighty is installed. Similarly, it expects that CGI is configured, so it calls another playbook to configure Lighty for CGI and to upload a configuration that adds index.cgi as an index file type.

Because these Lighty configs are generic to a number of playbooks, I have them in an include directory. So, something like:

include/lighttpd.yml: Makes sure the lighttpd package is installed.  
include/lighttpd\_cgi.yml: Configures Lighty for CGI.  
include/lighttpd\_cgi/cgi-tweaks.conf: Configuration for local, CGI-specific tweaks. Copied to server via lighttpd\_cgi.yml.  
fossil/root\_project.yml: Sets up a Fossil project on the root of a specified domain, includes include/lighttpd.yml and include/lighttpd\_cgi.yml.

The problem is that, when lighttpd\_cgi.yml tries to copy lighttpd\_cgi/cgi-tweaks.conf, the file isn't found. It uses a path relative to itself.

I suppose I can refer to this file as if all playbooks will be in some subdirectory, so ../include/lighttpd\_cgi/cgi-tweaks.conf. But include directives seem to work relative to the file that includes them. I wonder if it might make sense for paths relative to src to originate at the directory of the file that calls them? Then I can reference lighttpd\_cgi.yml from anywhere and it will always find lighttpd\_cgi/cgi-tweaks.conf, without having to unwind the current directory first.

Is this currently doable?

Thanks.

---

<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:** [October 25, 2012, 11:18pm UTC](https://forum.ansible.com/t/src-relative-to-current-playbook/12030/2 "2012-10-25T23:18:35Z")

</div>

Basically the underlying problem is that Ansible's "path\_dwim" (do  
what I mean) function only passes down one directory to look for  
relative files in (as well as directories of included task files).

This is obviously not ideal, and the fix is to pass in all directories  
of ALL playbooks, and be smart and try to find the file in any of  
them.

For now, file paths relative to the top level playbook \*do\* work, but  
I completely agree this is suboptimal.

It's something we'll have resolved for 0.9.
