Last Updated: February 25, 2016
· lordofthejars

Installing TomEE from Puppet

Apache TomEE is an all-Apache stack aimed at Java EE 6 Web Profile certification where Tomcat is top dog. It is the conjunction of Tomcat + Java EE. Apache TomEE

Puppet is a tool designed to manage the configuration of our systems declaratively. We only have to describe system resources and their state. This description is stored in the core-files of Puppet, which are called Puppet manifests. Puppet

We are going to see how to use Puppet to install TomEE.

# update the (outdated) package list
exec { "update-package-list":
  command => "/usr/bin/sudo /usr/bin/apt-get update",

class java_6 {

  package { "openjdk-6-jdk":
    ensure => installed,
    require => Exec["update-package-list"],


class tomee {

 file {"/opt/tomee-1.5.1":
    ensure => directory,
    recurse => true,
 } ->

 exec { "download-tomee" :
    command => "/usr/bin/wget -O /tmp/tomee-1.5.1.tar.gz",
    creates => "/tmp/tomee-1.5.1.tar.gz",
 } ->

 exec { "unpack-tomee" : 
    command => "/bin/tar -xzf /tmp/tomee-1.5.1.tar.gz -C /opt/tomee-1.5.1 --strip-components=1",
    creates => "/opt/tomee-1.5.1/bin",

 service { "tomee" :
    provider => "init",
    ensure => running,
    start => "/opt/tomee-1.5.1/bin/",
    stop => "/opt/tomee-1.5.1/bin/",
    status => "",
    restart => "",
    hasstatus => false,
    hasrestart => false,
    require => Exec["unpack-tomee"],


include java_6
include tomee

You can download script Here.

This manifest will ensure that you had a OpenJDK installed into your system, download TomEE from its site, install it in /opt/tomee-1.5.1 and finally start it each time you start your system.

Some final points:

  • In Puppet, creates attribute inside exec task, is used to know if the resource should be executed or not (case that the file exists, exec will not be executed). In our case we are downloading TomEE in tmp directory. Most OS removes periodically this directory so it is a bad location for downloading it, but for this tutorial it works perfectly because I could re-execute the script every time as a new execution.

  • For simplifications we have add all content inside a single file, in your enterprise I suggest creating a TomEE module so you could share across all your projects.

  • TomEE version should be set as a variable/parameter/hiera so same class can be reused when new version of TomEE is released.

Note: that this post assumes you have already installed Puppet. This script has been tested in an Ubuntu 12.04.

We keep learning,