Ansible Directory Layout
Review possible Ansible directory layouts.
We'll cover the following
When to create a repository
-
Per team
- SRE
- Infrastructure
- Network
-
Per application and or platform
- Redis
- Navigation
- Database
The reason being, they have different workflows.
Following are the possible layouts for an Ansible directory:
Basic
Review the basic layout below:
|-- dev.yml|-- production.yml|-- group_vars/| |-- all.yml| |-- linux.yml| |-- windows.yml|-- host_vars/| |-- linuxweb01.yml| |-- winweb01.yml|-- ping.yml|-- win_ping.yml|-- configure_nginx_web_server.yml|-- configure_iis_web_server.yml|-- roles/| |-- chocolatey/| |-- ngnix/| |-- iis/
Alternate
Review the alternate layout below:
|-- inventories/| || |-- dev/| | |-- hosts| | |-- group_vars/| | | |-- all.yml| | | |-- linux.yml| | | |-- windows.yml| | |-- host_vars/| | | |-- linuxweb01.yml| | | |-- winweb01.yml| || |-- production/| | |-- hosts| | |-- group_vars/| | | |-- all.yml| | | |-- linux.yml| | | |-- windows.yml| | |-- host_vars/| | | |-- linuxweb01.yml| | | |-- winweb01.yml|-- ping.yml|-- win_ping.yml|-- configure_nginx_web_server.yml|-- configure_iis_web_server.yml|-- roles/| |-- chocolatey/| |-- ngnix/| |-- iis/
Multistage
Review the multistage layout below:
|-- environments/| || |-- 000_cross_env_vars| || |--dev/| | |-- hosts| | |-- group_vars/| | | |-- all/| | | | |-- 000_cross_env_vars -> ../../../000_cross_env_vars| | | | |-- env_specific| | | |-- linux.yml| | | |-- windows.yml| | |-- host_vars/| | | |-- linuxweb01.yml| | | |-- winweb01.yml| |production/| | |--hosts| | |--group_vars/| | | |-- all/| | | | |-- 000_cross_env_vars -> ../../../000_cross_env_vars| | | | |-- env_specific| | | |-- linux.yml| | | |-- windows.yml| | |-- host_vars/| | | |-- linuxweb01.yml| | | |-- winweb01.yml|-- ping.yml|-- win_ping.yml|-- configure_nginx_web_server.yml|-- configure_iis_web_server.yml|-- roles/| |-- chocolatey/| |-- ngnix/| |-- iis/
The highlighted lines represent the following:
- Line-3: symbolic link, shares variable across all environments
- Line-10: env specific variables
Both 000_cross_env_vars
and env_specific
are provided to the hosts via the all
group.
Get hands-on with 1300+ tech skills courses.