In order to consolidate my development environment a friend (thank you @bascht) mentioned veewee to me. Veewee automates and simplifys vagrant basebox creation. It comes with a plethora of templates for operating systems and versions. I use it to quickly build Ubuntu server on VirtualBox.
I started with a standard template (vagrant basebox define ‘appbox’ ‘ubuntu-12.10-server-amd64’) and customized the postinstall.sh. Including replacing the ruby install with rvm. This leads to problems when using chef which I don’t necessarily use so I can live with the inconvenience rather than with having to ruby setups.
I keep my own definitions for veewee in a separate directory to be able to version control it. Basebox creation itself is done by a little script. This setup requires git, and VirtualBox to be installed. I clone veewee parallel to the directory holding my definitions.
echo “nnBuilding dbesbox and exportingnn”
if [ ! -d $BASE/veewee/definitions ]; then
cp -r $BASE/my-devenv/appbox/ $BASE/veewee/definitions/appbox/
cp -r $BASE/my-devenv/databasebox/ $BASE/veewee/definitions/databasebox/
veewee vbox build ‘appbox’ —force
veewee vbox export ‘appbox’ —force
echo “nnDone building and exporting appboxnn”
mv $BASE/veewee/appbox.box $BASE/my-devenv/
veewee vbox build ‘databasebox’ —force
veewee vbox export ‘databasebox’ —force
echo “nnDone building and exporting databaseboxnn”
mv $BASE/veewee/databasebox.box $BASE/my-devenv/
veewee alias delete vagrant #Eradicate the “Gemfile could not be found” error
After building the two boxes I add them with
vagrant box add 'appbox' 'appbox.box'
and databasebox accordingly.
My Vagrantfile looks like this:
Vagrant::Config.run do |config|
config.vm.define :app do |app_config|
app_config.vm.box = "appbox"
app_config.vm.network :hostonly, "10.10.1.2" #10.10.1.1 is the host
app_config.vm.provision :shell, :path => "provisions/common_base.sh"
app_config.vm.provision :shell, :path => "provisions/app_base.sh"
config.vm.define :db do |db_config|
db_config.vm.box = “databasebox”
db_config.vm.network :hostonly, “10.10.1.3”
db_config.vm.provision :shell, :path => “provisions/common_base.sh”
db_config.vm.provision :shell, :path => “provisions/db_base.sh”
My provisioner is shell, but a »gem install chef« would enable you to use chef subsequently to provision. (Since rvm installation requires a closing and restarting of the shell or login/logout I found this to be more reliable.)
Now a simple ‘vagrant up’ starts both boxes and pointing the browser at 10.10.1.2 is answered by the nginx in appbox. My application is configured to use the db server at 10.10.1.3