Vagrant makes it very easy to play with Ansible locally. This article provides essential information about that process to get you started in no time.
First, install Vagrant binary. On OSX, it can be done with Homebrew Cask. For other OS, check Vagrant Downloads and download a binary that fits your case.
brew cask install vagrantLet's start by generating Vagrantfile.
vagrant initSince Vagrant 1.3, Ansible provisioner is built-in. Adjust Vagrantfile by
specifying a playbook file to use as an entry point.
Vagrant.configure("2") do |config|
config.vm.box = "hashicorp/precise64"
config.vm.provision :ansible, :playbook => "playbook.yml"
endYou can check Vagrant's Ansible Provisioner documentation for details, e.g. how to specify an inventory file or pass execution parameters.
Next, create playbook.yml in the same directory as Vagrantfile.
---
- hosts: all
sudo: yes
tasks:
- name: install cURL
apt: pkg=curl state=installedFinally, run vagrant up to start and provision the box. Once you changed the
playbook and your box is still running, you can simply vagrant provision to
apply those changes.