Setting Up Development Environment Using Vagrant

Last updated on May 22,2019 7.5K Views

Vagrant is a computer software for creating and configuring virtual development environments. It can be seen as a wrapper around virtualization software such as VirtualBox, KVM, VMware and around configuration management software such as Ansible, Chef, Salt or Puppet, according to Wikipedia.

However, there are two important  terms i.e. Virtualization and Configuration Management.

In other words, Vagrant is a simpler way for Virtualization and Configuration Management. Virtualization and Configuration Management are two big names in devops culture. In this age of devops, a lot of automation is the key to success.

To achieve all this, vagrant is a handy tool for creating and configuring lightweight, reproducible, and portable development environment (Virtual Machines).

Let’s see how to install and create your first virtual development environment using Vagrant:

Step 1:  Before we start with Vagrant we need to install Virtual Box as Vagrant uses it to run the virtual machines.

Download the below guide to install Virtual Box:

Download Installation Guide

Step 2:  Download Vagrant from the URL below as per your operating system:

Download Vagrant

Step 3: Once you have the vagrant set up, installing it is as simple as installing VLC media player.

Step 4: Once you have vagrant on your machine, open the terminal (Linux or Mac) or command prompt (Windows)

Step 5: Create a separate directory for vagrant :

$ mkdir vagrant_edureka
$ cd vagrant_edureka

Step 6: Initialize a new VagrantFile. A Vagrantfile describes the type of machine required, and how to configure and provision it.

$ vagrant init

A Vagrant file looks like the one below:

# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at

# Every Vagrant development environment requires a box. You can search for
# boxes at = "base"

# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false

# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# "forwarded_port", guest: 80, host: 8080

# Create a private network, which allows host-only access to the machine
# using a specific IP.
# "private_network", ip: ""

# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# "public_network"

# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"

# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
# config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
# end
# View the documentation for the provider you are using for more
# information on available options.

# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
# such as FTP and Heroku are also available. See the documentation at
# for more information.
# config.push.define "atlas" do |push|
# end

# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
# config.vm.provision "shell", inline: <<-SHELL
# sudo apt-get update
# sudo apt-get install -y apache2

Step 7: After creating a new Vagrantfile, specifying the box to use for your Vagrant environment is always the first step. Instead of building a virtual machine from scratch, which would be a slow and tedious process, Vagrant uses a base image to quickly clone a virtual machine. These base images are known as boxes in Vagrant.

We are using “chef/centos-6.5” for this blog. You can see the list of boxes here.

Use the command below to install it.

$ vagrant box add chef/centos-6.5

Step 8: Update the Vagrant File as below:

# This defines the version of vagrant
Vagrant.configure(2) do |config|
	# Specifying the box we wish to use = "chef/centos-6.5"
	# Specifying the provider as VirtualBox and naming the VM
	one_config.vm.provider "virtualbox" do |v|
		# The VM will be named as edureka_vm1 = "edureka_vm1"

Step 9: Let’s start the edureka_vm1:

$ vagrant up

Congratulations! You have created your first VM using vagrant. Ans now, you must be wondering how to use it. You can access it using ssh.

You can connect the VM using the host and port number  below:
                                         Host :|   Port  : 2222

Step 10: Download putty (windows shh client) from here. Run the application and enter the details like below –> Click Open :

Putty Configuration

Step 11: You need to enter the username and password to log in into the VM. Please use the credentials below:
                                         Username : vagrant    |   Password  : vagrant

login as: vagrant
vagrant@'s password:

Step 12: Finally,  you are ready to use your first VM, created using vagrant. Use it and feel the difference:

login as: vagrant
vagrant@'s password:
Last login: Fri Jan 23 11:00:41 2015 from
[vagrant@localhost ~]$

The virtual machines created using vagrant are very light and runs smoothly on a machine with 2 -4 Gb RAM and i3 processor.

Before I end this blog, here is something you can work on. Using this blog you create a single virtual machine, but can we create multiple virtual machines using vagrant? Refer to this blog: 10 Steps To Create Multiple Virtual Machines Using Vagrant

Got a question for us? Please mention it in the comments section and we will get back to you.

Related Posts:

Mystery Of Devops


Get Started with Devops

Upcoming Batches For DevOps Certification Training Course
Course NameDate
DevOps Certification Training Course

Class Starts on 12th June,2023

12th June

MON-FRI (Weekday Batch)
View Details
DevOps Certification Training Course

Class Starts on 24th June,2023

24th June

SAT&SUN (Weekend Batch)
View Details
DevOps Certification Training Course

Class Starts on 10th July,2023

10th July

MON-FRI (Weekday Batch)
View Details
    • EdurekaSupport says:

      Thanks!! Do go through our other posts as well.

      • Souvik Kundu says:

        Almost all of your blog posts are highly informative and succinct. Thank you

        • EdurekaSupport says:

          Hi Souvik,
          Thank you for your positive feedback. We hope that you will find our blog useful in future as well. Keep visiting the Edureka Blog page for latest posts on this link:

Join the discussion

Browse Categories
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP

Subscribe to our Newsletter, and get personalized recommendations.

image not found!
image not found!

Setting Up Development Environment Using Vagrant