Using Veewee
With @dancarley and @patrickebois just discussing the origin of the name of Veewee I figured I still had that piece of documentation I wrote up for myselve flying around ...
So with no other reason than having my docs mirrored on the internet .
gem install veewee
veewee templates
shows you what templates we have around ..
$veewee init natty ubuntu-11.04-server-amd64 Init a new box natty, starting from template ubuntu-11.04-server-amd64 The basebox 'natty' has been successfully created from the template ''ubuntu-11.04-server-amd64' You can now edit the definition files stored in definitions/natty or build the box with: vagrant basebox build 'natty'
As noted this will generate the definition for your natty box,
It will create a definition.rb file which describes your box.
A preseed (or kickstart or similar file) and a postinstall file
The next step is then to use vagrant to build this basebox
$ vagrant basebox build natty Verifying the isofile ubuntu-11.04-server-amd64.iso is ok. Creating vm natty : 384M - 1 CPU - Ubuntu_64 Creating new harddrive of size 10140 VBoxManage createhd --filename '/home/sdog/VirtualBox VMs/natty/natty.vdi' --size '10140' --format vdi > /dev/null Attaching disk: /home/sdog/VirtualBox VMs/natty/natty.vdi Mounting cdrom: /home/sdog/iso/ubuntu-11.04-server-amd64.iso Waiting for the machine to boot Typing:[1]: <Esc><Esc><Enter> Typing:[2]: /install/vmlinuz noapic preseed/url=http://192.168.10.101:7122/preseed.cfg Typing:[3]: debian-installer=en_US auto locale=en_US kbd-chooser/method=us Typing:[4]: hostname=natty Typing:[5]: fb=false debconf/frontend=noninteractive Typing:[6]: keyboard-configuration/layout=USA keyboard-configuration/variant=USA console-setup/ask_detect=false Typing:[7]: initrd=/install/initrd.gz -- <Enter> Done typing. Starting a webserver on port 7122 Serving file /home/sdog/definitions/natty/preseed.cfg Waiting for ssh login with user vagrant to sshd on port => 7222 to work .....................................................................................................................................................Transferring /tmp/vbox.version20110822-6766-1xcca1e-0 to .vbox_version .. Step [0] was successfully - saving state Waiting for ssh login with user vagrant to sshd on port => 7222 to work .Transferring /home/sdog/definitions/natty/postinstall.sh to postinstall.sh
Plenty more output here !
Be very patient .. you will see VirtualBox launch a VM and start installing it ..
The next steps are clear .. vagrant tells you what you can do next
Now you can: - verify your box by running : vagrant basebox validate natty - export your vm to a .box file by running : vagrant basebox export natty
So after validating it , you can now export the basebox and share it with other people.
The next step is to actually use that box in your own Vagrant setup, for that you need to import the box into your box collection
$ vagrant box add 'natty' 'natty.box' [vagrant] Downloading with Vagrant::Downloaders::File... [vagrant] Copying box to temporary location... [vagrant] Extracting box... [vagrant] Verifying box... [vagrant] Cleaning up downloaded box...
To verify just run
$ vagrant box list Centos6 MyCentOS2 debian natty
your freslhy imported box should be in the list .
You can now use
config.vm.box = "natty"
After that .. regular vagrant fun starts, up, provision, provision, provision, destroy, and so forth ..
Comments
#1 Joe J : Your blog
Your blog is really informative.
But my favorite thing is your title: "Everything is a Freaking DNS problem"
Haha. As a network admin I can attest to that!
#2 Kevin Cheney : I tried to build myself a
I tried to build myself a basebox using veewee. But I hadn't much luck with it. I always got we tried to create a box or a box was here before but now it's gone. I don't know ruby but I checked with the scripts and everything basically seemed right. But I figured out that the system calls are not executed. After hours of trying I remembered to have read something about replacing execute() calls by execute2() calls. I changed all occurrences in the
/opt/local/lib/ruby/gems/1.8/gems/veewee-0.1.29/lib/veewee/session.rb
from Veewee.Shell.execute()
to
Veewee.Shell.execute2()
and after that I could build a box. Well, I'm close. I still get an error while exporting the machine with
vagrant basebox export 'deb1' I get
...
Excuting vagrant voodoo:
vagrant package --base 'deb1' --output 'deb1.box'
To import it into vagrant type:
vagrant box add 'deb1' 'deb1.box'
To use it:
vagrant init 'deb1'
vagrant up
vagrant ssh
/opt/local/lib/ruby/gems/1.8/gems/virtualbox-0.8.6/lib/virtualbox/com/imple menter/ffi.rb:95:in `call_and_check': Error in API call to add_redirect: 2147942487 (VirtualBox::Exceptions::FFIException)
#3 Thomas : Nice writeup! You can also
Nice writeup!
You can also use the 'basebox' task with vagrant once veewee is installed.
So instead of 'veewee templates' you can use 'vagrant basebox templates'. In the same way you can replace 'veewee init natty ubuntu-11.04-server-amd64' with 'vagrant basebox define natty ubuntu-11.04-server-amd64'
I also noticed with the Veewee version I'm using (0.2.0) that the vagrant.pub file isn't installed correctly. I had to edit the postinstall.sh definition and replace the URL for vagrant.pub with https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub
For some odd reason the redirect on the original URL didn't work and an nginx redirect error was echo'd into the authorized_keys file (instead of the actual public key).