Home

Awesome

Vagrant Logo

Vagrant lets you easily package an environment and share it with anyone. <br />

Key Benefits

Also ...

Will it work for me...?

YES! You can run vagrant on the most popular operating systems; <br /> Windows Mac Linux <br /> Microsoft Windows, Mac and Linux (most flavours).

<br />

Requirements

<br />

Up & Running in Three Easy Steps

1. Download & Install Vagrant + VirtualBox

First thing you need to do is install VirtualBox:

https://www.virtualbox.org/wiki/Downloads

(Vagrant uses a "headless" VirtualBox Virtual Machine (VM) - you don't need to know what that is or how it works just trust that it does its job really well, is well documented and extensively tested)

and Vagrant:

http://www.vagrantup.com/downloads.html

2. Clone this repository

git clone https://github.com/nelsonic/learn-vagrant.git && cd learn-vagrant

This means that you will now have the only file you need in your directory to get Vagrant up and running: the Vagrantfile. This file adds the configuration you need to the vagrant box.

The one in this repository updates Ubuntu, installs Node.js, updates it and prints out the version. There is also commented out code there that would have installed MongoDB and run some tests. If you're setting up your own configuration, copying this file would be a good place to start!

Windows users will also need a vagrantfile_ssh.txt file - in the windows-only directory of this repository.

3. Boot Ubuntu (installs latest Node.js)

Boot the Vagrant Box:

vagrant up

(this will install ubuntu and node.js so may take a few minutes - depending on your internet connection)

Anything you do within the directory you're currently in will now take place exclusively in your Vagrant environment.

Login and Explore

SSH (login) to the Vagrant Box:

vagrant ssh

to exit simply type exit in the terminal (this logs you out but Vagrant will still be running):

exit

Windows Only

Because windows does not come with an SSH client you will need to install one.

Todo

<br /><br />

Other useful commands

Shut down the Vagrant Box

vagrant halt

This will shut down while preserving the state of the machine, much like hitting the 'pause' button.

Need to Kill it?

vagrant destroy

This will stop the machine altogether and you will no longer be operating within Vagrant in the directory.

More Detailed Instructions

Create our base Ubuntu Box:

vagrant box add base https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box

This command will create a box called "base" and download the base install of ubuntu version 14.04 (latest)

you should see:

==> box: Adding box 'base' (v0) for provider:
    box: Downloading: https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box
==> box: Successfully added box 'base' (v0) for 'virtualbox'!

This will be useful if you want to install the box globally so that you don't have to download and install it through the Vagrantfile every time you run vagrant up. <br />

<br />

Useful Links

Which box should I start with?

I'm using: https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box

Install Node.js on Unbunt:

Tutorials

Background

Why do we even need Vagrant?

For better or worse, people still use different operating systems for their development machines. While many have made the switch to Mac or Ubuntu, most people are still developing on Windows. Using vagrant as a VM to run your production OS locally means you can keep everything consistent everywhere, regardless of your local OS.

How did we get here?

In the dark ages of development (pre 2012) people had to manually install all the dependencies for projects, often leading to version conflicts and incompatibilities. :cry:

Enter Vagrant to save the day!

Now you can keep a single file listing all the dependencies required to boot a fully-functional development machine using a single vagrant up command.

<br />

Minimal Overhead

CPU

Vagrant CPU Consumption

Memory

Vagrant Memory Consumption

<br /> <br />

Discussion

Docker vs. Vagrant

Next

Vagrant on Digital Ocean / AWS ?

Inspiration / Thanks

Special Thanks to Joaquim Serafim for encouraging me to learn/use Vagrant <br /> see: https://github.com/joaquimserafim/vagrant-nodejs-redis-mongodb