Quickly produce a Linux 64 bit Ubuntu 14.04 Desktop environment using Vagrant and Puppet – as starting point for Oracle installations


My objective in this article: create generally reusable Linux 64 bit (Ubuntu 14.0.4 with Desktop) Virtual Box Image – based on Vagrant and Puppet as to stamp out multiple copies of the image. The image should support Puppet and Git and must have a JDK installed.

I frequently want to try out new software. In many occasions this is software from Oracle, frequently still in beta. Usually this software runs best on Linux (even though my laptop still boots in Windows7). Besides. I want an isolated environment in which to run said software. An environment that I can easily create, start and also stop and remove.

In the past I have written a bit on both Vagrant – an open source product that allows us to script the creation of virtual machine images with Virtual Box (as well as Docker containers and AWS machine images) – and on Puppet – another open source project that supports configuring environments based on declarative descriptions of the desired end state. I have been introduced to both tools – that happen to work together very well – by Edwin Biemond (formerly of AMIS and currently of Oracle Corporation), who has done a ton of work and donated his findings to the community through his blog (http://biemond.blogspot.nl/) and his many GitHub contributions (https://github.com/biemond).

My objective as stated at the beginning of this article is actually not very demanding at all. Once you are somewhat versed in Vagrant and Puppet, this is almost the simplest thing to do. Yet it is a useful building block for me.

You will find the sources – Vagrant and Puppet scripts – in this GutHub repository: https://github.com/lucasjellema/vagrant-ubuntu1404-puppet-java. Note that the JDK7 module is copied from Edwin’s Puppet module: https://github.com/biemond/puppet/tree/master/modules/jdk7.


To get going, you need to first install Vagrant and Oracle Virtual Box, as discussed in many places including my article: https://technology.amis.nl/2014/07/29/fastest-way-to-a-virtual-machine-with-jdeveloper-12-1-3-and-oracle-database-xe-11gr2-on-ubuntu-linux-64-bit/.

Then clone the GitHub repository –  https://github.com/lucasjellema/vagrant-ubuntu1404-puppet-java – to your local machine or simply download the repository as zip-file and expand the file in a local directory. I am assuming a Windows Host, but the steps are almost the same for Linux, MacOS or other hosts.

You need to download a JDK installation file (for the target operation system which is Linux 64bit) to the files subdirectory. Go to http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html and download the jdk-###-linux-x64.tar.gz file and copy it to the files directory.



Also download UnlimitedJCEPolicyJDK7.zip from http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html and copy it to the files directory.



Looking at the Vagrant file for stamping out the Virtual Box machine

Open file vagrantfile to see what is defined inside:

Select Box image: ubuntu/trusty64 (that is available from the following URL  https://atlas.hashicorp.com/ubuntu/boxes/trusty64)


Ensure an Ubuntu.sh shell script is run on the image for configuring Puppet support in the client (again: this could be done in various ways). This script is inherited from Edwin who was inspired by  http://garylarizza.com/blog/2013/02/01/repeatable-puppet-development-with-vagrant/ and https://github.com/hashicorp/puppet-bootstrap/blob/master/ubuntu.sh)


Map relevant folders on the host to the VM (guest):


Note that the Vagrant file also contains definitions regarding the physical resources allocated to the Virtual Box VM (RAM memory , Video Memory, CPUs) as well as a name:


Use the Puppet Provisioner in Vagrant to run the Puppet manifest (plus modules) from within the guest – using the Puppet that was installed with the shell script:



Note: this section states that relative to the directory containing the vagrantfile, folder manifests contains the Puppet manifests to run – specifically the base.pp manifest – and directory modules contains the Puppet modules to be loaded and possibly included from the base.pp.

The directory structure for the Vagrant and Puppet resources looks like this:


Puppet declarations for the target environment

When you look inside the base.pp Puppet manifest, you will find the declarative configurations that describe the Virtual Machine to be provisioned. Vagrant takes care of the foundation – Ubuntu 14.04 64 bit. Puppet does the fine-tuning.

Here we see how Puppet is instructed to ensure that the Linux packages git, build-essential and ubuntu-desktop are installed (which boils down to: install them if they are not already installed). The group and user oracle are created, the password for the user is set (also to oracle).



The instruction include java::install activates the class java::install in package java in modules\java\manifests\init.pp. This class in its turn leverages the jdk7 module to install a specific Java 7 JDK. It is currently configured to install Java 7 U79 – which should correspond with the JDK tar file in the files directory (jdk-7u79-linux-x64.tar). If you want to install a different JDK version, you need to update this java::install class. Note: directly updating the class is not the correct way in Puppet. I should read settings – using the Hiera mechanism – from a YAML or JSON file. I have not yet gotten round to adding that for this module.


Generating the Virtual Machine

With the set up out of the way, we can start stamping out the clean Ubuntu 64 bit VM images with Desktop and Java set up, primed for action. We may want to do one final thing, especially if we are going to create multiple VM images – and that is define the title of the VM :


Then: open a command prompt in the directory that contains the vagrantfile.


and type: vagrant up.

This will fire off vagrant with the vagrantfile and have it do its thing.


At some point in the process, you will see Virtual Box being launched. This means the VM is running. Vagrant continues to install the Virtual Box Guest Additions – used for mapping folders and interaction between host and VM in other ways. Then, in the vagrant logging, you will see the output indicating the installation of Puppet into the VM image:


A little later, this Puppet instance is put to good use: to run the Puppet manifest that is available inside the Guest VM through the folder mapping to the host folder.



After several minutes – depending on what had to be downloaded to your local machine – Vagrant will complete its work (which was partially performed by Puppet working inside the VM).



Accessing the brand new VM

The new VM can be accessed through SSH from the command line, using the simple command:

vagrant ssh

This brings us into the VM as user vagrant. Have a look around.



And just to  be sure about the JDK installation:


Alternatively, we can access the desktop – using remote desktop tools or by simply going through the Virtual Box GUI.


Note that the VM is stopped using vagrant halt (with shutdown) or vagrant suspend (A suspend effectively saves the exact point-in-time state of the machine). To get going again, use vagrant resume (after a suspend) or vagrant up (after a halt). To get rid of the VM altogether, use vagrant destroy.(creating a new VM is easily enough now that we have the scripts for it).


When you change or extend the Puppet manifest and want to have it reapplied to the VM, you can use the command: vagrant provision –provision-with puppet to only reapply the (changed) puppet script. To learn more details about what is going on during Puppet provisioning driven from Vagrant, you can add this  line inside the config.vm.provision  entry for Puppet:

puppet.options =”–verbose –debug”


About Author

Lucas Jellema, active in IT (and with Oracle) since 1994. Oracle ACE Director and Oracle Developer Champion. Solution architect and developer on diverse areas including SQL, JavaScript, Docker, Machine Learning, Java, SOA and microservices, events in various shapes and forms and many other things. Author of the Oracle Press books: Oracle SOA Suite 11g Handbook and Oracle SOA Suite 12c Handbook. Frequent presenter on community events and conferences such as JavaOne, Oracle Code and Oracle OpenWorld.

1 Comment

  1. asdasdadasdasda on

    Very Very HARD to read the low resolution images of code! Have your tried reading them yourself?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.