Zero to Vagrant
Brought you by chadoh, from PipelineDeals
Approachable & up-to-date!
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
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
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.
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
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.