Philly DevOps, meet Ansible

Zero to Vagrant

Ansible Basics

Brought you by chadoh, from PipelineDeals

www.ansibleworks.com/docs

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 git@github.com: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
      [work]
      shared-dev ansible_ssh_host=fqdn ansible_ssh_user=user
      prod ansible_ssh_host=fqdn ansible_ssh_user=user
      [personal]
      bitcoins ansible_ssh_host=fqdn ansible_ssh_user=user
    

One-offs

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

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

Vagrant allows you to set up a development VM with Ansible.

      config.vm.network :private_network, ip: "192.168.111.222"
      config.vm.provision :ansible do |ansible|
        ansible.playbook = "../ansible-starter/playbook.yml"
        ansible.inventory_file = "../ansible-starter/hosts"
      end
    

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