Hello Developers and welcome to our series on using Vagrant for development. This is our first article in the series where we’ll discuss what Vagrant is and why we should use it.
At a previous job we had a server for our production workload and then we each set up a local development environment to do our development. To do this we had a rough document that outlined what packages needed to be installed and what changes to make in our configuration files. This process worked well but we constantly had little differences between our environments. Every so often someone would install a vastly different version of a package and use a feature that didn’t exist in the production version of the package. When they deployed their code to production it would break the application and we would have to quickly roll back their changes.
Worse still would be the fact that due to the mismatch in setups a bug in production wouldn’t be reproducible in the developer’s environment and they would waste hours trying to fix it.
By using Vagrant we can quickly and easily set up a development environment with a minimal amount of human involvement.
What is Vagrant?
Vagrant is an open-source product that makes it easy to build and maintain software development environments. It uses hypervisors like VirtualBox and VMware to host the environment and provides a glue layer that allows us to set up the necessary software we need. Vagrant itself is written in Ruby so we may occasionally see references to Ruby and .rb files in the output.
To get started we’ll need to install Vagrant from https://www.vagrantup.com/. We’re using version 2.2.14 for this series and as always using a different version may cause a different set of outputs.
We’ll also need a hypervisor like VirtualBox or VMware Workstation. This article series was written using version 6.1.16 of VirtualBox. VirtualBox is a good way to get started with Vagrant because it’s free and open-source but VMware will give us a better performance.
Why Should We Use It?
There are numerous benefits to using Vagrant to set up our development environment.
- Vagrant makes resetting our development environment super easy. This makes it easy to set up a new computer or recover if something is broken.
- It helps reduce the “it works on my computer” excuses for bugs. Because we’re using a common setup we can be sure we’re using the same major/minor versions of packages
- It provides the “glue” that makes it easier to develop our code such as setting up a shared directory between the host and the guest VM. This allows us to use our favorite GUI applications without having to jump through any extra hoops.
The core piece of technology that Vagrant leverages to set up our development environment is the Virtual Machine (VM). VMs are essentially a file that a piece of software known as a hypervisor uses to run an operating system that behaves like a completely separate computer inside another computer.
For more information on virtual machines be sure to check out our article “What’s a Virtual Machine?”.
Scott is the Director of Technology at WeCare Connect where he strives to provide solutions for his customers needs. He's the father of two and can be found most weekends working on projects around the house with his loving partner.
- Working With Soft Deletes in Laravel (By Example)
- Fixing CMake was unable to find a build program corresponding to "Unix Makefiles"
- Upgrading to Laravel 8.x
- Get The Count of the Number of Users in an AD Group
- Multiple Vagrant VMs in One Vagrantfile
- Fixing the "this is larger than GitHub's recommended maximum file size of 50.00 MB" error
- Changing the Directory Vagrant Stores the VMs In
- Accepting Android SDK Licenses From The OSX Command Line
- Fixing the 'Target class [config] does not exist' Error
- Using Rectangle to Manage MacOS Windows
More In This Series
- What's a Virtual Machine?
- Why Use Vagrant?
- Initializing a Vagrant Development Environment
- Managing A Vagrant Environment's Power State
- How to Reset/Delete A Vagrant Development Environment
- Configuring Our Vagrant Development Environment's Network
- Remotely Accessing Our Vagrant Development Environment (Linux/Ubuntu)
- Syncing Files to Our Vagrant Development Environment
- Customizing the Amount Of RAM in Our Vagrant VMs
- Displaying Our Vagrant VMs User Interface
- Saving Vagrant States Using Snapshots