Vagrantfile for an Erlang/MySql project using Chef

Vagrant is a great tool for getting a virtualized server up and running

The following is a cookbook and Vagrantfile for setting up a 64bit ubuntu box. I had a lot of workarounds to get an environment successfully set up, hopefully this will ease the pain

  • Install Vagrant and VirtualBox
  • Create cookbook folder for chef
  • Clone relevant recipes into mycookbook/myrecipes

git clone git:// apt
git clone git:// openssl
git clone git:// yum
git clone git:// build-essential
git clone git:// rubygems
git clone git:// gems
git clone git:// erlang
git clone git:// mysql

cd mysql

it checkout 3.0.0

cd ..
git clone git:// database

  • Edit mycookbooks/erlang/recipes/default.rb to specify version/type/checksum of erlang install
  • Edit mycookbooks/database/recipes/default.rb  to specify databases/users/data to seed
  • Add Vagrantfile to repo

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

# We’ll mount the Chef::Config[:file_cache_path] so it persists between
# Vagrant VMs
host_cache_path = File.expand_path(“../.cache”, __FILE__)
guest_cache_path = “/tmp/vagrant-cache”

# ensure the cache path exists
FileUtils.mkdir(host_cache_path) unless File.exist?(host_cache_path)

# Vagrantfile API/syntax version. Don’t touch unless you know what you’re doing!

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| = “precise64″

config.vm.box_url = “”

config.vm.synced_folder “…/myrepo/”, “/vagrant_data”

config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "1024"]

config.vm.provision :shell, :inline => “sudo aptitude -y install build-essential”

config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = “../../tm_recipes/cookbooks”
# stuff that should be in base box
chef.add_recipe “build-essential”
chef.add_recipe “openssl”
chef.add_recipe “yum”
chef.add_recipe “apt”
chef.add_recipe “rubygems”
chef.add_recipe “gems”
# note: mysql version 3.0.0, due to bug
chef.add_recipe “mysql::ruby”
chef.add_recipe “mysql::server”
chef.add_recipe “database”

#leave erlang until last, it’s a big file

chef.add_recipe “erlang”
chef.log_level = :debug

chef.json = {
:mysql => {
:server_root_password => ‘root’,
:bind_address => ’′,
:server_root_password => ‘bla’,
:server_repl_password => ‘bla’,
:server_debian_password => ‘bla’


  • Create your virtual server by hitting the following commands

vagrant box add base

vagrant up

vagrant ssh


Some issues encountered (Vagrant file contains links to solutions)

  • Downgraded mysql to version 3.0.0
  • Failed to fetch  404  Not Found [IP: 80]
  • Erlang E: Unable to fetch some archives, maybe run apt-get update or try with –fix-missing?
  • (mysql::client line 57) had an error: Chef::Exceptions::Exec: apt-get
  • 404 Not Found [IP: 80]


Comment (1)

  1. monster beats wrote::

    This is a really good read for me, thank you!

    Friday, October 18, 2013 at 12:40 am #