# Vagrant

Related articles

- VirtualBox
- Libvirt
- KVM

Vagrant is a tool for managing and configuring virtualised development environments.

Vagrant has a concept of 'providers', which map to the virtualisation engine and its API. The most popular and well-supported provider is Virtualbox; plugins exist for `libvirt`, `kvm`, `lxc`, `vmware` and more.

Vagrant uses a mostly declarative `Vagrantfile` to define virtualised machines. A single Vagrantfile can define multiple machines.

See also Wikipedia:Vagrant.

## Installing Vagrant

Install vagrant from the official repositories.

## Plugins

Vagrant has a middleware architecture providing support for powerful plugins.

Some popular Vagrant plugins are available from the aur, such as vagrant-vbguest. Other plugins can be installed with Vagrant's built-in plugin manager:

    $ vagrant plugin install vagrant-vbguest

### vagrant-kvm

This plugin supports KVM as the virtualisation provider.

Vagrant installs a self-contained rainbow environment in /opt which interacts with the system ruby in Arch in confusing ways. As of vagrant 1.4.3, this invocation will install vagrant-kvm successfully:

    $ CONFIGURE_ARGS="with-libvirt-include=/usr/include/libvirt with-libvirt-lib=/usr/lib" vagrant plugin install vagrant-kvm

### vagrant-lxc

First install lxc from the official repositories, then:

    $ vagrant plugin install vagrant-lxc

Next, configure lxc and some systemd unit files per this comment. The plugin can now be used with a `Vagrantfile` like so:

    VAGRANTFILE_API_VERSION = "2"

    Vagrant.configure("2") do |config|

        config.vm.define "main" do |config|
            config.vm.box = 'http://bit.ly/vagrant-lxc-wheezy64-2013-10-23'

            config.vm.provider :lxc do |lxc|
                lxc.customize 'cgroup.memory.limit_in_bytes', '512M'
            end

            config.vm.provision :shell do |shell|
                shell.path = 'provision.sh'
            end
        end
    end

The `provision.sh` file should be a shell script beside the `Vagrantfile`. Do whatever setup is appropriate; for example, to remove puppet, which is packaged in the above box:

    rm /etc/apt/sources.list.d/puppetlabs.list
    apt-get purge -y puppet facter hiera puppet-common puppetlabs-release ruby-rgen

## Base Boxes for Vagrant

Here is a list of places to get all sorts of vagrant base boxes for different purposes: development, testing, or even production.

- An well maintained up-to-date Arch Linux x86_64 base box for Vagrant

- vagrantbox.es
  A List of vagrant base boxes. Initiated by Gareth Rushgrove @garethr hosted on Heroku using Nginx. See the story here: The Vagrantbox.es Story.

- Opscode bento
  We all know what bento means in Japanese, right? In this case, they are NOT lunch boxes BUT extremely useful base boxes which can be used to test cookbooks or private chef (Chef Server and Client). Distributions included: Ubuntu Server, Debian, CentOS, Fedora and FreeBSD.

- Puppet Labs Vagrant Boxes
  Pre-rolled vagrant boxes, ready for use. Made by the folks at Puppet Labs.

- Vagrant Ubuntu Cloud Images
  It has been there since Jan, 2013. For some reason Canonical has NOT officially promoted it yet, may be still in beta. Remember these are vanilla images, NOT very useful without Chef or Puppet.

Category:

- Virtualization