# directory layout for grouping playbooks - ansible.cfg ?

**URL:** <https://forum.ansible.com/t/directory-layout-for-grouping-playbooks-ansible-cfg/18329>\
**Category:** Ansible Project\
**Created:** [May 28, 2015, 9:50am UTC](https://forum.ansible.com/t/directory-layout-for-grouping-playbooks-ansible-cfg/18329 "2015-05-28T09:50:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Torsten\_Reinhard](https://avatars.discourse-cdn.com/v4/letter/t/46a35a/32.png) [@Torsten\_Reinhard](https://forum.ansible.com/u/Torsten_Reinhard)\
**Post date:** [May 28, 2015, 9:50am UTC](https://forum.ansible.com/t/directory-layout-for-grouping-playbooks-ansible-cfg/18329/1 "2015-05-28T09:50:39Z")

</div>

Hi,

we have several playbooks and roles in our project so I try to organize them in that way:

`\---deployment \---trunk`| ansible.cfg`

> app1.yml  
> `| ....yml`  
> `| app[N].yml`  
> ±–files  
> ±–filter\_plugins  
> ±–group\_vars  
> ±–library  
> ±–playbooks  
> ±–provisioning
> 
> > > binaryBuild.yml  
> > > root.yml  
> > > site.yml  
> > > user.yml  
> > > ±–roles  
> > > `| | | `test-java.yml  
> > > ±–java

`

we put the ansible.cfg to the root of our project (trunk) to keep all settings in a central place, so whenever somebody checks out that project it should be executable.

Now, when invoking

`ansible-playbook -i /path/to/inventory/hosts playbooks/provisioning/site.yml`

the execution faills because of missing roles, filter\_plugins and so on. Ansible tries to load those relative to the playbook - and not relative to the current directory!

Only workaround I found is to add a list of settings to the ansible.cfg file:

`  
roles\_path = roles: …/roles: …/…/roles  
filter\_plugins = filter\_plugins:…/filter\_plugins:…/…/filter\_plugins:~/.ansible/plugins/filter\_plugins/:/usr/share/ansible\_plugins/filter\_plugins

`

```auto

Using ${ANSIBLE_HOME} in the ansible.cfg to have fixed path also did not work for me.

=> What is the "best practice" to organize real-life projects, containing a huge list of playbooks? 
=> Also, where do people put their "test playbooks", for integration testing of roles ?

I dont want a solution based on 
* ansible.cfg outside the project ( HOME directory or any other user dependant place)
* symlinks

I couldn´t find any hint concerning "test playbooks" and "organizing modules" in the documentation.

Thanx for any advice, 

Torsten

```

---

<div class="post-metadata">

**Author:** ![Torsten\_Reinhard](https://avatars.discourse-cdn.com/v4/letter/t/46a35a/32.png) [@Torsten\_Reinhard](https://forum.ansible.com/u/Torsten_Reinhard)\
**Post date:** [May 28, 2015, 10:55am UTC](https://forum.ansible.com/t/directory-layout-for-grouping-playbooks-ansible-cfg/18329/2 "2015-05-28T10:55:23Z")

</div>

in addition, also the group\_vars cannot be resolved - they are expected relative to the playbook(s) - or the inventory hosts file.

=\> how do i define common group\_vars/all.yml - when i want to structure my playbooks in (sub) directories ?

Regards, Torsten

---

<div class="post-metadata">

**Author:** ![Ulrich\_Hochholdinger](https://avatars.discourse-cdn.com/v4/letter/u/839c29/32.png) [@Ulrich\_Hochholdinger](https://forum.ansible.com/u/Ulrich_Hochholdinger)\
**Post date:** [May 28, 2015, 3:09pm UTC](https://forum.ansible.com/t/directory-layout-for-grouping-playbooks-ansible-cfg/18329/3 "2015-05-28T15:09:06Z")

</div>

Hi,  
I’m also in the situation to get “many” different projects under control and use following directory structure:

- one folder per project with dependeing playbooks and roles
- global inventory with one folder per stage (since the project share hosts I made only one inventory )
- group\_vars and host\_vars only in inventory
- global "site.yml’ including playbooks out of projects
- "only for “global\_roles” I had to add one Entry in roles\_path in my ansible.cfg

I don’t know if this is good practice. Improvements and tips are welcome 😃

Details:

site.yml example:

---

<div class="post-metadata">

**Author:** ![Yoshi\_Spendiff1](https://avatars.discourse-cdn.com/v4/letter/y/8c91f0/32.png) [@Yoshi\_Spendiff1](https://forum.ansible.com/u/Yoshi_Spendiff1)\
**Post date:** [January 5, 2016, 1:50am UTC](https://forum.ansible.com/t/directory-layout-for-grouping-playbooks-ansible-cfg/18329/4 "2016-01-05T01:50:50Z")

</div>

Hi,

Torsten, did you ever find an answer?

It seems like it should be trivial to simply have a _plays_ or _playbooks_ directory, but I’m not finding a good way to do it…

Breaking down into projects isn’t what I’m looking for as I’d like to share roles

Regards,  
Yoshi

---

<div class="post-metadata">

**Author:** ![cohen.ben](https://avatars.discourse-cdn.com/v4/letter/c/c89c15/32.png) [@cohen.ben](https://forum.ansible.com/u/cohen.ben)\
**Post date:** [January 5, 2016, 4:28am UTC](https://forum.ansible.com/t/directory-layout-for-grouping-playbooks-ansible-cfg/18329/5 "2016-01-05T04:28:14Z")

</div>

I also yearn for a solution to this problem – I think that ansible playbooks don’t compose well – and roles are (in my opinion) a not-so-good abstraction for code re-use / process organization. Frequently for the ‘orchestration’ portion of some automation I find myself needing playbooks and the only way I can write playbook logic with access to resources that is shared with other playbooks (vars, group\_vars, plugins etc) is to keep them all in what becomes a giant directory of playbooks … Its both annoying and harder to organize/package for other users than it would be if I could compose the playbook units in a better way … I’d love to be able to:

(1) include a playbook from another playbook with dynamically specified hosts: eg something like:  
include: some-playbook.yml hosts={{some\_host\_or\_group\_determined\_by\_logic}}

(2) organize my playbooks so that I can suggest to other developers which playbooks are entry points and which are only meant to be used as part of other automation pipelines – while keeping a unified ‘file/template/plugin/var\_file…’ search space …  
include: ./some\_dir/some-playbook.yml keep\_resource\_search\_paths=true
