# Playbooks in subdirectories

**URL:** <https://forum.ansible.com/t/playbooks-in-subdirectories/20928>\
**Category:** Ansible Project\
**Created:** [March 19, 2016, 3:34am UTC](https://forum.ansible.com/t/playbooks-in-subdirectories/20928 "2016-03-19T03:34:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Max\_Kraszewski](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@Max\_Kraszewski](https://forum.ansible.com/u/Max_Kraszewski)\
**Post date:** [March 19, 2016, 3:34am UTC](https://forum.ansible.com/t/playbooks-in-subdirectories/20928/1 "2016-03-19T03:34:50Z")

</div>

Hi!  
After reading the docs, dozens of group messages and several articles, I can’t find the way to locate playbooks in subdirs.  
I’m having a large, complex project to deploy several and different installations in multiple hosts, and the amount of playbooks are growing up.  
At this moment, everything works fine with my playbooks located at project’s root folder, but I’d like a little more organization  
So I decided to create a **playbooks** folder and move them in some subdirectories inside.  
Following [this repository](https://github.com/enginyoyen/ansible-best-practises) guideline, I created an ansible.cfg file with role\_path=…/roles

This is my folder (re)structure

`  
project

> \_ inventory  
> \_ playbooks  
> \_ ansible.cfg  
> `|_ webservers.yml`  
> `|_ databases.yml`` `````|_ roles` ``|_ nginx`` ```|_ php``` ``````|_ mysql`

```auto
`

But when I run

`
> ansible-playbook -i inventory plays/webservers.yml

`

it throws the error

`
ERROR! the role 'nginx' was not found in /Users/max/Work/project/playbooks/roles:/Users/max/Work/project/playbooks:/etc/ansible/roles
`

It seems that the role_path is not working, and I don't have any more ideas-
So my question is: is there a way to achieve subfolder organization to playbooks?

Thanks a lot for any help!
Max
```

---

<div class="post-metadata">

**Author:** ![Benjamin\_Redling](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@Benjamin\_Redling](https://forum.ansible.com/u/Benjamin_Redling)\
**Post date:** [March 20, 2016, 12:49am UTC](https://forum.ansible.com/t/playbooks-in-subdirectories/20928/2 "2016-03-20T00:49:19Z")

</div>

Hi Max,

> [...] but I'd like a little more organization  
> So I decided to create a \*playbooks\* folder and move them in some  
> subdirectories inside.

Isn't a vast number of tasks in the project's main folder a sign that  
you aren't using roles enough?

> Following this repository  
> \<[https://github.com/enginyoyen/ansible-best-practises&gt](https://github.com/enginyoyen/ansible-best-practises&gt); guideline, I created  
> an ansible.cfg file with role\_path=../roles

roles\_path not role\_path -- but I guess it's just a typo in the mail.

[http://docs.ansible.com/ansible/playbooks\_roles.html](http://docs.ansible.com/ansible/playbooks_roles.html)  
suggests to use a central location for all roles across projects and use  
roles\_path with one (absolute) path:  
"  
In Ansible 1.4 and later you can configure a roles\_path to search for  
roles. Use this to check all of your common roles out to one location,  
and share them easily between multiple playbook projects. See  
Configuration file for details about how to set this up in ansible.cfg.  
"

Using recommendations and best practices from ansible.com has the  
advantage that on-boarding others is relatively easy. You'll have a  
single source to point them to.

Regards,  
Benjamin

---

<div class="post-metadata">

**Author:** ![Mike\_Biancaniello](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@Mike\_Biancaniello](https://forum.ansible.com/u/Mike_Biancaniello)\
**Post date:** [March 21, 2016, 3:02pm UTC](https://forum.ansible.com/t/playbooks-in-subdirectories/20928/3 "2016-03-21T15:02:17Z")

</div>

I agree that it’s annoying, especially if you try to organize by includes and reusable playbooks, it’s hard to tell, looking at a list of \*.yml files which ones are the top-level and which are meant to be included.

If you’re not using roles and only using tasks, you can put your tasks in a tasks/ subfolder and then include them and everything will use the dir of the playbook as the ansible root.

However, if you’re using roles, the roles are assumed to be in a subdir of the playbook, so you can either create a playbooks/ subdir and reference your roles like:

./stuff.yml

`

---

<div class="post-metadata">

**Author:** ![Max\_Kraszewski](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@Max\_Kraszewski](https://forum.ansible.com/u/Max_Kraszewski)\
**Post date:** [March 21, 2016, 11:21pm UTC](https://forum.ansible.com/t/playbooks-in-subdirectories/20928/4 "2016-03-21T23:21:04Z")

</div>

Benjamin, Mike:  
Thanks for your replies and your advices.  
Now I know I need to reorganize a bit mi playboks and try to follow the Ansible best practices more closely.

Thanks in advance!!

Max
