# Organize playbooks in subdirectories

**URL:** <https://forum.ansible.com/t/organize-playbooks-in-subdirectories/17905>\
**Category:** Ansible Project\
**Created:** [April 4, 2015, 2:35pm UTC](https://forum.ansible.com/t/organize-playbooks-in-subdirectories/17905 "2015-04-04T14:35:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andre](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@Andre](https://forum.ansible.com/u/Andre)\
**Post date:** [April 4, 2015, 2:35pm UTC](https://forum.ansible.com/t/organize-playbooks-in-subdirectories/17905/1 "2015-04-04T14:35:48Z")

</div>

Hi,  
I am trying to find a suitable directory structure for my ansible files. I have come up with this structure which is not working with the playbooks in subdirectories:

`. ├── group_vars ├── inventories │ ├── production │ │ ├── group_vars │ │ │ └── all.yml │ │ └── inventory │ └── vagrant │ ├── group_vars │ │ └── all.yml │ └── inventory ├── playbooks │ ├── net1 │ │ └── dnsdhcp.yml │ ├── net2 │ │ └── dnsdhcp.yml │ └── update.yml ├── roles`│ ├── dnsmasq` ``│ ├── bind9`` ``│ `````└`── isc-dhcp``  
├── playbooks  
└── Vagrantfile

`

In the group\_vars for the inventories I have variables which differ between the real servers and my vagrant test vms (IP addresses, domain names), this is working fine.

Then I would like to organize the playbooks into subdirectories so I don’t wind up with a directory with dozen of playbooks. The root group\_vars variables would then define the project wide configuration which can be used by multiple playbooks.

For example if I have two subnetworks and I need a DHCP server on each (possible different programs), I would write a playbook for each which installs the server (using roles) and put them in different subdirectories.

Then I have the master file which includes most playbooks. This file could be used to run ansible every day with a cron job.

The problem is that the group\_vars are relative to the current running playbook, so I can’t run

`ansible-playbook -i inventories/vagrant/inventory playbooks/net2/dnsdhcp.yml`

One way would be to flatten out the hierarchy in the playbooks directory and put a symlink to the root group\_vars directory in the playbooks directory:

`  
.  
├── group\_vars  
├── playbooks  
│ └── group\_vars → …/group\_vars  
│ ├── net1-dnsdhcp.yml  
│ ├── net2-dnsdhcp.yml  
│ ├── update.yml

`

`But then I would have to prefix the files for different subnets and would have one directory with many playbooks.`

Is this a good way to organize the playbooks? I’m not sure if I understand the purpose of the playbooks correctly, am I putting the right plays in the playbooks or should I organize the plays in an other way into playbooks?
