Best practices for folder structure in Ansible

48 views
Skip to first unread message

akazi...@gmail.com

unread,
Nov 21, 2017, 2:11:30 AM11/21/17
to Ansible Project
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
    - ...

4.  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
Reply all
Reply to author
Forward
0 new messages