Vagrant

A collection of commands for typical Vagrant use cases. Environment:

  • Vagrant 1.7.2
  • Ubuntu 14.04 as Base
  • Salt for provisioning

Creating and Using a Base Image with Salt Installed

First create a Vagrantfile

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|

    config.vm.box = "ubuntu/trusty64"
    # vagrant uses this name in its output
    config.vm.define "trusty64-salt"

    config.vm.provider "virtualbox" do |v|
      # the name in the Virtualbox GUI
      v.name = "trusty64-salt"
      v.memory = 2048
      v.cpus = 4
    end

    # installs salt
    config.vm.provision :salt do |salt|
      salt.run_highstate = false
    end

    # leave the official insecure key be - we want a base image
    # see http://docs.vagrantup.com/v2/boxes/base.html

    config.ssh.insert_key = false

end

Create it:

vagrant up

Package it:

vagrant package --base trusty64-salt

Add it locally:

vagrant box add package.box --name trusty64-salt

Use it in another Vagrantfile, e.g.:

config.vm.box = "trusty64-salt"