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://github.com/opscode-cookbooks/apt.git apt
git clone git://github.com/opscode-cookbooks/openssl.git openssl
git clone git://github.com/opscode-cookbooks/yum.git yum
git clone git://github.com/opscode-cookbooks/build-essential.git build-essential
git clone git://github.com/cookbooks/rubygems.git rubygems
git clone git://github.com/opscode-cookbooks/gems.git gems
git clone git://github.com/opscode-cookbooks/erlang.git erlang
git clone git://github.com/opscode-cookbooks/mysql.git mysqlcd mysql
it checkout 3.0.0
cd ..
git clone git://github.com/opscode-cookbooks/database.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!
VAGRANTFILE_API_VERSION = “2”Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = “precise64”
config.vm.box_url = “http://files.vagrantup.com/precise64.box”
config.vm.synced_folder “…/myrepo/”, “/vagrant_data”
config.vm.provider :virtualbox do |vb|
vb.customize [“modifyvm”, :id, “–memory”, “1024”]
end# http://gettingstartedwithdjango.com/questions/1/error-installing-chef/
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”
#http://stackoverflow.com/questions/15328369/error-executing-action-install-on-resource-chef-gemmysql-installing-ruby
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 = :debugchef.json = {
:mysql => {
:server_root_password => ‘root’,
:bind_address => ‘127.0.0.1’,
:server_root_password => ‘bla’,
:server_repl_password => ‘bla’,
:server_debian_password => ‘bla’}
}
end
end
- Create your virtual server by hitting the following commands
vagrant box add base http://files.vagrantup.com/precise64.box
vagrant up
vagrant ssh
Some issues encountered (Vagrant file contains links to solutions)
- Downgraded mysql to version 3.0.0
- Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/m/mysql-5.5/libmysqlclient18_5.5.24-0ubuntu0.12.04.1_amd64.deb  404  Not Found [IP: 91.189.92.190 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: 91.189.91.15 80]
Comment (1)