Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
vagrant [2016/01/08 01:46]
admin [Vagrant Box & Templates]
vagrant [2016/01/08 04:43] (current)
admin [Custom Vagrant Box Using Veewee]
Line 60: Line 60:
  
 > You can define really complex environments through a single configuration file, then share that with other people. The added bonus, is that your environments are self documenting,​ in that it is easy to read the configuration file and see what is going on. > You can define really complex environments through a single configuration file, then share that with other people. The added bonus, is that your environments are self documenting,​ in that it is easy to read the configuration file and see what is going on.
 +
 +
 +==== Custom Vagrant Box Using Veewee ====
 +
 +The following requires VirtualBox, Ruby, and Vagrant to be installed.
 +
 +=== Install Veewee ===
 +<​code>​
 +> sudo gem install veewee
 +</​code>​
 +
 +In case you get an error of type:
 +<​code>​
 +ERROR: ​ Error installing veewee:
 + ERROR: Failed to build gem native extension.
 +
 +    /​usr/​bin/​ruby2.1 extconf.rb
 +mkmf.rb can't find header files for ruby at /​usr/​lib/​ruby/​include/​ruby.h
 +
 +extconf failed, exit code 1
 +
 +Gem files will remain installed in /​var/​lib/​gems/​2.1.0/​gems/​posix-spawn-0.3.11 for inspection.
 +Results logged to /​var/​lib/​gems/​2.1.0/​extensions/​x86_64-linux/​2.1.0/​posix-spawn-0.3.11/​gem_make.out
 +</​code>​
 +
 +You need to install the ruby-dev library:
 +<​code>​
 +> sudo apt-get install ruby-dev
 +</​code>​
 +
 +=== List available Veewee templates ===
 +
 +To list available templates issue the following command:
 +<​code>​
 +> veewee vbox templates
 +> veewee vbox templates | grep -i debian
 +</​code>​
 +
 +=== Define a new basebox off and existing template ===
 +
 +We'd like to set up a **Debian 8.2** box, but there is only a **Debian-7.6.0-amd64-netboot** template available, let's start with this one:
 +<​code>​
 +> veewee vbox define '​debian-8.2-amd64'​ '​Debian-7.6.0-amd64-netboot'​ --workdir=/​home/​user/​Vagrant
 +</​code>​
 +
 +At this stage we have a //​**definitions**//​ directory that was created under //​**/​home/​user/​Vagrant**//​ (our workdir). Inside this directory is another one named //​**debian-8.2-amd64**//​ after our previous ''​%%veewee vbox define%%''​ command options. Inside this //​definitions//​ directory we'll look at two files:
 +
 +__//​**definition.rb**//​__
 +
 +Change the following lines:
 +
 +<​code>​
 +...
 +  :iso_file => "​debian-7.6.0-amd64-netinst.iso",​
 +  :iso_src => "​http://​mirror.i3d.net/​pub/​debian-cd/​7.6.0/​amd64/​iso-cd/​debian-7.6.0-amd64-netinst.iso",​
 +  :iso_md5 => "​8a3c2ad7fd7a9c4c7e9bcb5cae38c135",​
 +...
 +     '​console-keymaps-at/​keymap=us ',
 +     '​keyboard-configuration/​xkb-keymap=us ',
 +...
 +     '​kbd-chooser/​method=us ',
 +...
 +</​code>​
 +
 +To this:
 +<​code>​
 +...
 +  :iso_file => "​debian-8.2.0-amd64-netinst.iso",​
 +  :iso_src => "​http://​cdimage.debian.org/​debian-cd/​8.2.0/​amd64/​iso-cd/​debian-8.2.0-amd64-netinst.iso",​
 +  #:iso_md5 => "​8a3c2ad7fd7a9c4c7e9bcb5cae38c135",​
 +...
 +     '​console-keymaps-at/​keymap=fr ',
 +     '​keyboard-configuration/​xkb-keymap=fr ',
 +...
 +     '​kbd-chooser/​method=fr ',
 +...
 +</​code>​
 +
 +The **iso_md5** parameter is commented out as I couldn'​t figure out where to find this for Debian releases :-\
 +
 +__//​**preseed.cfg**//​__
 +
 +Change the following lines:
 +<​code>​
 +...
 +# Keyboard selection.
 +#d-i keymap select us
 +d-i keyboard-configuration/​xkb-keymap select us
 +...
 +d-i partman/​default_filesystem string ext3
 +...
 +# Individual additional packages to install
 +d-i pkgsel/​include string openssh-server ntp acpid  sudo bzip2 rsync
 +...
 +#d-i grub-installer/​bootdev ​ string (hd0,0)
 +...
 +</​code>​
 +
 +To this:
 +<​code>​
 +...
 +# Keyboard selection.
 +#d-i keymap select us
 +d-i keyboard-configuration/​xkb-keymap select fr
 +...
 +d-i partman/​default_filesystem string ext4
 +...
 +# Individual additional packages to install
 +d-i pkgsel/​include string openssh-server ntp acpid sudo bzip2 rsync ruby-dev
 +...
 +d-i grub-installer/​bootdev ​ string /dev/sda
 +...
 +</​code>​
 +
 +Adding ruby-dev is mandatory here as otherwise an error will be thrown when trying to install some gems.
 +
 +=== Local iso repository ===
 +
 +We can create an **iso** directory in our workdir where downloaded iso will be stored for future usage (avoiding recurrent downloads).
 +<​code>​
 +> mkdir /​home/​user/​Vagrant/​iso
 +</​code>​
 +
 +=== Build the box ===
 +
 +We can now tell Veewee to build our Debian 8.2.0 box:
 +<​code>​
 +> veewee vbox build '​debian-8.2-amd64'​
 +</​code>​
  
 ---- ----