Vagrant: reproducible development environments from a Vagrantfile

Vagrant 1.x (2012-2013) by Mitchell Hashimoto: wrapper over VirtualBox/VMware/AWS for virtualised development environments configured via a Vagrantfile, integrated provisioning with Puppet/Chef/Ansible. The seed of HashiCorp.

Open SourceWebR&D VagrantHashiCorpVirtualBoxDev EnvironmentRubyOpen Source

“It works on my machine”

A recurring operational problem in software development is ensuring the development environment is repeatable across team members and aligned with production. The historical frustration — “it works on my machine, I don’t see why it doesn’t run on yours” — arises from combinations of different compiler, library, network service, operating system versions.

Vagrant — created by Mitchell Hashimoto in 2010, released as 1.0 in March 2012 and actively developed toward 1.2 at time of writing — answers this problem with a simple idea: the dev environment is a reproducible virtual machine, described as code.

The architecture

A Vagrant project has a Vagrantfile in Ruby DSL at its root:

Vagrant.configure("2") do |config|
    config.vm.box = "ubuntu/precise64"
    config.vm.network :private_network, ip: "192.168.33.10"
    config.vm.synced_folder ".", "/vagrant"

    config.vm.provision :shell, path: "setup.sh"
    # or: config.vm.provision :puppet do |puppet| ...
end

With vagrant up from the command line, Vagrant:

  1. Downloads a base box (pre-packaged VM image) if not local
  2. Provisions a new VM with declared features (CPU, RAM, network, shared folders)
  3. Runs the provisioner — shell script, Puppet, Chef, Ansible, Salt — to configure it
  4. Makes the VM available via vagrant ssh, vagrant reload, vagrant halt, vagrant destroy

Providers and provisioners

Vagrant is deliberately abstract over the virtualisation backend:

  • Default provider: VirtualBox (Oracle, free and cross-platform)
  • Commercial providers: VMware Workstation/Fusion, Parallels
  • Cloud providers: AWS (plugin), DigitalOcean
  • Docker providers: later plugins

And agnostic over configuration management:

  • Shell — elementary scripting
  • Puppet — integrated
  • Chef — integrated
  • Ansible — supported (with SSH requirement)
  • Salt — supported
  • Inline scripts for rapid prototypes

This architectural neutrality makes Vagrant the glue between dev and ops: a team can use Puppet in production and Vagrant + Puppet in development, getting consistency.

Vagrant Cloud

In 2014 HashiCorp will launch Vagrant Cloud (today part of HashiCorp Cloud Platform) as public registry for boxes — the functional equivalent of DockerHub for Vagrant. As of 2013 distribution happens more artisanally (boxes hosted on public HTTP servers, referenced by URL).

Relationship with Docker

Docker debuts publicly in March 2013 — the same period as Vagrant’s growth. The two tools are not in direct competition at debut: Vagrant does VMs, Docker does containers. VM is heavier but more isolated; container is lighter but requires kernel compatibility with the host.

In early years Vagrant and Docker coexist happily — Vagrant can provision a VM that then runs Docker. Later, with increasing lightness of Docker Desktop and Docker Compose maturity, the “everything in containers” model will prevail for web dev environments; Vagrant will keep its niche where a full VM is needed (e.g. cross-platform projects testing BSD/Windows kernels, scenarios requiring privilege elevation, network infrastructure tests).

HashiCorp

Vagrant’s success lets Mitchell Hashimoto found HashiCorp in 2012 — a company that will become one of the most relevant in open source cloud infrastructure. After Vagrant come Packer (2013, image building), Serf (2013, service discovery), Consul (2014, service mesh), Terraform (2014, IaC), Vault (2015, secrets), Nomad (2015, orchestration).

The HashiCorp model is progressive open core: open source core, paid enterprise services and features. The model holds until 2023, when Terraform’s (and later other products’) shift to BSL will trigger community reaction and birth OpenTofu.

Adoption

As of 2013 Vagrant is already widely adopted in web development teams:

  • Digital agencies — aligning environments across different developers
  • Ruby/Rails community — ecosystem of origin
  • Python Django/Flask — environment setup
  • PHP WordPress/Drupal/Laravel — multi-version testing

In the Italian context

Vagrant spreads rapidly in Italy among agile software development teams, from startups to larger software houses, as a pragmatic answer to the “setup new machine” problem that previously required hours or days of manual installation.

What remains

Vagrant’s contribution is conceptual more than technical: it normalises the idea of dev environment as code, prefiguring what Docker Compose, VS Code devcontainers, Nix Shell will bring in more specialised forms. For many developers, Vagrant was the first contact with the idea that “the development environment is a versioned software artefact”.


References: Vagrant 1.x (2012-2013). Mitchell Hashimoto. HashiCorp (founded 2012). MIT licence. VirtualBox/VMware/AWS providers. Shell/Puppet/Chef/Ansible/Salt provisioners. Box registry (Vagrant Cloud, 2014).

Need support? Under attack? Service Status
Need support? Under attack? Service Status