How to Define (Installation Of) TomEE as a resource of Puppet

Recommended by 0 users

Installation of TomEE from Puppet

With Puppet, the declarative configuration of systems can easily be managed. Our task is just to declare the available resources of the system, and then declare their state too. We then store the description in the Puppet’s core files. In this chapter, we will guide you on how to define TomEE as a resource of Puppet and this will mean that it will be automatically installed in all computers which are under the management of Puppet. Note that the TomEE was written in Java programming language, which means that JDK must be installed in your system for you to succeed in this chapter. To easily install the package into your system, just use the package manager.

We need to begin by creating a manifest file named “init.php” and then create an exec task which will update the package manager with the list of the available packages. This should have the following code:

# updating the (outdated) package list
exec { ‘update-package-list’:
command => ‘usrbinsudo usrbinapt-get update’,

A class should next be defined, and then tasked with the installation of the OpenJDK. In Puppet, a class means several resources put together, and then Puppet will view them as a single unit. This is shown below:

class java {
package { “openjdk-6-jdk”:
ensure => installed,
require => Exec[“update-package-list”],

The next step should involve installation of the TomEE. Right now, it is not available in your distribution package repository in a software format. This means that a different approach is needed to the one which is followed in OpenJDK. We want to visit the TomEE site, and then download the “tar.gz” file which we will extract into our installation directory. The code for doing this is given below:

class tom {
file {“/opt/tomee-1.5.1”:
ensure => directory,
recurse => true,
} ->
exec { “download-tomee” :
command => “/usr/bin/wget http://apache.rediris.es/openejb/openejb-4.5.1/apache-tomee-1.5.1-
webprofile.tar.gz -O
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”,

We have created a class named “tom” and then the directory in which the TomEE will be installed. The TomEE has been downloaded from the Apache site by use of the “wget” command, and the file is downloaded in a compressed format. We have then uncompressed the file in the directory which we have just created.

At this point, the Apache TomEE has already been installed into the computer, but to start and stop it, this is not done automatically. To make the TomEE available, we must execute the command “/opt/tomee-1.5.1/bin/startup.sh.” We can change this by use of the service resource. What it does is that an installed service is registered as a service. The next service resource should be defined in the TomEE class as follows:

service { “tomee” :
provider => “init”,
ensure => running,
start => “/opt/tomee-1.5.1/bin/startup.sh”,
stop => “/opt/tomee-1.5.1/bin/shutdown.sh”,
status => “”,
restart => “”,
hasstatus => false,
hasrestart => false,
require => [ Exec[“unpack-tomee”], Package[“openjdk-6-jdk”] ],

When it comes to a service resource, one must have the TomEE unpacked and the OpnJDK installed, and this is why we have two declarations in the required attribute. The Puppet will create attributes in the “exec” task, and this will determine if a task is to be executed or not.

Related Pages:

Sample Resume:

Interview Questions:

0 Responses on How to Define (Installation Of) TomEE as a resource of Puppet"

Leave a Message

Your email address will not be published. Required fields are marked *

Copy Rights Reserved © Mindmajix.com All rights reserved. Disclaimer.
Course Adviser

Fill your details, course adviser will reach you.