Puppet Class: tomcat

Defined in:
modules/tomcat/manifests/init.pp

Summary

module to install and configure tomcat

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • hostname (Stdlib::Host) (defaults to: 'localhost')
  • user (String[1]) (defaults to: 'tomcat')
  • group (String[1]) (defaults to: 'tomcat')
  • app_base (String) (defaults to: 'webapps')
  • unpack_wars (Boolean) (defaults to: true)
  • auto_deploy (Boolean) (defaults to: true)
  • connector_port (Stdlib::Port) (defaults to: 8080)
  • connector_timeout (Integer) (defaults to: 20000)
  • config_basedir (Stdlib::Unixpath) (defaults to: '/etc/tomcat9')
  • versionlogger_listener (Boolean) (defaults to: true)
  • security_listener (Boolean) (defaults to: false)
  • apr_listener (Boolean) (defaults to: false)
  • apr_sslengine (Boolean) (defaults to: false)
  • apr_port (Stdlib::Port::User) (defaults to: 8443)
  • userdatabase_realm (Boolean) (defaults to: false)
  • userdatabase_file (String[1]) (defaults to: 'tomcat-users.xml')
  • logs_dir (String[1]) (defaults to: 'logs')
  • log_pattern (String[1]) (defaults to: 'combined')
  • default_session_timeout (Integer[1]) (defaults to: 30)
  • default_servlet_debug (Boolean) (defaults to: false)
  • default_servlet_listings (Boolean) (defaults to: false)
  • default_servlet_readonly (Boolean) (defaults to: true)
  • default_servlet_mappings (Array[String[1]]) (defaults to: ['/'])
  • jsp_servlet_fork (Boolean) (defaults to: false)
  • jsp_servlet_xpoweredby (Boolean) (defaults to: false)
  • jsp_servlet_mappings (Array[String[1]]) (defaults to: ['*.jsp', '*.jspx'])
  • welcome_files (Array[String[1]]) (defaults to: ['index.html', 'index.htm', 'index.jsp'])
  • shutdown_address (Stdlib::Host) (defaults to: 'localhost')
  • shutdown_string (String) (defaults to: 'SHUTDOWN')
  • public_key_path (Stdlib::Unixpath) (defaults to: '/etc/tomcat9/ssl/cert.pem')
  • private_key_path (Stdlib::Unixpath) (defaults to: '/etc/tomcat9/ssl/server.key')
  • java_opts (Hash[String[1], String[1]]) (defaults to: {'java.awt.headless' => 'true', 'log4j2.formatMsgNoLookups' => 'true'})
  • watched_resources (Array[String[1]]) (defaults to: ['WEB-INF/web.xml', 'WEB-INF/tomcat-web.xml', # lint:ignore:single_quote_string_with_variables '${catalina.base}/conf/web.xml'])
  • shutdown_port (Optional[Stdlib::Port]) (defaults to: undef)


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'modules/tomcat/manifests/init.pp', line 3

class tomcat (
    Stdlib::Host           $hostname                 = 'localhost',
    String[1]              $user                     = 'tomcat',
    String[1]              $group                    = 'tomcat',
    String                 $app_base                 = 'webapps',
    Boolean                $unpack_wars              = true,
    Boolean                $auto_deploy              = true,
    Stdlib::Port           $connector_port           = 8080,
    Integer                $connector_timeout        = 20000,
    Stdlib::Unixpath       $config_basedir           = '/etc/tomcat9',
    Boolean                $versionlogger_listener   = true,
    Boolean                $security_listener        = false,
    Boolean                $apr_listener             = false,
    Boolean                $apr_sslengine            = false,
    Stdlib::Port::User     $apr_port                 = 8443,
    Boolean                $userdatabase_realm       = false,
    String[1]              $userdatabase_file        = 'tomcat-users.xml',
    String[1]              $logs_dir                 = 'logs',
    String[1]              $log_pattern              = 'combined',
    Integer[1]             $default_session_timeout  = 30,
    Boolean                $default_servlet_debug    = false,
    Boolean                $default_servlet_listings = false,
    Boolean                $default_servlet_readonly = true,
    Array[String[1]]       $default_servlet_mappings = ['/'],
    Boolean                $jsp_servlet_fork         = false,
    Boolean                $jsp_servlet_xpoweredby   = false,
    Array[String[1]]       $jsp_servlet_mappings     = ['*.jsp', '*.jspx'],
    Array[String[1]]       $welcome_files            = ['index.html', 'index.htm', 'index.jsp'],
    Stdlib::Host           $shutdown_address         = 'localhost',
    String                 $shutdown_string          = 'SHUTDOWN',
    Stdlib::Unixpath       $public_key_path          = '/etc/tomcat9/ssl/cert.pem',
    Stdlib::Unixpath       $private_key_path         = '/etc/tomcat9/ssl/server.key',
    Hash[String[1], String[1]] $java_opts            = {'java.awt.headless'         => 'true',
                                                        'log4j2.formatMsgNoLookups' => 'true'},
    Array[String[1]]           $watched_resources    = ['WEB-INF/web.xml',
                                                        'WEB-INF/tomcat-web.xml',
    # lint:ignore:single_quote_string_with_variables
                                                        '${catalina.base}/conf/web.xml'],
    # lint:endignore
    Optional[Stdlib::Port]     $shutdown_port           = undef,
){

    if debian::codename::eq('bullseye') {
        ensure_packages(['tomcat9'])
    }

    if debian::codename::eq('bookworm') {
        apt::package_from_component { 'tomcat9-forwardport':
            component => 'component/tomcat9',
            packages  => ['libtomcat9-java', 'tomcat9', 'tomcat9-common'],
            priority  => 1002,
        }
    }

    if $apr_listener {
      ensure_packages(['libtcnative-1'])
    }

    $_java_opts  = $java_opts.reduce('') |$memo, $value| { "-D${value[0]}=${value[1]} ${memo}" }.strip

    file{
        default:
            ensure => file,
            owner  => 'root',
            mode   => '0640',
            group  => $group,
            notify => Service['tomcat9'];
        $config_basedir:
            ensure => directory;
        "${config_basedir}/server.xml":
            content => template('tomcat/server.xml.erb');
        "${config_basedir}/context.xml":
            content => template('tomcat/context.xml.erb');
        "${config_basedir}/web.xml":
            content => template('tomcat/web.xml.erb');
        '/etc/default/tomcat9':
            mode    => '0644',
            group   => 'root',
            content => "JAVA_OPTS=\"${_java_opts}\"\n";
    }
    service{'tomcat9':
        ensure => 'running',
        enable => true,
    }
}