Introduction to Vagrant
The dictionary meaning of the Vagrant is “A person without a settled home or regular home who wanders from place to place and lives by begging. or vagabond"
This is very synonymous to the lifestyle of a developer. We build our application and push it to Production after a lot of hassle and take a great sigh of relief!!...But this is not the end of the story!!.
When a Production Bug is identified and reported back to the development Team, the developer keeps wandering from desk to desk searching for a system with an environment similar to PROD, so as to replicate the issue and resolve the issue within SLA and avoiding escalations. The challenge here is not for resolving the issue, but getting an infrastructure setup and replicate the issue to proceed further.
As, we all understand, its not an easy job to make a prod environment setup available in few hours – considering and respecting the formalities of the Operations Team.
Also there is a common problem for most of the Enterprise Application Deployments, that can be represented with the help of a mathematical expression:
Development !=Production Environment
Production!= Development Environment
Therefore, for any issue the Developer has a weapon = “It works on my box”
This is a very developer friendly quote, irrespective of any issue and any priority. “See..it works on my system, donno....why the same is not working the Prod Env”
So, what next!! ..
This is where “Virtualization Tools” come to the rescue of the Developers. Vagrant is one such tool.
When we talk about Virtualization we cannot miss Vmware:
- Having said that, the additional hardware cost and maintenance cannot be ruled out which is still an overhead
- But, yes with the all new vFabric product suite and AppDirector life is made easy with a price tag!!
The cloud, can also be considered as a ray of hope with the features provided by the products like, Amazon AWS,Vmware CloudFoundry or Rackspace, making life easy for the developer. But, still this is not a realistic approach from a developer standpoint and moreover, Cloud Management itself increases the cost exponentially along with the overheads of bandwidth access.
So, What is Vagrant?
- It Create and configure lightweight, reproducible, and portable development environments
- Most importantly it is an Open Source Software – Free!!
- It automates virtual machine creation using Oracle’s Virtual Box
- The package/product is written in Ruby
- Avoiding all confusions, it is not a Virtual Machine solution, like Virtualbox, VMware.
- It is just a “helper”, a automated solution to interact easily with VirtualBox from Oracle.
- It sets-up a new VM based on the pre-configured Box that is specified on the Vagrantfile. The user does not have to open VirtualBox and configure the system, vagrant will deal with it.
- It automates provisioning of virtual environments using Chef or Puppet (i.e. Deployment Automation or Configuration Management Tools)
- Static IPs are assigned to the VM, and is accessible from outside
- Necessary Ports can be enabled for access
- The best part is, once the job is done, the environment can be destroyed or removed
- The entire setup can be brought to life, in a few minutes, by clicking a single command
Why Vagrant and What are the Advantages of using it?
- Reduces the Setup time
- Very simple and straight forward
- Self servicing, based on Pull from a Base Box(each VM is based on a base box)
- Consistency can be maintaining by spawning multiple instances which are just identical.
- Repeatability (A new VM can be created and crushed in few minutes)
- Helps create a production-like VM in minutes
- The same puppet files can be used to generate developer environments
- With an agile driven development approach where testing becomes handy, virtualization tools like Vagrant, offer a great helping hand.
- The advantage of running a full stack locally
Also, every Developer in the Team, does not have to go through the pain of identifying which software version to download and from where, so as to sync up with his/her project mate desktop environment. The replica of the image is just a command away and the environment is all set. Create once Development Environment and distribute to the Team.
A combination of Configuration Management (Puppet or Chef) + Virtualization (Vagrant) is a perfect combination to meet the enterprise needs.
Virtualization tools like Vagrant can create environments with a couple of clicks and Configuration Management Tools like Puppet/Chef can use the manifest files to load or configure the new Instance/Environment with necessary software setup and services startup.
The following is a representation for provisioning multiple instances :
How do I go about setting it up ?
- The following are the steps that needs to be executed :
- Install Ruby on your OS/Machine
- Install the necessary pack of Oracle Virtual Box available at virtualbox.org
- Install the Latest Package of Vagrant available at vagrantup.com
Concluding thoughts : Feel Good Factor
Imagine a situation, you are working on a Critical Prod Issue and for some reason the Instance/System goes down!!...booom!!..or you need 5 similar instances urgently!!....
This is where tools like these become life saviours, where the Developer himself can Create a New Environment by running one command, and once the work is done, can just destroy the virtual instance. Fast and Easy. Reproducing what we have Lost is definitely a “Moral Booster” for any hard-core developer!! And the best part is all the machines comply the same standards.
Note : If you have any thoughts and interesting links please do share. Stay tuned for the next blog spot on a detailed usecase based implementation using Vagrant and Puppet.
Reference Reading :
- Vagrant Site : http://vagrantup.com/
- Getting Started : http://vagrantup.com/v1/docs/getting-started/index.html
- Puppet provisioning using Vagrant : http://vagrantup.com/v1/docs/provisioners/puppet.html
- What is Vagrant : http://blog.rubyhead.com/2010/07/26/what-is-vagrant/
Happy Learning!! :-)