Saturday, November 16, 2013

Creating your own Virtualbox Development Images

For my Oracle Puppet provisioning development I can't do without these create image tools: Packer and Vagrant in combination with Oracle VirtualBox or VMware.  In this blogpost I will explain what these tools can do for you and how you can make your own images and use puppet as provisioning tool.

With Vagrant you can create your own virtual images and it can start puppet or chef to do all the server provisioning. Besides this, Vagrant can also manage all the network configuration or make a multi machine configuration. One of the great things of Vagrant is when you make a mistake you can start over by destroying the image ( vagrant destroy ) or start the provisioning again ( vagrant provision).

For Vagrant you need to download and import a small image box ( here is  an overview of the all public boxes which you can use right away )  like CentOS or Ubuntu. This image already contains the Virtualbox guest additions, which Vagrant will use to setup the shared folder etc.

Packer is a tool which can create this vagrant box for you. With this you can create a virtual image which also can be used for Amazon EC2, VirtualBox or VMware. In my case I need to have a particular image with the latest VBox guest additions and the latest Puppet RPM's. With packer I am now be able to create the same images as which my customer uses and test it on my own laptop.

How does this work?.  ( you can download a full working example at my Github page which will create a CentOS 6.4, 5.8 or Ubuntu images and this will also add Puppet )

First we need to define a json file and a Red Hat kickstart file.

here is an example of a CentOS 6.4 example.  This file contains the url of CentOS minimal or network iso, the Vagrant setup steps and post installation scripts, like the puppet install.

and the CentOS kickstart file

Next add the packer directory to your path variable , go to the packer github folder and use this command
packer build centos-6.4-x86_64.json

Wait some minutes and you will have a new box. Packer also shrinks this image to 600mb and is now ready to use it for Vagrant.

Next step is to download my vagrant github folder
When you go to this directory and use the vagrant up command, this will download the CentOS box, create a Virtualbox image and start the Puppet provisioning.

here is my example of a vagrant single node configuration, this will forward some ports and starts the Puppet site.pp class.

Here is an overview of my puppet folder

This is a shared folder ( virtual image and your machine ) and you can edit these Hiera and Puppet files in your fav editor, Add the needed puppet modules and start the provisioning again by using this command: vagrant provision or do it all over again by destroying it first: vagrant destroy -> vagrant up

Also vagrant supports multi machine configuration, just look at Vagrantfile_multinode.

Here is an working 3 node example, 3 VirtualBox Servers with a working WebLogic Cluster which uses a private network. 

Hope these will also help you.


  1. nice post - why do you do the puppet provisionning in vagrant ? will take a while each time you run vagrant up. can you move it to the packer provisionning ?

    1. Hi,

      First I don't think you need to do a lot of vagrant up actions and start the provisioning over again, just suspend it or destroy it only when you want a clean image,

      For me , this is a great feature, I do this a lot , so I can test my puppet development.

      Packer is different and this has a different use case , Just want a specific OS image with the latest puppet and do this in a very small vagrant box image.
      after this I will use this box to make a db or wls server.


  2. Hi,

    I am trying to create a virtual machine with your scripts to soa suite 12c, I tried to modify the scripts because I need to have installed the database and the server on a single virtual machine but I have not got me, You Might indicate some way to realize it.

    I hope your answer, thanks.