15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
##2014-08-27 - Supported Release 1.0.0
###Summary

This release has added support for installation from packages, improved WAR management, and updates to testing and documentation.

###Features
- Updated tomcat::setenv::entry to better support installations from package
- Added the ability to purge auto-exploded WAR directories when removing WARs. Defaults to purging these directories
- Added warnings for unused variables when installing from package
- Updated acceptance tests and nodesets
- Updated README

###Deprecations
- $tomcat::setenv::entry::base_path is being deprecated in favor of $tomcat::setenv::entry::config_file

##2014-08-20 - Release 0.1.2
###Summary

Expand Down
79 changes: 71 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* [Classes](#classes)
* [Defined Types](#defined-types)
* [Parameters](#parameters)
- [tomcat](#tomcat)
- [tomcat](#tomcat-1)
- [tomcat::config::server](#tomcatconfigserver)
- [tomcat::config::server::connector](#tomcatconfigserverconnector)
- [tomcat::config::server::engine](#tomcatconfigserverengine)
Expand Down Expand Up @@ -42,6 +42,14 @@ Tomcat is a Java web service provider. The Puppet Labs module gives you a way to

**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.**

###Stdlib

This module requires puppetlabs-stdlib >= 4.0. On Puppet Enterprise, this upgrade must be completed manually before this module can be installed. 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 package from EPEL,
Expand Down Expand Up @@ -124,6 +132,8 @@ tomcat::service { 'tomcat6':

###I want to deploy WAR files.

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

```puppet
tomcat::war { 'sample.war':
catalina_base => '/opt/apache-tomcat/tomcat8',
Expand All @@ -132,6 +142,39 @@ tomcat::war { 'sample.war':
```
The `war_source` can be a local file, puppet:/// file, http, or ftp.

###I want to change my congfiguration

Tomcat will not restart if its configuration changes unless you provide a `notify`.

For instance, to remove a connector, you would start with a manifest like this:

```puppet
tomcat::config::server::connector { 'tomcat8-jsvc':
catalina_base => '/opt/apache-tomcat/tomcat8-jsvc',
port => '80',
protocol => 'HTTP/1.1',
additional_attributes => {
'redirectPort' => '443'
},
connector_ensure => 'present'
}
```

Then you would set `connector_ensure` to 'absent', and provide `notify` for the service.

```puppet
tomcat::config::server::connector { 'tomcat8-jsvc':
catalina_base => '/opt/apache-tomcat/tomcat8-jsvc',
port => '80',
protocol => 'HTTP/1.1',
additional_attributes => {
'redirectPort' => '443'
},
connector_ensure => 'present'
notify => Tomcat::Service['jsvc-default'],
}
```

##Reference

###Classes
Expand All @@ -156,7 +199,7 @@ The `war_source` can be a local file, puppet:/// file, http, or ftp.
* `tomcat::config::server::valve`: Configures a [Valve](http://tomcat.apache.org/tomcat-8.0-doc/config/valve.html) 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::setenv::entry`: Adds an entry to the configuration file (ie. setenv.sh, /etc/sysconfig/tomcat, ...).
* `tomcat::war`: Manages the deployment of WAR files.

####Private Defined Types
Expand Down Expand Up @@ -386,11 +429,11 @@ Specifies any attributes to remove from the Valve. Should be a hash of the forma

#####`$catalina_home`

Specifies the root of the Tomcat installation.
Specifies the root of the Tomcat installation. Only affects the instance installation if `$install_from_source` is true.

#####`$catalina_base`

Specifies the base directory for the Tomcat installation.
Specifies the base directory for the Tomcat installation. Only affects the instance installation if `$install_from_source` is true.

#####`$install_from_source`

Expand Down Expand Up @@ -433,7 +476,7 @@ 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](#tomcatconfigserverservice).)
Determines whether the Tomcat service is on or off. Valid values are 'running', 'stopped', 'true', and 'false'. (To determine whether the service is present/absent, see [tomcat::config::server::service](#tomcatconfigserverservice).)

#####`$use_init`

Expand Down Expand Up @@ -462,11 +505,15 @@ Specifies the value of the parameter you're setting.

Determines whether the fragment should be present or absent.

#####`$config_file`

Path to the configuration file to edit. Defaults to '$::tomcat::catalina_home/bin/setenv.sh'.

#####`$base_path`

Sets the path to create the setenv.sh script under. Should be either '$catalina_base/bin' or '$catalina_home/bin'.
Sets the path to create the setenv.sh script under. Should be either '$catalina_base/bin' or '$catalina_home/bin'. **Deprecated** This parameter is being deperecated, please use `$config_file`.

#####`$parameter`
#####`$param`

Specifies the parameter you're setting. Defaults to '[name]' passed in the define.

Expand Down Expand Up @@ -494,7 +541,11 @@ Specifies whether to add or remove the WAR. Valid values are 'present', 'absent'

#####`$war_name`

Specifies the name of the WAR. Defaults to '[name]' passed in the define. This parameter is optional.
Specifies the name of the WAR. Must end in '.war'. Defaults to '[name]' passed in the define. This parameter is optional.

#####`$war_purge`

Specifies whether to purge the exploded WAR directory. Boolean defaulting to true. This parameter is only applicable when `$war_ensure` is 'absent' or 'false'. Setting this parameter to false will not prevent Tomcat from removing the exploded WAR directory if Tomcat is running and autoDeploy is set to true.

#####`$war_source`

Expand All @@ -504,6 +555,18 @@ Specifies the source to deploy the WAR from. Currently supports http(s)://, pupp

This module only supports Tomcat installations on \*nix systems. The `tomcat::config::server*` defines require augeas >= 1.0.0.

###Stdlib

This module requires puppetlabs-stdlib >= 4.0. On Puppet Enterprise, this upgrade must be completed manually before this module can be installed. To update stdlib, run:

```
puppet module upgrade puppetlabs-stdlib
```

###Multiple Instances

If you are not installing Tomcat instances from source, depending on your packaging, multiple instances may not work.

##Development

###Contributing
Expand Down
34 changes: 26 additions & 8 deletions manifests/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
# This define installs an instance of Tomcat.
#
# Parameters:
# - $catalina_home is the root of the Tomcat installation.
# - $catalina_base is the base directory for the Tomcat installation.
# - $catalina_home is the root of the Tomcat installation. This parameter only
# affects the instance when $install_from_source is true.
# - $catalina_base is the base directory for the Tomcat installation. This
# parameter only affects the instance when $install_from_source is true.
# - $install_from_source is a boolean specifying whether or not to install from
# source. Defaults to true.
# - The $source_url to install from. Required if $install_from_source is true.
Expand All @@ -16,8 +18,8 @@
# - $package_name is the name of the package you want to install. Required if
# $install_from_source is false.
define tomcat::instance (
$catalina_home = $::tomcat::catalina_home,
$catalina_base = $::tomcat::catalina_home,
$catalina_home = undef,
$catalina_base = undef,
$install_from_source = true,
$source_url = undef,
$source_strip_first_dir = undef,
Expand All @@ -40,6 +42,22 @@
fail('If not installing from source $package_name must be specified')
}

if ! $install_from_source and ($catalina_home or $catalina_base) {
warning('Setting $catalina_home or $catalina_base when not installing from source doesn\'t affect the installation.')
}

if ! $catalina_home {
$_catalina_home = $::tomcat::catalina_home
} else {
$_catalina_home = $catalina_home
}

if ! $catalina_base {
$_catalina_base = $::tomcat::catalina_home
} else {
$_catalina_base = $catalina_base
}

if $install_from_source {
if ! $source_strip_first_dir {
$source_strip = true
Expand All @@ -48,8 +66,8 @@
}

tomcat::instance::source { $name:
catalina_home => $catalina_home,
catalina_base => $catalina_base,
catalina_home => $_catalina_home,
catalina_base => $_catalina_base,
source_url => $source_url,
source_strip_first_dir => $source_strip,
require => File[$catalina_base],
Expand All @@ -60,8 +78,8 @@
}
}

if $catalina_base != $catalina_home {
file { $catalina_base:
if $install_from_source and $_catalina_base != $_catalina_home {
file { $_catalina_base:
ensure => directory,
owner => $::tomcat::user,
group => $::tomcat::group,
Expand Down
32 changes: 24 additions & 8 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
# - The $start_command to use for the service
# - The $stop_command to use for the service
define tomcat::service (
$catalina_home = $::tomcat::catalina_home,
$catalina_base = $::tomcat::catalina_home,
$catalina_home = undef,
$catalina_base = undef,
$use_jsvc = false,
$java_home = undef,
$service_ensure = running,
Expand All @@ -42,6 +42,10 @@
fail('$service_name must be specified when $use_init is set to true')
}

if $use_init and ($catalina_home or $catalina_base) {
warning('$catalina_home and $catalina_base have no affect when $use_init = true')
}

if $java_home and ! $use_jsvc {
warning('$java_home has no affect unless $use_jsvc = true')
}
Expand All @@ -50,6 +54,18 @@
warning('$java_home is used in the $start_command, so this may not work as planned')
}

if ! $catalina_home {
$_catalina_home = $::tomcat::catalina_home
} else {
$_catalina_home = $catalina_home
}

if ! $catalina_base {
$_catalina_base = $::tomcat::catalina_home
} else {
$_catalina_base = $catalina_base
}

if $use_jsvc {
if $java_home {
$_jsvc_home = "-home ${java_home} "
Expand All @@ -58,7 +74,7 @@
$_hasstatus = false
$_hasrestart = false
$_start = $start_command ? {
undef => "export CATALINA_HOME=${catalina_home}; export CATALINA_BASE=${catalina_base};
undef => "export CATALINA_HOME=${_catalina_home}; export CATALINA_BASE=${_catalina_base};
\$CATALINA_BASE/bin/jsvc \
${_jsvc_home}-user ${::tomcat::user} \
-classpath \$CATALINA_BASE/bin/bootstrap.jar:\$CATALINA_BASE/bin/tomcat-juli.jar \
Expand All @@ -73,13 +89,13 @@
default => $start_command,
}
$_stop = $stop_command ? {
undef => "export CATALINA_HOME=${catalina_home}; export CATALINA_BASE=${catalina_base};
undef => "export CATALINA_HOME=${_catalina_home}; export CATALINA_BASE=${_catalina_base};
\$CATALINA_BASE/bin/jsvc \
-pidfile \$CATALINA_BASE/logs/jsvc.pid \
-stop org.apache.catalina.startup.Bootstrap",
default => $stop_command,
}
$_status = "ps p `cat ${catalina_base}/logs/jsvc.pid` > /dev/null"
$_status = "ps p `cat ${_catalina_base}/logs/jsvc.pid` > /dev/null"
$_provider = 'base'
} elsif $use_init {
$_service_name = $service_name
Expand All @@ -94,14 +110,14 @@
$_hasstatus = false
$_hasrestart = false
$_start = $start_command ? {
undef => "su -s /bin/bash -c '${catalina_base}/bin/catalina.sh start' ${::tomcat::user}",
undef => "su -s /bin/bash -c '${_catalina_base}/bin/catalina.sh start' ${::tomcat::user}",
default => $start_command
}
$_stop = $stop_command ? {
undef => "su -s /bin/bash -c '${catalina_base}/bin/catalina.sh stop' ${::tomcat::user}",
undef => "su -s /bin/bash -c '${_catalina_base}/bin/catalina.sh stop' ${::tomcat::user}",
default => $stop_command
}
$_status = "ps aux | grep 'catalina.base=${catalina_base} ' | grep -v grep"
$_status = "ps aux | grep 'catalina.base=${_catalina_base} ' | grep -v grep"
$_provider = 'base'
}

Expand Down
30 changes: 20 additions & 10 deletions manifests/setenv/entry.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,44 @@
# Parameters:
# - $value is the value of the parameter you're setting
# - $ensure whether the fragment should be present or absent.
# - $base_path is the path to create the setenv.sh script under. Should be
# either $catalina_base/bin or $catalina_home/bin.
# - $parameter is the parameter you're setting. Defaults to $name.
# - $config_file is the path to the config file to edit
# - $param is the parameter you're setting. Defaults to $name.
# - $quote_char is the optional character to quote the value with.
# - (Deprecated) $base_path is the path to create the setenv.sh script under. Should be
# either $catalina_base/bin or $catalina_home/bin.
define tomcat::setenv::entry (
$value,
$ensure = 'present',
$base_path = "${::tomcat::catalina_home}/bin",
$param = $name,
$quote_char = undef,
$ensure = 'present',
$config_file = "${::tomcat::catalina_home}/bin/setenv.sh",
$param = $name,
$quote_char = undef,
# Deprecated
$base_path = '',
) {

if $base_path {
warning('The $base_path parameter is deprecated; please use $config_file instead')
$_config_file = "${base_path}/setenv.sh"
} else {
$_config_file = $config_file
}

if ! $quote_char {
$_quote_char = ''
} else {
$_quote_char = $quote_char
}

if ! defined(Concat["${base_path}/setenv.sh"]) {
concat { "${base_path}/setenv.sh":
if ! defined(Concat[$_config_file]) {
concat { $_config_file:
owner => $::tomcat::user,
group => $::tomcat::group,
}
}

concat::fragment { "setenv-${name}":
ensure => $ensure,
target => "${base_path}/setenv.sh",
target => $_config_file,
content => inline_template('<%= @param %>=<%= @_quote_char %><%= @value %><%= @_quote_char %>'),
}
}
Loading