Daniel Banck, @dbanck
#bcki14
(oder via yum, apt, aura, brew, source...)
pip install ansible
ansible webservers -m service -a "name=httpd state=started"
ansible webservers -m ping
ansible webservers -m command -a "/sbin/reboot -t now"
mail.example.com
[webservers]
foo.example.com
bar.example.com
[dbservers]
one.example.com
two.example.com
three.example.com
---
ntp_server: acme.example.org
database_server: storage.example.org
server {
listen [::]:80;
server_name {{ server_name }};
index index.html;
access_log /home/www/{{ user }}/logs/access.log;
error_log /home/www/{{ user }}/logs/error.log;
}
---
- hosts: webservers
vars:
http_port: 80
max_clients: 200
remote_user: root
tasks:
- name: ensure apache is at the latest version
yum: pkg=httpd state=latest
- name: write the apache config file
template: src=/srv/httpd.j2 dest=/etc/httpd.conf
notify:
- restart apache
- name: ensure apache is running
service: name=httpd state=started
handlers:
- name: restart apache
service: name=httpd state=restarted
production/ # production environment
group_vars/
group1 # here we assign variables to particular groups
host_vars/
hostname1 # if systems need specific variables, put them here
inventory
staging/
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
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
webtier/ # same kind of structure as "common" was above
monitoring/ # ""
fooapp/ # ""
coming soon™