2012-11-19
based on vagrant 1.0.5, veewee 0.3.1 and VirtualBox 4.2
As I am always looking for tools to simplify my work and play and was looking for some virtualization helpers to easily manage virtual machines for development I thought I should pick vagrant from my to-do list and give it a try.
Since I looked at it for the first time quite some time has gone by and the project grew and matured as it seems and the user-base contains some large companies as it seems - which is nice IMHO.
Of course I could also stick with already packaged boxes but that would be too easy I guess. Furthermore I am likely to need custom boxes anyway further down the road. So I was looking for ways to build custom boxes too.
Quickly veewee showed up - which is a tool for generating vagrant boxes.
So here we go.
According to the vagrant docs and the veewee readme I will need some software installed on my (64bit debian squeeze) system for this to work.
Mind the prompts. #
stands for root and $
for a normal user.
~# cat > /etc/apt/sources.list.d/oracle-virtualbox.list << EOF
deb http://download.virtualbox.org/virtualbox/debian squeeze non-free
deb http://download.virtualbox.org/virtualbox/debian squeeze contrib
EOF
~# wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -
~# apt-get update
~# apt-get install dkms
~# apt-get install virtualbox-4.2
Note that eventually a relogin/reboot and/or adding a user to the virtualbox group will be needed to have correct permissions to actually use virtualbox.
Installing vagrant (using the appropriate download from vagrant downloads):
~# wget -c http://files.vagrantup.com/packages/be0bc66efc0c5919e92d8b79e973d9911f2a511f/vagrant_1.0.5_x86_64.deb
~# dpkg -i vagrant_1.0.5_x86_64.deb
~# echo 'export PATH=$PATH:/opt/vagrant/bin' >> /etc/profile.d/vagrant_path.sh
~# . /etc/profile.d/vagrant_path.sh
Maybe some other packages will be needed for installation...
And then veewee:
~# apt-get install libxslt1-dev libxml2-dev zlib1g-dev
~$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
~$ . ~/.bash_profile
~$ rvm install 1.9.2
~$ git clone https://github.com/jedi4ever/veewee.git
~$ cd veewee
~/veewee$ gem install bundler
~/veewee$ bundle install
Note that the RVM install will probably need some extra packages. So just read and follow the instructions when they come up.
Veewee comes with quite a few "templates" to choose from in order to build your vms. Take a look. I chose a debian image with reasonably low memory requirements for now.
~/veewee$ veewee vbox define 'debian-6-i386' 'Debian-6.0.6-i386-netboot'
~/veewee$ veewee vbox build 'debian-6-i386'
That took some time (~10 minutes) ... but now I got a virtual machine up and running based on the given veewee template.
Veewee tells me that I can login to the vm with:
~/veewee$ ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 7222 -l vagrant 127.0.0.1
vagrant@127.0.0.1's password: vagrant
Which works. Now I verify the build.
~/veewee$ veewee vbox validate 'debian-6-i386'
Which runs some cucumber tests which are all green here.
Now I only have to create a box file from this...
When veewee is active, vagrant provides an additional command named basebox
which actually does this. After that I can add it to vagrant, initialize and
start it.
~/veewee$ vagrant basebox export 'debian-6-i386'
~/veewee$ vagrant box add 'debian-6-i386' 'debian-6-i386.box'
~/veewee$ vagrant init 'debian-6-i386'
~/veewee$ vagrant up
Which takes a few minutes ...
... and hangs. Looking around revealed a known issue.
So I opened up the Vagrantfile in question and added config.ssh.timeout = 20
to the configuration directives. Running vagrant up
again resulted in a
properly started vm which I then can ssh into using
~/veewee$ vagrant ssh
Nice!
~/veewee$ vagrant down