Forge Home




18,657 latest version

1.9 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 2.6.0 (latest)
  • 2.5.0
  • 2.4.0
  • 2.3.1
  • 2.3.0
  • 2.2.0
  • 2.1.0
  • 2.0.2
  • 2.0.1
  • 2.0.0
  • 1.4.3
  • 1.4.2
  • 1.4.1
  • 1.4.0
  • 1.3.0
  • 1.2.0
  • 1.1.1
  • 1.1.0
  • 1.0.0
  • 0.3.3
  • 0.3.2
  • 0.3.1
  • 0.3.0
  • 0.2.0
  • 0.1.2
  • 0.1.1
  • 0.1.0
released Nov 5th 2013

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'llehmijo-tomcat7_rhel', '2.6.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add llehmijo-tomcat7_rhel
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install llehmijo-tomcat7_rhel --version 2.6.0

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.



llehmijo/tomcat7_rhel — version 2.6.0 Nov 5th 2013

Tomcat 7 on RHEL 6 [Build Status]



  • Deploy multiple Tomcat instances on same machine ("the base + home setup")
  • Use Tomcat Manager for deployment
  • Use JMX for monitoring the Tomcat instances
  • Use a ready-made smoke test script to test whether your web application is up and running


puppet module install llehmijo/tomcat7_rhel

Example usage

Configure Puppet

# In site.pp
node "superserver" {
  tomcat7_rhel::tomcat_application { "my-web-application":
    application_root => "/opt",
    tomcat_user => "webuser",
    tomcat_port => "8080",
    jvm_envs => "-server -Xmx1024m -Xms128m -XX:MaxPermSize=256m -Djava.rmi.server.hostname=some.ip.address",
    tomcat_manager => true,
    tomcat_admin_user => "superuser",
    tomcat_admin_password => "secretpassword",
    smoke_test_path => "/health-check",
    jmx_registry_port => 10054,
    jmx_server_port => 10053

  tomcat7_rhel::tomcat_application { "my-second-application":
    application_root => "/opt",
    tomcat_user => "webuser",
    tomcat_port => "8090",
    disable_access_log => true,
    jvm_envs => "-server -Xmx1024m -Xms128m -XX:MaxPermSize=256m -Djava.rmi.server.hostname=some.ip.address"

Custom configurations

Adding extra configuration into the <Engine> tag of server.xml

You can include additional configuration in the <Engine> tag of you server.xml by including a valid engine value in the server_xml_engine_config parameter of tomcat7_rhel::tomcat_application.

For example, you can enable Tomcat 7 session replication with the help of the server_xml_engine_config parameter. See the example below for more info.

Enabling session replication

Take a look at Tomcat 7 Clustering/Session Replication HOW-TO.

Enable default clustering by passing server_xml_engine_config into tomcat7_rhel::tomcat_application:

server_xml_engine_config => "<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>"

Full control over the clustering xml fragment can be done conveniently by using your own template:

server_xml_engine_config => template("mymodule/my_tomcat_cluster_config.erb")

Specifying allow/deny IPs for Tomcat Manager

Pass the params tomcat_manager_allow_ip and tomcat_manager_deny_ip to tomcat7_rhel::tomcat_application. It will write them into the manager.xml file.


Without Tomcat Manager

scp app.war webuser@superserver:~/app.war
ssh webuser@superserver "rm -rf /opt/my-web-application/webapps/*"
ssh webuser@superserver "cp ~/app.war /opt/my-web-application/webapps/ROOT.war"
ssh webuser@superserver "sudo service my-web-application restart"

With Tomcat Manager

scp app.war webuser@superserver:/tmp/app.war
ssh webuser@superserver "/opt/my-web-application/bin/ /tmp/app.war"

Note that if you deploy with Manager, make sure your application shuts down correctly when Tomcat calls the ServletContextListener#contextDestroyed method, otherwise you will eventually experience out-of-memory errors.

You can use the to find memory leaks. It's under the bin directory of your web application.

You can also use the parallel deployment feature of Tomcat (

scp app.war webuser@superserver:/tmp/app.war
ssh webuser@superserver "/opt/my-web-application/bin/ /tmp/app.war 1.2"

The above example starts a new version (1.2) of application in the same context path as the old one, without shutting down the old version, meaning that new sessions (and requests) will go to the new instance, while existing sessions stay in the old version of application. This results in zero downtime for your application.

You can list the running applications and their versions:

ssh webuser@superserver "/opt/my-web-application/bin/"

And undeploy an old version of the application:

ssh webuser@superserver "/opt/my-web-application/bin/ 1.1"

Run smoke test on the application

ssh webuser@superserver "/opt/my-web-application/bin/"

For Hiera users


I've added a class tomcat7_rhel::tomcat_instances, which allows users of hiera to assign defined types through this class wrapper using for example the following yaml (change to json for json users, obviously):

      application_root: /meltwater
      tomcat_user: www-data
      jvm_envs: "-server -Xmx128m -Xms128m -XX:MaxPermSize=256m"
      tomcat_manager: true
      tomcat_admin_user: superuser
      tomcat_admin_password: secretpassword
      tomcat_port: 8080
      tomcat_control_port: 9080



This project uses Semantic Versioning.


We test this project with

You can run the tests like this:

bundle install # Installs the Ruby gems that we use for testing

Creating a release

  1. Amend
  2. Update Modulefile
  3. puppet module build
  4. Upload to


This project in Puppet Forge:

A note about JPackage unstability

Sometimes the indices of the JPackage Project become corrupted. When that happens, this Puppet module will fail to install the Tomcat package.

For example, the indices might point to Tomcat 7.0.34, whereas the mirrors only contain the version 7.0.39.

Verifying that the indices do not work

  1. Open and find tomcat7
  2. Note the version of the tomcat7 RPM package
  3. Open and check if the tomcat7 entry in the filelists.xml points to a different version that what's available (refer to steps 1 and 2 here)
  4. If the versions do not match, this project does not work. Go do something else!
  5. If the versions match, please notify