On Github skinofstars / talk-ansible
by Kevin
skinofstarsInstalling packages
Configuration
Updating app code
Vagrant
Any old server set-up
Cloud instances management
Workbox set-up
Chef
Puppet
Salt
Ansible
Uses Python, so pretty universal
Uses SSH, so no installing on remote systems
Scripting with YAML, so even an idiot can use it
apt-get
apt-get install ansible
pip
easy_install pip pip install ansible
source
easy_install pip pip install pyyaml jinja2 nose passlib pycrypto git clone git@github.com:ansible/ansible.git source ./hacking/env-setup
INI format host files
default - /etc/ansible/hosts
[appservers] 192.168.1.23 192.168.1.99
or
[myapp:children] appservers dbservers [appservers] pedrosa.example.com ansible_ssh_user=dani lorenzo.example.com ansible_ssh_user=jorge [dbservers] db-[a:f].example.com
ansible appservers -m copy -a "src=/etc/hosts dest=/tmp/hosts"
I NEVER DO THIS!!!1!
I ALWAYS DO THIS!!!2!
--- # playbook.yml - hosts: appservers tasks: - name: Super secure secret sharing stuff copy: src=secrets.txt dest=/srv/public/secrets.txt mode=777
ansible-playbook appservers playbook.yml
--- # playbook - hosts: all vars: my_common_packages: - curl - git tasks: - name: Install some stuff apt: pkg={{ item }} state=present with_items: my_common_packages
There are also a lot of built in variables, like
{{ ansible_pkg_mgr }}
- name: Install some stuff on Debian apt: pkg={{ item }} state=present with_items: - curl - git when: ansible_pkg_mgr == "apt"
There are loads
Common tasks like apt, git, pg/mysql/redis... or shell scripts
Services like AWS, Linode, etc
Uses jinja2
--- # playbook.yml - hosts: all vars_prompt: name: "What is your name?" loot: "Where is the money?" tasks: - name: Super secure secret sharing stuff copy: src=secrets.txt dest=/srv/public/secrets.txt mode=777
# secrets.txt My name is {{ name }} The cash is at {{ loot }}
staging.yml production.yml
/roles /nginx /handlers main.yml /tasks main.yml /templates nginx.conf /vars main.yml
docs - docs.ansible.com
ansible-examples - github.com/ansible/ansible-examples
Galaxy - galaxy.ansible.com
Tower - ansible.com/tower