Why vagrant is still fruitful for developers

“This article is an upgraded version of my last article written around 18 months back. Can See the Why Vagrant and how it works

You may also like: Why Vagrant and how it works

Why vagrant is still fruitful for developers. We have much advance docker available?

Today we are leaving in the world of containers , which is independent deployable unit. Which is a bundle of code and infrastructure documentation into it. As it runs it will prepare itself and get it running. And because of the docker we are also moving in the world of micro services which gives us the flexibility to choose the best for whatever its built for. It means if Java is good for writing backend code then use Java where more security is preferred and use node where fast latency required and streaming required. Fare enough !!

The scenario we have mentioned above is really good from application perspective but from developers perspective just think for couple of scenarios

Scenario 1:

From a developer perspective most of us are from not begin our career with microservices (even someone started s/he should know the environment from closer). So we love to be into the environment  while we are doing development. For example we are good with Cent OS and someone has given a windows machine. So s/he may not like the environment its really hard to change from one machine/dev environment to another (because it’s a requirement because of microservices)

Scenario 2:

I spent around four hours,  when I was in the mid of the setup, I found that I have made some mistake in my first step (some configuration was not enabled ) . Now it was required to clean all the installation (which obviously will again take time, ensure nothing left and then start again).

So the problem is with time and effort made during environment switching. E.g.,:

  • Time to install the softwares
  • Time to uninstall the softwares, In case of any issue
  • Clear/flush all the changes
  • The same work to be done on each machine of every developer
  • Each developer needs to start with same environment

How vagrant can help developer into this space

Vagrant is the solution. Because vagrant provides a facility to create another machine on top of your machine which use resources from your machine obviously but this machine will contain all the application softwares even with the new OS itself. The good thing is that you can destroy this machine anytime and your host machine will still as it is . No need to uninstall any software manually. Just destroy the machine and everything else gone.
As per the definition from Vagrant

“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.”

Vagrant installation

1. Install oracle virtual machine on host machine first
2. Install vagrant from here.
Once you are installed both softwares you are done.

Using vagrantfile

1. Either you can create your own vagrantfile then run the command “vagrant init”. It will create vagrant file, add your description here
2. Download any vagrant file (github or any place) and use it with some commands. and keep it up on any folder. From where you need to spin up a machine. Go to CMD  of that folder and run the command

  • vagrant up : to install and configure all the softwares on new machine
  • vagrant ssh: to go inside the machine
  • vagrant reload: to restart the vagrant machine
  • vagrant halt: to shut down the running machine

Using vagrant plugin

Vagrant support different kind of plugins. One of the important plugin name is vagrant-scp which upload/download host machine file to vagrant machine.

• To install vagrant-scp plugin :

vagrant plugin install vagrant-scp

Here its notable that this plugin will get installed through normal command line. Not after vagrant ssh command line.
• To see which all vagrant machine are running on your host machine
vagrant global-status (you will get name)
vagrant scp [vm_name]:
vagrant scp [vm_name]:
For example:

vagrant scp kubeadm-setup-master.sh master:/home/vagrant
The following two tabs change content below.

Chandra Shekhar

GCP Architect
Chandra Shekhar Pandey is Google certified Cloud engineer, I am Magento2 Trained developer. Having huge experience in designing cloud solution. I have around 12 years of experience with world enterprise IT companies and fortune 500 clients. During my architecture design I am always caring about high availability, fast performance and resilient system. From the programmer background I have huge experience in LAMP stack as well. Throughout my carrier I have worked on Retail, E-Learning, Video Conferencing and social media domain. The motive of creating cutehits was just to share the knowledge/solutions I get to know during my day to day life so that if possible I can help someone for same problems/solutions. CuteHits.com is a really a very effort for sharing knowledge to rest of the world. For any query/suggestion about same you can contact me on below details:- Email: shekharmca2005 at gmail.com Phone: +91-9560201363

Latest posts by Chandra Shekhar (see all)

You may also like...