DZone
Cloud Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Cloud Zone > Virtualization Matters: Part 1 — From Virtualbox to Vagrant

Virtualization Matters: Part 1 — From Virtualbox to Vagrant

In Part 1 of this series, I am going to talk about the basics of Virtualbox and Vagrant. Read on for more informaiton.

Hardik Pandya user avatar by
Hardik Pandya
·
Mar. 16, 16 · Cloud Zone · Analysis
Like (3)
Save
Tweet
3.42K Views

Join the DZone community and get the full member experience.

Join For Free

In Part 1 of this series, I am going to talk about Virtualbox and Vagrant. In Part 2, I will talk about what the differences are between Vagrant and Docker. As development cycles become shorter and shorter and your startup wants to be 10 years ahead today virtualization affects us all. In Part 3, I want to build and test Spark Application on Docker, stay tuned!

Back in 2007 – Rise of Type-2 Hypervisor

Just to provide some context... I hope everyone is familiar with VirtualBox, which basically provides a way to run any OS as a guest OS in your host machine (Linux/Windows/Mac) etc.

VirtualBox
Developer’s life in Virtual Box – well it works great, wait till it crashes again...again and again…man, I lost my last 2 days of work—wish I would have committed it sooner.

bang_head

2010: Here Comes Vagrant

Written in Ruby, Vagrant is a scripting engine for VirtualBox. It allows you to set up multiple virtual machines.

But, why would someone want to do that?

Import/use Pre-configured Virtual Machine

  • For e.g to fire up an existing Virtual Machine called hashicorp/precise64 just execute:
$ vagrant init hashicorp/precise64 (will create vagrantfile)
$ vagrant up

After running the above two commands, you will have a fully running virtual machine in VirtualBox running Ubuntu 12.04 LTS 64-bit.

You can SSH into this machine with vagrant ssh, and when you are done playing around, you can terminate the virtual machine with vagrant destroy.

Configure VM (with .vagrantfile)

There is one Vagrantfile per project, and the Vagrantfile is supposed to be committed to version control. This allows other developers involved in the project to check out the code, run vagrant up, and be on their way. Vagrantfiles are portable across every platform.

You can configure your Vagrant VM with a bunch of properties available under:

  • config.vm.*
  • config.ssh.*
  • config.winrm.*
  • config.vagrant.*

Provisioning

Up to this point, you can fire and configure your VM in under 2 mins. But you still have not installed any software in your virtual machine. You say to your boss, I can install those 50 things (Cassandra, Elasticsearch, Spark etc..) needed to develop/run my software–give me a week! And your boss responds, give me a break!

Vagrant gives you multiple options for provisioning (automate installation) your virtual machine—from simple shell scripts to more complex tools like Chef and Puppet. Vagrant Provisioning is very powerful, everything that is repeatable is meant to be automated and that's exactly what you get.

For example, installing Apache–create install-apache.sh and modify your vagrantfile:

apt-get update
apt-get install -y apache2
if ! [ -L /var/www ]; then
  rm -rf /var/www
  ln -fs /vagrant /var/www
fi

Vagrant.configure("2") do |config| config.vm.box = "hashicorp/precise64"config.vm.provision :shell, path: "install-apache.sh" end

Vagrant in a Nutshell

Vagrant allows you to create/extend and provision a new virtual machine so it's available to the masses.

Vagrant

Next, I want to extend this article with Docker (a lightweight container), the future of application delivery.

docker.png

I have covered the very basics of Vagrant. But, the point here is automate everything.  We are software developers and we should automate everything as much as possible. Thanks for reading!

Virtual Machine VirtualBox Virtualization Machine

Published at DZone with permission of Hardik Pandya, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Amazon Lightsail: Virtual Cloud Server
  • Trending Programming Language to Learn
  • How to Submit a Post to DZone
  • When Microservices Are a Bad Idea

Comments

Cloud Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo