Forge Home

tomcat

Puppet Tomcat Module

61,657 downloads

1,962 latest version

4.6 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

  • 1.3.1 (latest)
  • 1.3.0
  • 1.2.3
  • 1.2.2
  • 1.2.1
  • 1.2.0
  • 1.1.0
  • 1.0.0
  • 0.17.1
  • 0.17.0
  • 0.16.5
  • 0.16.3
  • 0.16.2
  • 0.16.1
  • 0.15.0
  • 0.14.2
  • 0.14.1
  • 0.14.0
  • 0.13.9
  • 0.13.8
  • 0.13.6
  • 0.13.5
  • 0.13.4
  • 0.13.3
  • 0.13.2
  • 0.13.1
  • 0.13.0
  • 0.12.0
  • 0.11.2
  • 0.11.0
  • 0.10.5
  • 0.10.4
  • 0.10.3
  • 0.10.1
  • 0.10.0
  • 0.9.0
  • 0.8.10
  • 0.8.9
  • 0.8.8
  • 0.8.7
  • 0.8.6
  • 0.8.4
  • 0.8.3
  • 0.8.2
  • 0.8.1
  • 0.8.0
  • 0.7.4
  • 0.7.3
  • 0.7.2
  • 0.7.1
  • 0.7.0
  • 0.6.2
  • 0.6.1
  • 0.6.0
  • 0.5.0
  • 0.0.4
  • 0.0.3
  • 0.0.2
  • 0.0.1 (deleted)
released Sep 14th 2020
This version is compatible with:
  • , ,

Start using this module

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

Add this module to your Puppetfile:

mod 'camptocamp-tomcat', '1.3.1'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add camptocamp-tomcat
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install camptocamp-tomcat --version 1.3.1

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.

Download

Documentation

camptocamp/tomcat — version 1.3.1 Sep 14th 2020

Tomcat Puppet module

Puppet Forge Version Puppet Forge Downloads Build Status Gemnasium By Camptocamp

Manages Tomcat configuration.

This module is provided by Camptocamp.

This module will install tomcat, either using you system's package manager or from a compressed archive available on one of the tomcat-mirrors.

This is done by including the tomcat class for a package based setup or declaring the class with the parameter sources => true for a source based setup.

Instances

You'll then be able to define one or more tomcat instances, where you can drop your webapps in the ".war" format. This is done with the tomcat::instance definition.

The idea is to have several independent tomcats running on the same host, each of which can be restarted and managed independently. If one of them happens to crash, it won't affect the other instances. The drawback is that each tomcat instance starts it's own JVM, which consumes memory.

This is implemented by having a shared $CATALINA_HOME, and each instance having it's own $CATALINA_BASE. More details are found in this document: http://tomcat.apache.org/tomcat-6.0-doc/RUNNING.txt

Logging

To offer more flexibility and avoid having to restart tomcat each time catalina.out is rotated, tomcat is configured to send it's log messages to log4j. By default log4j is configured to send all log messages from all instances to /var/log/tomcat/tomcat.log.

This can easily be overridden on an instance base by creating a custom log4j.properties file and setting the common.loader path to point to it, by editing /srv/tomcat/<name>/conf/catalina.properties.

Defaults

By default a new tomcat instance create by a tomcat::instance resource will listen on the following ports:

  • 8080 HTTP
  • 8005 Control
  • 8009 AJP

You should override these defaults by setting attributes server_port, http_port and ajp_port.

Limitations

  • there is no way to automatically manage webapps (\*.war files).
  • the initscript calls catalina.sh instead of using jsvc. This prevents tomcat from listening on ports < 1024.

Examples

Simple standalone instance:

Create a standalone tomcat instance whose HTTP server listen on port 8080:

Exec {
  path => '/usr/bin:/usr/sbin/:/bin:/sbin:/usr/local/bin:/usr/local/sbin',
}

include tomcat

tomcat::instance {'myapp':
  ensure    => present,
  http_port => '8080',
}

If you want to install a specific tomcat version from a specific mirror:

class { 'tomcat':
  version     => 6,
  sources     => true,
  sources_src => 'http://archive.apache.org/dist/tomcat/',
}

Apache integration

Pre-requisites:

include apache_c2c

apache_c2c::module {'proxy_ajp':
  ensure  => present,
}

apache_c2c::vhost {'www.mycompany.com':
  ensure => present,
}

Create a tomcat instance which is accessible via Apache using AJP on a given virtualhost:

include tomcat

tomcat::instance {'myapp':
  ensure      => present,
  ajp_port    => '8000'
}

apache_c2c::proxypass {'myapp':
  ensure   => present,
  location => '/myapp',
  vhost    => 'www.mycompany.com',
  url      => 'ajp://localhost:8000',
}

Multiple instances

If you create multiple Tomcat instances, you must avoid port clash by setting distinct ports for each instance:

include tomcat

tomcat::instance {'tomcat1':
  ensure      => present,
  server_port => '8005',
  http_port   => '8080',
  ajp_port    => '8009',
}

tomcat::instance {'tomcat2':
  ensure      => present,
  server_port => '8006',
  http_port   => '8081',
  ajp_port    => '8010',
}

Create a tomcat instance with custom connectors

First you have to declare you connectors then they are added to the tomcat-instance:

include tomcat

tomcat::connector{'http-8080':
  ensure   => present,
  instance => 'tomcat1',
  protocol => 'HTTP/1.1',
  port     => 8080,
  manage   => true,
}

tomcat::connector{'ajp-8081':
  ensure   => present
  instance => 'tomcat1'
  protocol => 'AJP/1.3',
  port     => 8081,
  manage   => true,
}

tomcat::instance {'tomcat1':
  ensure    => present,
  group     => 'tomcat-admin',
  manage    => true,
  connector => ['http-8080','ajp-8081'],
}