Book Image

Creating Development Environments with Vagrant

By : MICHAEL KEITH PEACOCK
Book Image

Creating Development Environments with Vagrant

By: MICHAEL KEITH PEACOCK

Overview of this book

Table of Contents (17 chapters)
Creating Development Environments with Vagrant Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Provisioning with Ansible on Vagrant


In order to use Ansible within a Vagrant project, we need to tell Vagrant where the playbook and inventory files are:

config.vm.provision "ansible" do |ansible| 
  ansible.playbook = "provision/ansible/playbook.yml"
end

Ansible needs to know which machines to provision; unlike with other provisioners, where this is explicitly known from the Vagrantfile configuration, Ansible uses an inventory file to configure this. The inventory file contains a list of environment names and IP addresses; we use this file to restrict which commands Ansible runs on specific environments. We can omit this file, and Vagrant will generate one for all of the virtual machines it manages for us in the current project.

We can also create our own inventory file. At a minimum, it needs to know the name of the virtual machine (from our Vagrantfile) and the IP address. To provide only these two pieces of information, this requires the virtual machine to be running on its own IP address...