If you do not know about Vagrant already, you should visit VagrantUp to know more about it. Vagrant is a solution to create and configure lightweight , reproducible and portable environments. In this article I describe how Vagrant is useful in creating test environments for your DevOps test lab needs.
For this article, I am considering the default provider Vagrant has support for, VirtualBox. VirtualBox is an opensource virtualization software. Vagrant allows you to spin up virtual machines from a base virtual machine and also lets you provision the guest virtual machine to install necessary software. Vagrant is a cross platform solution, meaning the host can be Linux, Windows or OSX and the guest can be a Linux, Windows or OSX(based on your test lab needs).
Consider a scenario where you would like to run your UI Automated tests using Selenium WebDriver on different OS/Browser combinations, as part of your DevOps test team, but want to utilize the computing resources in your organization instead of using a cloud provider. Many organizations implementing DevOps practices try using a cloud provider for their test lab needs since test cloud providers give a better automated approach of managing test labs. This is where Vagrant comes in. With Vagrant instead of having multiple VM images created in your servers, or relying on Cloud providers for your DevOps test lab needs(automated test infra), you can have base images created for the guest OS you need as part of your test lab and then provision each machine with the software to be installed in them.
For example you can have a plain Ubuntu 14.0, Windows 7,8,10 and OSX Yosemite base boxes and define the vagrantfile to provision each of the VM by installing specific browsers. You can use shell scripts, powershell(Windows), Chef or Puppet for provisioning. Use “vagrant init” and “vagrant up” to bring up your environments and your Test Lab is ready for use. Once you are done with your testing you can destroy the guest machines by “vagrant destroy”.
Since vagrant also supports various other providers such as VMWare, AWS etc and has many plugins, it really gets interesting on what you can achieve using this software. With DevOps testing requiring performance monitoring and testing, using Vagrant will be really advantageous to quickly spin up your test machines to generate the necessary loads.