Vagrant is a tool for building and managing virtual machine environments in a single workflow. With an easy-to-use workflow and focus on automation, Vagrant lowers development environment setup time, increases production parity, and makes the “works on my machine” excuse a relic of the past.
As it says on tin, Vagrant is a way to spin up VMs quickly in an automated manner. To get started simply:
This will download the base box from HashiCorp’s public vagrant box server and start the box. The centos/7
box specifically refers to https://atlas.hashicorp.com/centos/boxes/7.
The newly started box can then be accessed with:
The meat and potatoes of the Vagrant experience will be manipulated via the Vagrantfile
(created upon running vagrant init
).
Here is an example Vagrantfile
which will setup two machines and network them together via private interfaces.
This names two machines, instructs Vagrant to base them on the centos/7
box and assigns them static IP addresses on private interfaces.
It also triggers a script to run upon provisioning the box for the first time. In this case the bootstrap.sh
script resides in the same directory as the Vagrantfile
and contains some simple bash commands:
A provisioning script is definitely not required though!