In the software development world, an ideal development environment is a key to developing resourceful software products but sometimes maintaining and configuring this development environment becomes a herculean time-consuming task. That’s where the Vagrant virtual machine manager comes into play.
By using Vagrant we can create an exact copy of the dedicated environment where the application or software product gets deployed once it’s in production. Same as a dedicated server, we can specify the operating system and its version, libraries needed, and their dependencies using the Vagrant platform.
Since Vagrant is open source, anyone can download it, modify it, and share it freely among team members. To start using Vagrant in a local environment we need any of the commonly known virtualization providers like VirtualBox or VMWare or if we want to host to the cloud, Vagrant provides support for many cloud hosting providers as well each of these supported environments is called Providers in Vagrant.
Vagrant uses boxes – boxes are actually virtual machines pre-configured with software in it. We can search and find a lot of existing boxes at “app.vagrantup.com” – if we can find the desired box, we can use it directly. If it’s close, we can create a customised one based on our needs. We can also build our boxes from scratch using Virtualbox.
Boxes in Vagrant go through two stages – configuration, in this stage the virtual machine is created and the next stage is provisioning, in this stage the software, dependencies, and various network settings are applied.
Just like a Virtual machine, we can start, stop, and destroy vagrant boxes, we can use the command vagrant up to specify starting up of a Vagrant box. Vagrant boxes are halted or suspended (a VM pause or shutdown) when we complete using them. Also, Vagrant boxes can be removed or destroyed by using the destroy command. We can incorporate all sorts of tools to help our development, tools like Chef, Puppet, or Ansible can be used and these tools are called provisioners in Vagrant.
And the most useful feature of Vagrant is the option to version control the boxes using Vagrantfile, The Vagrantfile is a Ruby file used to configure Vagrant on a per-project basis. The main function of the Vagrantfile is to describe the virtual machines required for a project as well as how to configure and provision these machines.
Other than using a VirtualBox or any other virtualization software to create a specific development environment, and then manually configuring and installing needed software above it, developers can use Vagrant and checkout a repository which having their desired Vagrantfile for creating the required set of dependencies and configurations and then do a vagrant up command which will create a production copy of that exact environment in minutes and this can save a lot of time during software test and development procedures.