Module tomcat
In: /etc/puppet/modules/tomcat/manifests/definitions/instance.pp
/etc/puppet/modules/tomcat/manifests/definitions/concatfilepart.pp
/etc/puppet/modules/tomcat/manifests/definitions/targz.pp
/etc/puppet/modules/tomcat/manifests/definitions/ulimit.pp
/etc/puppet/modules/tomcat/manifests/classes/tomcat6.pp
/etc/puppet/modules/tomcat/manifests/classes/admin.pp
/etc/puppet/modules/tomcat/manifests/init.pp

Defines

Classes and Modules

Class tomcat::admin
Class tomcat::tomcat
Class tomcat::tomcat6

Defines

concatfilepart( $manage => 'false', $content => 'false', $file, $ensure => 'present', $source => 'false' )

Definition: tomcat::concatfilepart

Helper concatenate contento to a file. Inspired by David Schmitt‘s concatenated_file.pp

Parameters:

  • ensure:: parameter to be passed to the file resource
  • file:: filename for the file
  • content:: the contet to be added to the file
  • source:: the source to be used as a starting point for the file
  • manage:: tue or flase to specify parameters for the file resource
instance( $setenv => [], $group => 'adm', $sample => 'undef', $http_port => '8080', $ajp_port => '8009', $java_home => '', $ajp_address => 'false', $ensure => 'present', $http_address => 'false', $server_port => '8005', $conf_mode => '', $owner => 'tomcat' )

Definition: tomcat::instance

This definition will create:

  • a CATALINA_BASE directory in /srv/tomcat/$name/, readable to tomcat, writeable to members of the admin group.
  • /srv/tomcat/$name/conf/{server,web}.xml which can be modified by members of the admin group.
  • a /srv/tomcat/$name/webapps/ directory where administrators can drop "*.war" files.
  • an init script /etc/init.d/tomcat-$name.
  • /srv/tomcat/$name/bin/setenv.sh, which is loaded by the init script.
  • /srv/tomcat/$name/bin/setenv-local.sh, which is loaded by the setenv.sh, and can be edited by members of the admin group.
  • rotation of /srv/tomcat/$name/logs/catalina.out.

Parameters:

  • name:: the name of the instance.
  • ensure:: defines if the state of the instance. Possible values:
    • present: tomcat instance will be running and enabled on boot. This is the default.
    • running: an alias to "ensure => present".
    • stopped: tomcat instance will be forced to stop, and disabled from boot, but the files won‘t be erased from the system.
    • installed: tomcat instance will be disabled from boot, and puppet won‘t care if it‘s running or not. Useful if tomcat is managed by heartbeat.
    • absent: tomcat instance will be stopped, disabled and completely removed from the system. Warning: /srv/tomcat/$name/ will be completely erased !
  • owner:: the owner of $CATALINA_BASE/{conf,webapps}. Defaults to "tomcat". Note that permissions will be different, as tomcat needs to read these directories in any case.
  • group:: the group which will be allowed to edit the instance‘s configuration files and deploy webapps. Defaults to "adm".
  • server_port:: tomcat‘s server port, defaults to 8005.
  • http_port:: tomcat‘s HTTP server port, defaults to 8080.
  • http_address:: define the IP address tomcat‘s HTTP server must listen on. Defaults to all addresses.
  • ajp_port:: tomcat‘s AJP port, defaults to 8009.
  • ajp_address:: define the IP address tomcat‘s AJP server must listen on. Defaults to all addresses.
  • conf_mode:: can be used to change the permissions on /srv/tomcat/$name/conf/, because some webapps require the ability to write their own config files. Defaults to 2570 (writeable only by $group members).
  • java_home:: can be used to define an alternate $JAVA_HOME, if you want the instance to use another JVM.
  • sample:: set to "true" and a basic "hello world" webapp will be deployed on the instance. You can test it by loading this URL: localhost:8080/sample (where 8080 is the port defined by the "http_port" parameter).
  • setenv:: optional array of environment variable definitions, which will be added to setenv.sh. It will still be possible to override these variables by editing setenv-local.sh.

Requires:

  • one of the tomcat classes which installs tomcat binaries.
  • java to be previously installed.
  • logrotate to be installed.

Example usage:

  include tomcat::package::v6
  include tomcat::administration

  tomcat::instance { "foo":
    ensure => present,
    group  => "tomcat-admin",
  }

  tomcat::instance { "bar":
    ensure      => present,
    server_port => 8006,
    http_port   => 8081,
    ajp_port    => 8010,
    sample      => true,
    setenv      => [
      'JAVA_XMX="1200m"',
      'ADD_JAVA_OPTS="-Xms128m"'
    ],
  }
targz( $target, $source )

Definition: tomcat::targz

Helper class that donwloads and extracts a tar.gz from the network.

Parameters:

  • source: url of the tar.gz to be downloadaed.
  • target: target directory where to extract the downloaded tar.gz.
ulimit( $value )

Definition: tomcat::ulimit

Helper definition which helps allocate more/less resources to the tomcat user, using PAM. See limits.conf(5) and pam_limits(8) for more details.

Parameters:

  • name: the name of the limit to change (instance name).
  • value: the value to set for this limit.

Example usage:

  include tomcat::package::v6

  tomcat::ulimit { "nofile": value => 16384 }

[Validate]