Philly DevOps, meet Ansible

Zero to Vagrant

Ansible Basics

Brought you by chadoh, from PipelineDeals

Approachable & up-to-date!

Install it

Ansible is written by Python folk, so you've gotta do a wee bit of that:

			easy_install pip
			pip install paramiko PyYAML jinja2
      git clone [email protected]:ansible/ansible.git ~/?/
      echo "source ~/?/ansible/hacking/env-setup -q" \
            >> ~/.bashrc

Tell Ansible about your machines

By default, Ansible looks for your inventory file at /etc/ansible/hosts

      localhost ansible_connection=local
      shared-dev ansible_ssh_host=fqdn ansible_ssh_user=user
      prod ansible_ssh_host=fqdn ansible_ssh_user=user
      bitcoins ansible_ssh_host=fqdn ansible_ssh_user=user


Use individual ansible modules to do stuff to all (or some (or one)) your machines at once.

      ansible all -m copy -a "src=~/.bashrc dest=/var/tmp/bashrc"
      ansible work -m apt -a "name=cowsay"
      ansible work -m shell -a "cowsay Hooray Ansible"
      ansible localhost -m homebrew -a "name=cowsay"


Playbooks are a bundled set of one-offs, saved in a yaml file.

These get too lengthy for a slide; check out this simple starter playbook.


Vagrant allows you to set up a development VM with Ansible. :private_network, ip: ""
      config.vm.provision :ansible do |ansible|
        ansible.playbook = "../ansible-starter/playbook.yml"
        ansible.inventory_file = "../ansible-starter/hosts"

Vagrant troubleshooting

Sometimes, when you run vagrant up, you'll get unexpected failures. Before getting distraught, try running vagrant reload and perhaps (if that fails, too) vagrant up (or vagrant provision) again.

Fork me on Github