Skip to content

Instantly share code, notes, and snippets.

@nvalentine-puppetlabs
Last active December 15, 2015 05:59
Show Gist options
  • Save nvalentine-puppetlabs/5213532 to your computer and use it in GitHub Desktop.
Save nvalentine-puppetlabs/5213532 to your computer and use it in GitHub Desktop.
Getting started with Vagrant

Getting Started with Vagrant

Installing

Installing vagrant itself can be a bit of a pain as it is a Ruby package and has most of the usual versioning problems therein. I recommend setting up your environment with the 'rbenv' package and then creating an rbenv environment with the latest vagrant. You probably want to run Vagrant with VirtualBox. At least for Ubuntu, I've had an easy enough time with Virtualbox from the Ubuntu repos.

rbenv

https://github.com/sstephenson/rbenv/

Installing vagrant

$ sudo apt-get install virtualbox

(assuming rbenv is already setup)

$ gem install vagrant

Boxes

Boxes are just OS images that are pre-built and can be imported into vagrant via the command line. The most popular site for pre-built boxes is:

http://www.vagrantbox.es/

Adding a box to the local cache

$ vagrant box install <your label> <URL to box>

Getting a list of the available boxes

$ vagrant box list

Init a VM

$ mkdir -p ~/workspace/vm && cd ~/workspace/vm && vagrant init

Preconfigure VM

$ vi Vagrantfile

Example Vagrant file

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant::Config.run do |config|
  config.vm.box = "ubuntu-12.04-amd64-server"

  config.vm.host_name = "myvm.example.org"

  config.vm.provision :puppet_server do |puppet|
    puppet.puppet_server = "puppet.example.org"
  end
end

Create, launch, and login to your new VM

$ vagrant up && vagrant ssh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment