Version information
Start using this module
Add this module to your Puppetfile:
mod 'puppetlabs-tomcat', '0.1.1'
Learn more about managing modules with a PuppetfileDocumentation
#tomcat
####Table of Contents
- Overview
- Module Description - What the module does and why it is useful
- Setup - The basics of getting started with tomcat
- Usage - Configuration options and additional functionality
- Reference - An under-the-hood peek at what the module is doing and how
- Limitations - OS compatibility, etc.
- Development - Guide for contributing to the module
##Overview
The tomcat module enables you to install, deploy, and configure Tomcat web services.
##Module Description
Tomcat is a Java web service provider. The Puppet Labs module gives you a way to install multiple versions of Tomcat, as well as multiple copies of a version, and deploy web apps to it. The tomcat module also manages the Tomcat configuration file with Puppet.
##Setup
NOTE: You must have Java installed in order to use this module. The version of Java needed will depend on the version of Tomcat you are installing. Older versions of Tomcat require >=java6, while the latest version of Tomcat needs >=java7.
###Beginning with tomcat
The simplest way to get Tomcat up and running with the tomcat module is to install the Tomcat package from EPEL,
class { 'tomcat': }
class { 'epel': }->
tomcat::instance{ 'default':
install_from_source => false,
package_name => 'tomcat',
}->
and then start the service.
tomcat::service { 'default':
use_jsvc => false,
use_init => true,
service_name => 'tomcat',
}
##Usage
###I want to install Tomcat from a specific source.
To download Tomcat from a specific source and then start the service,
class { 'tomcat': }
class { 'java': }
tomcat::instance { 'test':
source_url => 'http://mirror.nexcess.net/apache/tomcat/tomcat-8/v8.0.8/bin/apache-tomcat-8.0.8.tar.gz'
}->
tomcat::service { 'default': }
###I want to run multiple copies of Tomcat on a single node.
class { 'tomcat': }
class { 'java': }
tomcat::instance { 'tomcat8':
catalina_base => '/opt/apache-tomcat/tomcat8',
source_url => 'http://mirror.nexcess.net/apache/tomcat/tomcat-8/v8.0.8/bin/apache-tomcat-8.0.8.tar.gz'
}->
tomcat::service { 'default':
catalina_base => '/opt/apache-tomcat/tomcat8',
}
tomcat::instance { 'tomcat6':
source_url => 'http://apache.mirror.quintex.com/tomcat/tomcat-6/v6.0.41/bin/apache-tomcat-6.0.41.tar.gz',
catalina_base => '/opt/apache-tomcat/tomcat6',
}->
tomcat::config::server { 'tomcat6':
catalina_base => '/opt/apache-tomcat/tomcat6',
port => '8105',
}->
tomcat::config::server::connector { 'tomcat6-http':
catalina_base => '/opt/apache-tomcat/tomcat6',
port => '8180',
protocol => 'HTTP/1.1',
additional_attributes => {
'redirectPort' => '8543'
},
}->
tomcat::config::server::connector { 'tomcat6-ajp':
catalina_base => '/opt/apache-tomcat/tomcat6',
port => '8109',
protocol => 'AJP/1.3',
additional_attributes => {
'redirectPort' => '8543'
},
}->
tomcat::service { 'tomcat6':
catalina_base => '/opt/apache-tomcat/tomcat6'
###I want to deploy WAR files.
tomcat::war { 'sample.war':
catalina_base => '/opt/apache-tomcat/tomcat8',
war_source => '/opt/apache-tomcat/tomcat8/webapps/docs/appdev/sample/sample.war',
}
The war_source
can be a local file, puppet:/// file, http, or ftp.
##Reference
###Classes
####Public Classes
tomcat
: Main class, manages the installation and configuration of Tomcat.
####Private Classes
tomcat::params
: Manages Tomcat parameters.
###Defined Types
####Public Defined Types
tomcat::config::server
: Configures attributes for the Server element in $CATALINA_BASE/conf/server.xml.tomcat::config::server::connector
: Configures Connector elements in $CATALINA_BASE/conf/server.xml.tomcat::config::server::engine
: Configures Engine elements in $CATALINA_BASE/conf/server.xml.tomcat::config::server::host
: Configures Host elements in $CATALINA_BASE/conf/server.xml.tomcat::config::server::service
: Configures a Service element nested in the Server element in $CATALINA_BASE/conf/server.xml.tomcat::config::server::valve
: Configures a Valve element in $CATALINA_BASE/conf/server.xml.tomcat::instance
: Installs a Tomcat instance.tomcat::service
: Provides Tomcat service management.tomcat::setenv::entry
: Adds an entry to the setenv.sh script.tomcat::war
: Manages the deployment of WAR files.
####Private Defined Types
tomcat::instance::package
: Installs Tomcat from a package.tomcat::instance::source
: Installs Tomcat from source.
###Parameters
####tomcat
#####$catalina_home
Specifies the base directory for the Tomcat installation.
#####$user
Sets the user to run Tomcat as.
#####$group
Sets the group to run Tomcat as.
#####$manage_user
Specifies whether or not to manage the user. Boolean that defaults to 'true'.
#####$manage_group
Specifies whether or not to manage the group. Boolean that defaults to 'true'.
####tomcat::config::server
#####$catalina_base
Specifies the base directory for the Tomcat installation.
#####$class_name
Specifies the Java class name of the implementation to use, and maps to the className XML attribute in the Tomcat config file. This parameter is optional.
#####$class_name_ensure
Specifies whether to set or remove the className XML attribute. Valid values are 'true', 'false', 'present', or 'absent'. Defaults to 'present'.
#####$address
Sets the TCP/IP address on which the server waits for a shutdown command, and maps to the address XML attribute. This parameter is optional.
#####$address_ensure
Specifies whether to set or remove the address XML attribute. Valid values are 'true', 'false', 'present', or 'absent'. Defaults to 'present'.
#####$port
Sets the port to wait for shutdown commands on.
#####$shutdown
Specifies the command that must be sent to $port
.
####tomcat::config::server::connector
#####$catalina_base
Specifies the base directory for the Tomcat installation.
#####$connector_ensure
Specifies whether to add or remove ports that Tomcat will listen to for requests, and maps to the Connector XML element. Valid values are 'true', 'false', 'present', and 'absent'. Defaults to 'present'.
#####$port
Sets the TCP port number on which the Connector will create a server socket and await incoming connections. Maps to the port XML attribute. Required unless $connector_ensure
is set to 'false'.
#####$protocol
Sets the protocol to handle incoming traffic. Maps to the protocol XML attribute. Defaults to '[name]' passed in the define.
#####$parent_service
Specifies the Service element this Connector should be nested beneath. Defaults to 'Catalina'.
#####$additional_attributes
Specifies any additional attributes to add to the Connector. Should be a hash of the format 'attribute' => 'value'. This parameter is optional.
#####$attributes_to_remove
Specifies any attributes to remove from the Connector. Should be a hash of the format 'attribute' => 'value'. This parameter is optional.
####tomcat::config::server::engine
#####$default_host
Specifies the default host name for the host that will process requests directed to host names on this server, but which are not configured in this configuration file. Maps to the defaultHost XML attribute for the Engine. This parameter is required.
#####$catalina_base
Specifies the base directory for the Tomcat installation.
#####$background_processor_delay
Determines the delay (in seconds) between the invocation of the backgroundProcess method on this engine and its child containers. Maps to the backgroundProcessorDelay XML attribute. This parameter is optional.
#####$background_processor_delay_ensure
Specifies whether to add or remove the backgroundProcessorDelay XML attribute. Valid values are 'true', 'false', 'present', and 'absent'. Defaults to 'present'.
#####$class_name
Specifies the Java class name of the implementation to use, and maps to the className XML attribute in the Tomcat config file. This parameter is optional.
#####$class_name_ensure
Specifies whether to add or remove the className XML attribute. Valid values are 'true', 'false', 'present', and 'absent'. Defaults to 'present'.
#####$engine_name
Specifies the logical name of the Engine, used in log and error messages. Maps to the name XML attribute. Defaults to '[name]' passed in the define.
#####$jvm_route
Specifies the identifier which must be used in load balancing scenarios to enable session affinity. Maps to the jvmRoute XML attribute. This parameter is optional.
#####$jvm_route_ensure
Specifies whether to add or remove the jvmRoute XML attribute. Valid values are 'true', 'false', 'present', and 'absent'. Defaults to 'present'.
#####$parent_service
Specifies the Service element the Engine should be nested beneath. Defaults to 'Catalina'.
#####$start_stop_threads
Sets the number of threads the Engine will use to start child Host elements in parallel. Maps to the startStopThreads XML attribute. This parameter is optional.
#####$start_stop_threads_ensure
Specifies whether to add or remove the startStopThreads XML attribute. Valid values are 'true', 'false', 'present' and 'absent'. Defaults to 'present'.
####tomcat::config::server::host
#####$app_base
Specifies the Application Base directory for the virtual host, and maps to the appBase XML attribute for the Host. This parameter is required
unless $host_ensure
is set to 'false' or 'absent'.
#####$catalina_base
Specifies the base directory for the Tomcat installation.
#####$host_ensure
Specifies whether to add or remove the virtual host, or Host element. Valid values are 'true', 'false', 'present', and 'absent'. Defaults to 'present'.
#####$host_name
Specifies the the network name of the virtual host, as registered in your DNS server. Maps to the name XML attribute for the Host. Defaults to '[name]' passed in the define.
#####$parent_service
Specifies the Service element the Host should be nested beneath. Defaults to 'Catalina'.
#####$additional_attributes
Specifies any additional attributes to add to the Host. Should be a hash of the format 'attribute' => 'value'. This parameter is optional
#####$attributes_to_remove
Specifies any attributes to remove from the Host. Should be an array of the format 'attribute' => 'value'. This parameter is optional.
####tomcat::config::server::service
#####$catalina_base
Specifies the base directory for the Tomcat installation.
#####$class_name
Specifies the Java class name of the implementation to use, and maps to the className XML attribute. This parameter is optional.
#####$class_name_ensure
Specifies whether to set or remove the className XML attribute. Valid values are 'true', 'false', 'present', or 'absent'. Defaults to 'present'.
#####$service_ensure
Specifies whether to add or remove the Service element. Valid values are 'true', 'false', 'present', or 'absent'. Defaults to 'present'.
####tomcat::config::server::valve
#####$catalina_base
Specifies the root of the Tomcat installation.
#####$class_name
Specifies the Java class name of the implementation to use. Maps to the className XML attribute. Defaults to '[name]' passed in the define.
#####$parent_host
Specifies the virtual host (Host XML element) the Valve should be nested beneath. If not specified, the Valve will be nested beneath the Engine under $parent_service
.
#####$parent_service
Specifies is the Service element this Valve should be nested beneath. Defaults to 'Catalina'.
#####$valve_ensure
Specifies whether to add or remove the component that will be inserted into the request processing pipeline for the associated Catalina container. Maps to the Valve XML element. Valid values are 'true', 'false', 'present', or 'absent'. Defaults to 'present'.
#####$additional_attributes
Specifies any additional attributes to add to the Valve. Should be a hash of the format 'attribute' => 'value'. This parameter is optional.
#####$attributes_to_remove
Specifies any attributes to remove from the Valve. Should be a hash of the format 'attribute' => 'value'. This parameter is optional.
####tomcat::instance
#####$catalina_home
Specifies the root of the Tomcat installation.
#####$catalina_base
Specifies the base directory for the Tomcat installation.
#####$install_from_source
Specifies whether or not to install from source. A Boolean that defaults to 'true'.
#####$source_url
Specifies the source URL to install from. Required if $install_from_source
is true.
#####$source_strip_first_dir
Specifies whether or not to strip the first directory when unpacking the source tarball. A Boolean that defaults to 'true' when installing from source. Requires nanliu/staging > 0.4.0
#####$package_ensure
Specifies what the ensure should be set to in the package resource when installing from a package.
#####$package_name
Specifies the the name of the package you want to install. Required if $install_from_source
is false.
####tomcat::service
#####$catalina_home
Specifies the root of the Tomcat installation.
#####$catalina_base
Specifies the base directory for the Tomcat installation.
#####$use_jsvc
Specifies whether or not to use Jsvc for service management. A Boolean that defaults to 'false'. If both $use_jsvc
and $use_init
are false,
$CATALINA_BASE/bin/catalina.sh start
and $CATALINA_BASE/bin/catalina.sh stop
are used for service management.
#####$java_home
Specifies the path Java is installed under. Only applies if $use_jsvc = 'true'
#####$service_ensure
Determines whether the Tomcat service is on or off. (To determine whether the service is present/absent, see tomcat::config::server::service.)
#####$use_init
Specifies whether or not to use the package-provided init script for service management. A Boolean that defaults to 'false'. If both $use_jsvc
and $use_init
are false,
$CATALINA_BASE/bin/catalina.sh start
and $CATALINA_BASE/bin/catalina.sh stop
are used for service management.
#####$service_name
Specifies the name to use for the service when $use_init
is 'true'.
#####$start_command
Sets the start command to use for the service.
#####$stop_command
Sets the stop command to use for the service.
####tomcat::setenv::entry
#####$value
Specifies the value of the parameter you're setting.
#####$ensure
Determines whether the fragment should be present or absent.
#####$base_path
Sets the path to create the setenv.sh script under. Should be either '$catalina_base/bin' or '$catalina_home/bin'.
#####$parameter
Specifies the parameter you're setting. Defaults to '[name]' passed in the define.
#####$quote_char
Specifies the character with which to quote the value. This parameter is optional.
####tomcat::war
#####$catalina_base
Specifies the base directory for the Tomcat installation.
#####$app_base
Specifies the path relative to $catalina_base
to deploy the WAR to. Defaults to 'webapps'.
#####$deployment_path
Specifies the path to deploy the WAR to. This parameter is optional. You may only specify either $app_base
or $deployment_path
, but not both..
#####$war_ensure
Specifies whether to add or remove the WAR. Valid values are 'present', 'absent', 'true', and 'false'. Defaults to 'present'.
#####$war_name
Specifies the name of the WAR. Defaults to '[name]' passed in the define. This parameter is optional.
#####$war_source
Specifies the source to deploy the WAR from. Currently supports http(s)://, puppet://, and ftp:// paths. $war_source
must be specified unless $war_ensure
is set to 'false' or 'absent'.
##Limitations
This module only supports Tomcat installations on *nix systems.
##Development
###Contributing
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.
You can read the complete module contribution guide on the Puppet Labs wiki.
###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
##2014-08-14 - Release 0.1.1 ###Summary
This is a bugfix release.
###Bugfixes
- Update 'warn' to correct 'warning' function.
- Update README for use_init.
- Test updates and fixes.
##2014-08-06 - Release 0.1.0 ###Summary
Initial release of the tomcat module.
Dependencies
Copyright (C) 2012 Puppet Labs Inc Puppet Labs can be contacted at: info@puppetlabs.com Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.