# Best practices for folder structure in Ansible

**URL:** <https://forum.ansible.com/t/best-practices-for-folder-structure-in-ansible/26092>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [November 21, 2017, 7:11am UTC](https://forum.ansible.com/t/best-practices-for-folder-structure-in-ansible/26092 "2017-11-21T07:11:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![akazia.info](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@akazia.info](https://forum.ansible.com/u/akazia.info)\
**Post date:** [November 21, 2017, 7:11am UTC](https://forum.ansible.com/t/best-practices-for-folder-structure-in-ansible/26092/1 "2017-11-21T07:11:29Z")

</div>

Hello experts,

after going over the ansible documentation I have found this mix of recommendations a good starting point to setup a brand new structure. Here is the idea:

1. Inventory: I split it into two so that I can decouple prod from staging. Concerning the variables would place here only complete global stuff which is independent from tasks. e.g windwos login creds … ok?

2. site.yml incudes playbooks I have webservers.yml as example for one playbook here, I tend to use for the playbooks the same names as I have in the inventory for the groups of host - is that ok?

3. webservers.yml only defines the groups to act on and “calls” roles.

- name: apply the webserver configuration  
hosts: webservers  
roles:
- javajdk
- …

1. the roles should be more or less self standing, so I want to define needed variables “in” the substructur (pls see roles/var)

Questions I have:

- it this approach simple and flexible enough to server lager environments?
- is the location for variable declaration ok
- do the naming pattern fit

.

├── inventories

│ ├── production  
│ │ │

│ │ …

│ └── staging

│ ├── group\_vars  
│ │ └── windows.yml  
│ ├── hosts  
│ └── host\_vars  
│ └── hostname1  
├── roles

│ └── javajdk

│ ├── defaults  
│ │ └── main.yml  
│ ├── files  
│ │ ├── …  
│ │ └── webapps.zip

│ ├── handlers  
│ │ └── main.yml  
│ ├── meta  
│ │ └── main.yml  
│ ├── README.md  
│ ├── tasks  
│ │ └── main.yml  
│ ├── templates  
│ ├── tests  
│ │ ├── inventory  
│ │ └── test.yml  
│ └── vars  
│ └── main.yml  
├── site.yml  
└── webservers.yml

All the best and thanks a lot  
Michael
