What is it

vagrant is a command line tool that allows you to create "Create and configure lightweight, reproducible, and portable development environments." these are reproducible and redeployable virtual machine. The most awesome feature of vagrant is the function to import other people's premade boxes through the online catalog from the company who made it but there are many different sites that can supply boxes that are premade:

Atlas is an online comunity of users who make boxes and update them often.

Features

  • Updateable boxes (meaning an author can push an update and it will be reflected on your box if supported)
  • Fast deployment
  • many providers (These are where the boxes are deployed such as: vmware and virtualbox each are an example of a provider)
  • Big community and company support
  • Has a sharing function over ssh or HTML allowing remote support even inside the box

How do I vagrant

  1. install vagrant (Cinst vagrant for chocolatey users as I covered in a previous post
    Link Here)
  2. make a clean directory and change to it in commandline
  3. Find a box that interests you or is suitable for you development environment
    Example http://files.vagrantup.com/precise64.box will give you a Ubuntu precise 64 bit virtual box machine
  4. execute the command vagrant box add {title} {url} where title is you can name it anything and url is the url of the box you want
  5. Wait patiently and make a coffee as the box download to give an example of machine size this ubuntu box is
    323MB
  6. vagrant will notify you that the box has been downloaded next we execute
    vagrant init {title} where title is anything yet again
  7. vagrant up and that's it your box will boot up in virtual box and will run like a normal machine
  8. the machine will most likely have a vagrant user with the password vagrant as this is how base boxes are made.

Commands

vagrant up - brings the machine up.
vagrant init - makes the directory a vagrant machine folder and sets up the starting files
vagrant ssh - ssh into the machine that has booted
vagrant halt - shutdown the machine gracefully at first then forces the machine down.
vagrant destroy - deletes all the vm files.
vagrant box - various commands to manipulate premade boxes

Base Boxes?

Base boxes are the way of making a user created box using vagrant the main steps for making a box are:

  • ssh server is installed with the insecure vagrant key so that vagrant can hook into it at boot time
  • adding vagrant to the sudoers file
  • and a vagrant user is present on the system usually with the password vagrant

refer to this page for box building CREATING A BASE BOX

then finally vagrant package --base "Vm Name"
the box will then export to a package.box file that could be a few GB's in size this is the entire vm compressed into one file.

To unpack and run it on another machine just execute
vagrant box add {title} {path to box file}
and follow the next steps in a standard box to install you build vm

I hope that this crash course in how this cutting edge system works and how to use it is useful.