Configuration Management with Ansible:
A Whirlwind Tour

Why choose Ansible vs Chef or Puppet?

• Easiest to get started with
• No agents, no client/server
• Done over SSH
• Ansible can scale to thousands of hosts
• Ansible uses Python, yay!


Super-simple Ansible Tutorial

# Install Ansible
apt-get install ansible

Folder Structure


roles: can be further segregated into webserver, dbserver etc.
handlers: for very simple task
tasks: main configuration
templates: files that have variables; use python jinja2 template engine


• A playbook is a collection of tasks split into different roles
• We want to set up a new machine

Prep the machine

• add sshkey (or install sshpass and use --ask-pass)
• install python, python-apt

# Run a playbook
cd dirname
ansible-playbook -i hosts site.yml

Ansible Development Workflow:

• write some stuff
• run some stuff
• check if everything actually worked
• fix bugs, run again
• repeat


A larger Ansible project

mkdir -p basics/{group_vars,roles}/
touch group_vars/all
touch site.yml
mkdir -p roles/common/{files,handlers,tasks,templates}
touch /roles/common/{handlers,tasks}/main.yml

tree .