4. • Super simple to setup dev env
• Fully reproducible
• Having a setup that is as close to prod as possible
• Works with Chef, Puppet, Ansible & Shell Scripts to
provision your dev env
12. inventories/
dev
production
group_vars/
all/
main.yml
keys.yml
database
dev
production
host_vars/
...
site.yml
deploy.yml
roles/
database/
tasks/
main.yml
handlers/
main.yml
files/
foo.txt
templates/
bar.j2
vars/
main.yml
web/
...
memcached/
...
13. Inventories
Playbooks
inventories/
dev
production
group_vars/
all/
main.yml
keys.yml
database
dev
production
host_vars/
...
site.yml
deploy.yml
roles/
database/
tasks/
main.yml
handlers/
main.yml
files/
foo.txt
templates/
bar.j2
vars/
main.yml
web/
...
memcached/
...
14. Inventories
inventories/
dev
production
group_vars/
all/
main.yml
keys.yml
database
dev
production
host_vars/
...
# file: inventories/production
[web]
4.2.2.1
4.2.2.2
[database]
8.8.8.8
[production:children]
web
database
15. Inventories
inventories/
dev
production
group_vars/
all/
main.yml
keys.yml
database
dev
production
host_vars/
...
# file: inventories/production
[web]
4.2.2.1
4.2.2.2
[database]
8.8.8.8
[production:children]
web
database
# file: inventories/dev
[web]
192.168.33.16
[database]
192.168.33.16
[dev:children]
web
database
16. Inventories
inventories/
dev
production
group_vars/
all/
main.yml
keys.yml
database
dev
production
host_vars/
...
# file: inventories/production
[web]
Group
4.2.2.1
4.2.2.2
[database]
8.8.8.8
[production:children]
web
database
17. Inventories
inventories/
dev
production
group_vars/
all/
main.yml
keys.yml
database
dev
production
host_vars/
...
# file: inventories/production
[web]
Group
4.2.2.1
Host
4.2.2.2
[database]
8.8.8.8
[production:children]
web
database
18. Inventories > variables
inventories/
dev
production
group_vars/
all/
main.yml
keys.yml
database
dev
production
host_vars/
...
---
# file: group_vars/database
db_name: "{{ project_name }}_db"
db_user: "{{ project_name }}_pg"
db_encoding: UTF8
db_collate_and_ctype: en_US.UTF-8
db_template: template0
# file: inventories/production
[web]
4.2.2.1
4.2.2.2
[database]
8.8.8.8
[production:children]
web
database
22. Playbooks
- hosts: web
tasks:
- name: Ensure apache is at the latest version
yum: pkg=httpd state=latest
- name: Ensure apache is running
service: name=httpd state=started