- What is Veewee?
- Why Veewee?
- Supported VM Providers
- Getting Started
- Veewee Basics
- Customizing Definitions
- Veewee Fundamentals
- Veewee Definitions Examples
What is Veewee?
Veewee is a tool for easily (and repeatedly) building custom Vagrant base boxes, KVMs, and virtual machine images.
Vagrant is a great tool for creating and configuring lightweight, reproducible, portable virtual machine environments - often used with the addition of automation tools such as Chef or Puppet.
The first step to build a new virtual machine is to download an existing 'base box'. I believe this scares a lot of people as they don't know how these unverified boxes were built. Therefore a lot of people end up building their own base box which is often time consuming and cumbersome. Veewee aims to automate all the steps for building base boxes and to collect best practices in a transparent way.
Supported VM Providers
Veewee isn't only for Vagrant. It currently supports exporting VM images for the following providers
- VirtualBox - exports to OVA/OVF filetype
- VMware (Fusion) - exports to OVA filetype
- KVM - exports to IMG filetype
1. Virtualization Providers
2. Development Libraries
Veewee is written in Ruby. In order to use Veewee you need Ruby installed as well as some header files in order to compile native extensions that come as dependencies. If you already have experiences with Ruby this should be very straightforward.
On Linux, you may need these packages in order to build native rubygems:
- zlib1g-dev # or build-essential
For Mac OS X
On Macs, either install Xcode or use homebrew to install apple-gcc42 or build-essential.
3. Ruby Environment
Install as a gem
Projects that include the veewee gem can also benefit from utilizing Ruby version management (see below).
NOTE: The Veewee project is moving quickly and the Rubygem might be outdated. It is recommended that we install Veewee from source.
Install from source
In this case, use rbenv as Ruby Version Manager
Clone the veewee project from source
Set the local ruby version within the current directory
Run bundle install to install Gemfile dependencies for our selected ruby version
Veewee with bundle exec
Unless you've created an alias for veewee, always include the bundle exec prefix like this
Veewee without bundle exec
Create an alias for the veewee command so we don't have to type bundle exec any longer.
Add the alias alias veewee='bundle exec veewee' to your shell's default startup file (e.g. ~/.bash_profile)
For Ubuntu: Modify ~/.profile instead of ~/.bash_profile (it should NOT present anyway, otherwise ~/.profile will not be read by Bash).
For Zsh: Modify ~/.zshrc file instead of ~/.bash_profile.
Veewee as a Vagrant Plugin
Veewee can be used as a Vagrant plugin.
As a plugin, Veewee introduces the subcommand basebox on top of the vagrant command
This allows you to use the vagrant command style, which may feel more natural if you're already used to working with Vagrant. Please see Veewee's Vagrant doc for more details.
Overview of veewee commands
Veewee Provider Subcommands
Overview of veewee provider subcommands (vbox)
Template Naming Scheme
Each template folder name follows a naming scheme to help you choosing the right template
For example, the template for a Ubuntu 12.04 server (amd64) basebox looks like this
A common workflow to build a new base box with Veewee is:
- List all templates to find a single template to use
- Define a new box definition from a selected template
- Customize the definition (optional)
- Build a VM using standard ISOs, your own definition settings, and some postinstall scripts
- Validate the new VM
- Manually alter the VM by logging in with ssh (optional; but not recommended)
- Export the VM for distribution or to be used in Vagrant
If you'd like some help with a particular command
And if you're not sure how to use a subcommand, get help with
The subcommand help is often useful since it will list available optional flag arguments.
List Existing Definitions
To list all available definitions that you've previously created or copied
Create A Definition
A definition is created by cloning a template into the definitions/ folder.
To create a definition, use the define subcommand
If you want to use an external repository for the definition, you can specify a git URL
Modify a definition (optional)
You can tweak and customize every detail of the box by modifying and extending the (sane) default settings that come with a template. If you want to modify these settings take a look at the Customization instructions.
Remove a definition
If you change your mind and want to get rid of a definition simply call this subcommand
Or you can remove the folder under definitions
Manage ISO files
The distro ISOs (also called disk images) provide all files needed to install the OS. This file is essential for starting the installation process.
If you already have an .iso file for the desired distribution on your disk, put it inside the iso/ directory and make sure definition.rb is referencing the correct file.
If an expected ISO is not found in the iso/ directory, Veewee will ask you to download the ISO file from the web. Depending on your internet connection fetching an ISO file can take a while.
Build a new VM image
In order to build the defined box, execute this subcommand
The build subcommand can take the following optional flags
|--force||overwrites if already exists|
|--auto||automatically downloads the ISO without asking|
|--nogui||builds in the background rather than opening a VM GUI and building in the GUI window|
|--debug||enabled debug mode output|
|--redirectconsole||redirects console output|
|--postinstall-include=[...]||forces specified file(s) to get included in postinstall even if filename has a leading underscore|
|--postinstall-exclude=[...]||forces specified file(s) to get excluded from postinstall even if filename has no leading underscore|
The build subcommand will run the following routines behind the scenes
- Create a machine and disk according to the definition.rb Note: :os_type_id is the internal name Virtualbox uses for a given distribution
- Mount the ISO file :iso_file
- Boot up the machine and wait for :boot_time
- Send the keystrokes in :boot_cmd_sequence
- Start up a webserver on :kickstart_port to wait for a request from the :kickstart_file IMPORTANT: Do NOT navigate to the file in your browser or the server will stop and the installer will not be able to find your preseed
- Wait for ssh login to work with :ssh_user and :ssh_password
- sudo execute the :postinstall_files
Validate a build
After an OS has been installed on your VM image, you can verify that the machine is configured as intended with the validate subcommand. Veewee provides several tests to help you with that. The tests are located under the validation/ directory.
This subcommand executes all tests on a given machine
Validate will run some cucumber tests against the box to see if it has the necessary bits and pieces (e.g. for vagrant to work).
Export a build for distribution
The following subcommand take care of exporting
The exported filetype depends on the provider. For more details on the providers, please have a look at the Providers doc.
Learn by Example
Make a Oracle Linux 6.4 x86_64 base box compatible with VirtualBox.
Go find the OracleLinux-6.4-x86_64-DVD template
Then use the define command to create a new definition with a custom name. The following command copies the folder templates/OracleLinux-6.4-x86_64 to definitions/oracle-6.4-x86_64
IMPORTANT: You should avoid dots in the name because the box name gets used as the hostname also. Dots in the box name currently lead to invalid hostnames which causes several negative side effects (e.g. preventing the network devices to start).
Confirm that all expected files are in place
You can now inspect and optionally customize the defaults.
Next it's time to build the VM image with
Veewee now asks to download the distro ISO (unless --auto is provided) and will start creating the VM image. This process can take some time.
After the build completes, you can run the provided test suite on your new VM
Validation is highly recommended before requesting a fork pull on any modified templates.
Finally let's export the box so it can be distributed or used by Vagrant
Definitions are stored under the definitions/ directory relative to the current directory.
The file definition.rb contains all the parameters to define the machine to be build (see below)
- memory size
- number of CPUs
- user account and password
- sudo command
- shutdown command
- URL and checksum to download the ISO
When a new machine boots, it will typically fetch its initial configuration file over http from a kickstart file defined in kickstart_file. These files are usually named preseed.cfg or ks.cfg.
You can define multiple postinstall files by providing an array of filenames within definition.rb, like so
Once the initial installation is done, Veewee will execute each postinstall .sh file on the machine in chronologic order (order found in :postinstall_files array).
The main reason for splitting up the original postinstall.sh script into multiple files is to make the post-install steps as reusable and portable as possible for different virtualization systems and/or operating systems. For example, there is no need to install the Virtualbox Guest Additions on KVM or VMware Fusion.
A definition usually consists of at least these postinstall files
|preseed.cfg||Default options for the installer. See https://help.ubuntu.com/12.04/installation-guide/i386/preseed-using.html|
|definition.rb||Core definition of a box; like CPU, RAM, and the commands for the initial boot sequence|
|postinstall.sh||Steps that run after installing the OS|
Newer definitions contain of even more files (they have broken postinstall.sh into multiple files) to get a finer separation of concerns for the installation.
Using ERB in Files
Add .erb to your files in a definition and they will get parsed accordingly.
This is useful for generating kickstart, post-install at runtime.
The definition.rb file is the core definition file of each box. All crucial properties and postinstall scripts are defined here.
The boot_cmd_sequence parameter allows you to override the initial commands (like keyboard layout) that are fired up in the first boot sequence.
All other settings are used internally by Veewee, the virtualization provider, or simply for choosing the proper ISO
IMPORTANT: If you change values directly in a template, be sure to run bundle exec veewee <provider> undefine to remove the old definition and then bundle exec veewee <provider> define again to copy the updated template files into the definition.
If you are an experienced devops veteran and have enhanced template settings, please let us know why. We are very interested in improving Veewee's templates.
Each provider can take options that are specific the provider; more details will be available in each provider doc but let's have a quick overview here
This box will have pae and ioapic enabled with VirtualBox, and will use the brlxc0 bridge with KVM (on libvirt).
- Veewee Basics covers creating standard-issue boxes
- Customizing Definitions helps you fine tune each box definition to meet your exact needs
- Veeweefile can be used to define your own paths
Veewee Definitions Examples
Opscode bento and Puppet Labs Vagrant Boxes
- Opscode bento
- Puppet Labs Vagrant Boxes