PuppetLabs Tomcat module
Clone or download
pmcmaw Merge pull request #325 from puppetlabs/release
Release merge back 2.4.0
Latest commit c62780f Oct 4, 2018
Permalink
Failed to load latest commit information.
examples fix lint warnings Sep 1, 2017
locales (maint) modulesync 892c4cf Sep 18, 2017
manifests last of the manifests Jul 15, 2018
readmes Updating translations for readmes/README_ja_JP.md Jan 17, 2018
spec (maint) - Removing manual installation of augeas_core Oct 3, 2018
templates adding wait_timeout var for init Jun 25, 2018
.fixtures.yml (MODULES-7847) augeas_core added as a fixture to fix Puppet 6 Unit tests Sep 25, 2018
.geppetto-rc.json Update for using Geppetto plugin in CI Dec 2, 2014
.gitattributes [MODULES-4528] Replace Puppet.version.to_f version comparison from sp… Mar 22, 2017
.gitignore pdksync_1.7.0-0-g57412ed Aug 22, 2018
.pdkignore pdksync_1.7.0-0-g57412ed Aug 22, 2018
.project (MODULES-4098) Sync the rest of the files Jan 20, 2017
.rspec (FM-4049) Update to current msync configs [2c99161] Jan 27, 2016
.rubocop.yml (FM-7392) - Puppet 6 Testing Changes Sep 24, 2018
.rubocop_todo.yml (maint) - modulesync 384f4c1 Dec 13, 2017
.sync.yml (FM-7399) - Prepare for changelog generator Sep 20, 2018
.travis.yml (FM-7392) - Puppet 6 Testing Changes Sep 24, 2018
.yardopts pdksync_heads/master-0-g34e3266 May 18, 2018
CHANGELOG.md (MODULES-8028) - Release Prep 2.4.0 Oct 3, 2018
CONTRIBUTING.md (maint) modulesync 892c4cf Sep 18, 2017
Gemfile (FM-7392) - Puppet 6 Testing Changes Sep 24, 2018
HISTORY.md Escape underscore to avoid unnecessary formatting Sep 20, 2018
LICENSE (FM-4046) Update to current msync configs [006831f] Feb 16, 2016
MAINTAINERS.md (MODULES-4098) Sync the rest of the files Jan 20, 2017
NOTICE (maint) modulesync 65530a4 Update Travis Jan 3, 2018
README.md Merge pull request #304 from eputnam/strings Aug 14, 2018
REFERENCE.md (maint) Remove reference from README and add REFERENCE.md Jul 15, 2018
Rakefile pdksync_1.7.0-0-g57412ed Aug 22, 2018
metadata.json (MODULES-8028) - Release Prep 2.4.0 Oct 3, 2018

README.md

tomcat

Table of Contents

  1. Overview
  2. Module Description - What the module does and why it is useful
  3. Setup - The basics of getting started with tomcat
  4. Usage - Configuration options and additional functionality
  5. Reference - An under-the-hood peek at what the module is doing and how
  6. Limitations - OS compatibility, etc.
  7. Development - Guide for contributing to the module

Overview

The tomcat module lets you use Puppet to install, deploy, and configure Tomcat web services.

Module Description

Tomcat is a Java web service provider. The tomcat module lets you use Puppet to install Tomcat, manage its configuration file, and deploy web apps to it. It supports multiple instances of Tomcat spanning multiple versions.

Setup

Requirements

The tomcat module requires puppetlabs-stdlib version 4.0 or newer. On Puppet Enterprise you must meet this requirement before installing the module. To update stdlib, run:

puppet module upgrade puppetlabs-stdlib

Beginning with tomcat

The simplest way to get Tomcat up and running with the tomcat module is to install the Tomcat source and start the service:

tomcat::install { '/opt/tomcat':
  source_url => 'https://www-us.apache.org/dist/tomcat/tomcat-7/v7.0.x/bin/apache-tomcat-7.0.x.tar.gz',
}
tomcat::instance { 'default':
  catalina_home => '/opt/tomcat',
}

Note: look up the correct version you want to install on the version list.

Usage

I want to run multiple instances of multiple versions of Tomcat

class { 'java': }

tomcat::install { '/opt/tomcat9':
  source_url => 'https://www.apache.org/dist/tomcat/tomcat-9/v9.0.x/bin/apache-tomcat-9.0.x.tar.gz'
}
tomcat::instance { 'tomcat9-first':
  catalina_home => '/opt/tomcat9',
  catalina_base => '/opt/tomcat9/first',
}
tomcat::instance { 'tomcat9-second':
  catalina_home => '/opt/tomcat9',
  catalina_base => '/opt/tomcat9/second',
}
# Change the default port of the second instance server and HTTP connector
tomcat::config::server { 'tomcat9-second':
  catalina_base => '/opt/tomcat9/second',
  port          => '8006',
}
tomcat::config::server::connector { 'tomcat9-second-http':
  catalina_base         => '/opt/tomcat9/second',
  port                  => '8081',
  protocol              => 'HTTP/1.1',
  additional_attributes => {
    'redirectPort' => '8443'
  },
}

tomcat::install { '/opt/tomcat7':
  source_url => 'http://www-eu.apache.org/dist/tomcat/tomcat-7/v7.0.x/bin/apache-tomcat-7.0.x.tar.gz',
}
tomcat::instance { 'tomcat7':
  catalina_home => '/opt/tomcat7',
}
# Change tomcat 7's server and HTTP/AJP connectors
tomcat::config::server { 'tomcat7':
  catalina_base => '/opt/tomcat7',
  port          => '8105',
}
tomcat::config::server::connector { 'tomcat7-http':
  catalina_base         => '/opt/tomcat7',
  port                  => '8180',
  protocol              => 'HTTP/1.1',
  additional_attributes => {
    'redirectPort' => '8543'
  },
}
tomcat::config::server::connector { 'tomcat7-ajp':
  catalina_base         => '/opt/tomcat7',
  port                  => '8109',
  protocol              => 'AJP/1.3',
  additional_attributes => {
    'redirectPort' => '8543'
  },
}

Note: look up the correct version you want to install on the version list.

I want to configure SSL and specify which protocols and ciphers to use

  file { $keystore_path: 
    ensure => present,
    source => $keystore_source,
    owner => $keystore_user,
    mode => '0400',
    checksum => 'md5',
    checksum_value => $keystore_checksum,
  } ->

  tomcat::config::server::connector { "${tomcat_instance}-https":
    catalina_base         => $catalina_base,
    port                  => $https_port,
    protocol              => $http_version,
    purge_connectors      => true,
    additional_attributes => {
      'SSLEnabled'          => bool2str($https_enabled),
      'maxThreads'          => $https_connector_max_threads,
      'scheme'              => $https_connector_scheme,
      'secure'              => bool2str($https_connector_secure),
      'clientAuth'          => bool2str($https_connector_client_auth),
      'sslProtocol'         => $https_connector_ssl_protocol,
      'sslEnabledProtocols' => join($https_connector_ssl_protocols_enabled, ","),
      'ciphers'             => join($ciphers_enabled, ","),
      
      'keystorePass'        => $keystore_pass.unwrap,
      'keystoreFile'        => $keystore_path,
    },
  }

See also: SSL/TLS Configuration HOW-TO

I want to deploy WAR files

Add the following to any existing installation with your own war source:

tomcat::war { 'sample.war':
  catalina_base => '/opt/tomcat9/first',
  war_source    => '/opt/tomcat9/webapps/docs/appdev/sample/sample.war',
}

The name of the WAR file must end with .war.

The war_source can be a local path or a puppet:///, http://, or ftp:// URL.

I want to remove some configuration

Different configuration defined types will allow an ensure parameter to be passed, though the name may vary based on the defined type.

To remove a connector, for instance, the following configuration ensure that it is absent:

tomcat::config::server::connector { 'tomcat9-jsvc':
  connector_ensure => 'absent',
  catalina_base    => '/opt/tomcat9/first',
  port             => '8080',
  protocol         => 'HTTP/1.1',
}

I want to manage a Connector or Realm that already exists

Describe the Realm or HTTP Connector element using tomcat::config::server::realm or tomcat::config::server::connector, and set purge_realms or purge_connectors to true.

tomcat::config::server::realm { 'org.apache.catalina.realm.LockOutRealm':
  realm_ensure => 'present',
  purge_realms => true,
}

Puppet removes any existing Connectors or Realms and leaves only the ones you've specified.

Reference

See [REFERENCE.md] for all Reference information.

Limitations

For an extensive list of supported operating systems, see metadata.json

The tomcat::config::server* defined types require Augeas version 1.0.0 or newer.

Multiple Instances

Some Tomcat packages do not let you install more than one instance. You can avoid this limitation by installing Tomcat from source.

Development

Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can't access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve.

We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.

For more information, see our module contribution guide.

Contributors

To see who's already involved, see the list of contributors.

Running tests

This project contains tests for both rspec-puppet and beaker-rspec to verify functionality. For in-depth information, please see their respective documentation.

Quickstart:

gem install bundler
bundle install
bundle exec rake spec
bundle exec rspec spec/acceptance
RS_DEBUG=yes bundle exec rspec spec/acceptance