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 .

  1. gem install veewee

  1. veewee templates

shows you what templates we have around ..

  1. $veewee init natty ubuntu-11.04-server-amd64
  2. Init a new box natty, starting from template ubuntu-11.04-server-amd64
  3. The basebox 'natty' has been successfully created from the template ''ubuntu-11.04-server-amd64'
  4. You can now edit the definition files stored in definitions/natty
  5. or build the box with:
  6. 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

  1. $ vagrant basebox build natty
  2.  
  3. Verifying the isofile ubuntu-11.04-server-amd64.iso is ok.
  4. Creating vm natty : 384M - 1 CPU - Ubuntu_64
  5. Creating new harddrive of size 10140
  6. VBoxManage createhd --filename '/home/sdog/VirtualBox VMs/natty/natty.vdi' --size '10140' --format vdi > /dev/null
  7. Attaching disk: /home/sdog/VirtualBox VMs/natty/natty.vdi
  8. Mounting cdrom: /home/sdog/iso/ubuntu-11.04-server-amd64.iso
  9. Waiting for the machine to boot
  10.  
  11. Typing:[1]: <Esc><Esc><Enter>
  12. Typing:[2]: /install/vmlinuz noapic preseed/url=http://192.168.10.101:7122/preseed.cfg
  13. Typing:[3]: debian-installer=en_US auto locale=en_US kbd-chooser/method=us
  14. Typing:[4]: hostname=natty
  15. Typing:[5]: fb=false debconf/frontend=noninteractive
  16. Typing:[6]: keyboard-configuration/layout=USA keyboard-configuration/variant=USA console-setup/ask_detect=false
  17. Typing:[7]: initrd=/install/initrd.gz -- <Enter>
  18. Done typing.
  19.  
  20. Starting a webserver on port 7122
  21. Serving file /home/sdog/definitions/natty/preseed.cfg
  22.  
  23. Waiting for ssh login with user vagrant to sshd on port => 7222 to work
  24. .....................................................................................................................................................Transferring /tmp/vbox.version20110822-6766-1xcca1e-0 to .vbox_version
  25. ..
  26.  
  27.  
  28. Step [0] was successfully - saving state
  29.  
  30. Waiting for ssh login with user vagrant to sshd on port => 7222 to work
  31. .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

  1. Now you can:
  2. - verify your box by running : vagrant basebox validate natty
  3. - 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

  1. $ vagrant box add 'natty' 'natty.box'
  2. [vagrant] Downloading with Vagrant::Downloaders::File...
  3. [vagrant] Copying box to temporary location...
  4. [vagrant] Extracting box...
  5. [vagrant] Verifying box...
  6. [vagrant] Cleaning up downloaded box...

To verify just run

  1. $ vagrant box list
  2. Centos6
  3. MyCentOS2
  4. debian
  5. natty

your freslhy imported box should be in the list .

You can now use

  1. config.vm.box = "natty"
to refer to the fresly imported box in your Vagrant file, a file that can be created by running vagrant init, or copying around another Vagrant template ..

After that .. regular vagrant fun starts, up, provision, provision, provision, destroy, and so forth ..

Comments

Joe J's picture

#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!


Kevin Cheney's picture

#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)


Thomas's picture

#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).