Compare commits
No commits in common. "c702f531b405fbb40549545cc02fdb608ddd8f7e" and "eabb96af36921b005574ddf4f22e179e9c6de58d" have entirely different histories.
c702f531b4
...
eabb96af36
91
README.md
91
README.md
@ -1,93 +1,2 @@
|
|||||||
# ansible-repository-template
|
# ansible-repository-template
|
||||||
|
|
||||||
[From ansible best practices](https://docs.ansible.com/ansible/2.8/user_guide/playbooks_best_practices.html)
|
|
||||||
|
|
||||||
## Directory Layout
|
|
||||||
|
|
||||||
The top level of the directory would contain files and directories like so:
|
|
||||||
|
|
||||||
```
|
|
||||||
production # inventory file for production servers
|
|
||||||
staging # inventory file for staging environment
|
|
||||||
|
|
||||||
group_vars/
|
|
||||||
group1.yml # here we assign variables to particular groups
|
|
||||||
group2.yml
|
|
||||||
host_vars/
|
|
||||||
hostname1.yml # here we assign variables to particular systems
|
|
||||||
hostname2.yml
|
|
||||||
|
|
||||||
library/ # if any custom modules, put them here (optional)
|
|
||||||
module_utils/ # if any custom module_utils to support modules, put them here (optional)
|
|
||||||
filter_plugins/ # if any custom filter plugins, put them here (optional)
|
|
||||||
|
|
||||||
site.yml # master playbook
|
|
||||||
webservers.yml # playbook for webserver tier
|
|
||||||
dbservers.yml # playbook for dbserver tier
|
|
||||||
|
|
||||||
roles/
|
|
||||||
common/ # this hierarchy represents a "role"
|
|
||||||
tasks/ #
|
|
||||||
main.yml # <-- tasks file can include smaller files if warranted
|
|
||||||
handlers/ #
|
|
||||||
main.yml # <-- handlers file
|
|
||||||
templates/ # <-- files for use with the template resource
|
|
||||||
ntp.conf.j2 # <------- templates end in .j2
|
|
||||||
files/ #
|
|
||||||
bar.txt # <-- files for use with the copy resource
|
|
||||||
foo.sh # <-- script files for use with the script resource
|
|
||||||
vars/ #
|
|
||||||
main.yml # <-- variables associated with this role
|
|
||||||
defaults/ #
|
|
||||||
main.yml # <-- default lower priority variables for this role
|
|
||||||
meta/ #
|
|
||||||
main.yml # <-- role dependencies
|
|
||||||
library/ # roles can also include custom modules
|
|
||||||
module_utils/ # roles can also include custom module_utils
|
|
||||||
lookup_plugins/ # or other types of plugins, like lookup in this case
|
|
||||||
|
|
||||||
webtier/ # same kind of structure as "common" was above, done for the webtier role
|
|
||||||
monitoring/ # ""
|
|
||||||
fooapp/ # ""
|
|
||||||
```
|
|
||||||
|
|
||||||
## Alternative Directory Layout
|
|
||||||
|
|
||||||
Alternatively you can put each inventory file with its group_vars/host_vars in a separate directory. This is particularly useful if your group_vars/host_vars don’t have that much in common in different environments. The layout could look something like this:
|
|
||||||
|
|
||||||
```
|
|
||||||
inventories/
|
|
||||||
production/
|
|
||||||
hosts # inventory file for production servers
|
|
||||||
group_vars/
|
|
||||||
group1.yml # here we assign variables to particular groups
|
|
||||||
group2.yml
|
|
||||||
host_vars/
|
|
||||||
hostname1.yml # here we assign variables to particular systems
|
|
||||||
hostname2.yml
|
|
||||||
|
|
||||||
staging/
|
|
||||||
hosts # inventory file for staging environment
|
|
||||||
group_vars/
|
|
||||||
group1.yml # here we assign variables to particular groups
|
|
||||||
group2.yml
|
|
||||||
host_vars/
|
|
||||||
stagehost1.yml # here we assign variables to particular systems
|
|
||||||
stagehost2.yml
|
|
||||||
|
|
||||||
library/
|
|
||||||
module_utils/
|
|
||||||
filter_plugins/
|
|
||||||
|
|
||||||
site.yml
|
|
||||||
webservers.yml
|
|
||||||
dbservers.yml
|
|
||||||
|
|
||||||
roles/
|
|
||||||
common/
|
|
||||||
webtier/
|
|
||||||
monitoring/
|
|
||||||
fooapp/
|
|
||||||
```
|
|
||||||
|
|
||||||
This layout gives you more flexibility for larger environments, as well as a total separation of inventory variables between different environments. The downside is that it is harder to maintain, because there are more files.
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user