Skip to content
This repository has been archived by the owner on Jul 24, 2018. It is now read-only.

Commit

Permalink
v0.3.1
Browse files Browse the repository at this point in the history
* `java_opts` and `catalina_opts` are now array parameters
* Path to "setenv" file can be set using `config_path`
* `extras` renamed to `enable_extras`
* `tomcat_native` and `log4j` default to false
  • Loading branch information
antoineco committed Dec 16, 2014
1 parent 4c61c67 commit 562f280
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 59 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
###0.3.1

* `java_opts` and `catalina_opts` are now array parameters
* Path to "setenv" file can be set using `config_path`
* `extras` renamed to `enable_extras`
* `tomcat_native` and `log4j` default to false

###0.3.0

**Warning:** this release is a big step forward, please read the documentation carefully
Expand Down Expand Up @@ -32,7 +39,7 @@

###0.0.4

* Stop managing tomcat user, RPMs already take care of it
Stop managing tomcat user, RPMs already take care of it

###0.0.3

Expand Down
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class { '::tomcat':
package_name => 'ulyaoth-tomcat8',
version => '8.0.15'
service_name => 'tomcat',
config_path => '/opt/tomcat/bin/setenv.sh',
catalina_home => '/opt/tomcat',
catalina_pid => '$CATALINA_TMPDIR/$SERVICE_NAME.pid',
admin_webapps_package_name => 'ulyaoth-tomcat8-admin',
Expand Down Expand Up @@ -167,7 +168,9 @@ Whether to install the Tomcat Native library. Boolean value. Defaults to `false`
#####`tomcat_native_package_name`
Tomcat Native library package name. Default depends on the distribution.
#####`log4j`
Whether to install the log4j library. Boolean value. Defaults to `true`.
Whether to install the log4j library. Boolean value. Defaults to `false`.
#####`log4j_package_name`
Log4j package name. Default depends on the distribution.

See also [Common parameters](#common-parameters)

Expand Down Expand Up @@ -197,7 +200,7 @@ Whether the service should be running. Valid values are `stopped` and `running`.
Whether to enable the tomcat service. Boolean value. Defaults to `true`.
#####`extras`
Whether to install tomcat extra libraries. Boolean value. Defaults to `false`.
**Warning:** enabled globally if defined within the global context
*Warning:* enabled globally if defined within the global context

**Security and administration**

Expand Down Expand Up @@ -253,7 +256,11 @@ JMX/RMI server interface address. Defaults to `undef`.

**Global configuration file / environment variables**

#####`config_path`
Absolute path to the environment configuration (*setenv*). Default depends on the platform.

Please see [catalina.sh](http://svn.apache.org/repos/asf/tomcat/tc8.0.x/trunk/bin/catalina.sh) for a description of the following environment variables.

#####`catalina_home`
$CATALINA_HOME. Default depends on the platform.
#####`catalina_base`
Expand All @@ -267,9 +274,9 @@ $CATALINA_PID. Defaults to `/var/run/${service_name}.pid`
#####`java_home`
$JAVA_HOME. Defaults to `undef`.
#####`java_opts`
$JAVA_OPTS. Defaults to `-server`.
$JAVA_OPTS. Array. Defaults to `['-server']`.
#####`catalina_opts`
$CATALINA_OPTS. Defaults to `undef`.
$CATALINA_OPTS. Array. Defaults to `[]`.
#####`security_manager`
Whether to enable the security manager. Boolean value. Defaults to `false`.
#####`tomcat_user`
Expand All @@ -292,9 +299,7 @@ Custom variables, one per line.
Some extra documentation about [log4j](http://logging.apache.org/log4j/)'s usage with tomcat is available on [this page](http://tomcat.apache.org/tomcat-8.0-doc/logging.html#Using_Log4j).
#####`log4j_enable`
Whether to use log4j rather than *java.util.logging* for Tomcat internal logging. Boolean value. Defaults to `false`.
**Warning:** enabled globally if defined within the global context
#####`log4j_package_name`
Log4j package name. Default depends on the distribution.
*Warning:* enabled globally if defined within the global context
#####`log4j_conf_type`
Log4j configuration type. Valid values are `ini` and `xml`. Defaults to `ini`.
#####`log4j_conf_source`
Expand Down
17 changes: 3 additions & 14 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
fail('You must include the tomcat base class before using any tomcat sub class')
}

# generate OS-specific variables
$config_path = $::osfamily ? {
'RedHat' => "/etc/sysconfig/${::tomcat::service_name_real}",
default => "/etc/default/${::tomcat::service_name_real}"
}

# generate and manage server configuration
# Template uses:
# -
Expand All @@ -28,20 +22,15 @@
# but it avoids the randomness observed in some releases due to buggy startup scripts
file {
'tomcat environment variables':
path => $config_path,
path => $::tomcat::config_path_real,
content => template("${module_name}/common/setenv.erb"),
notify => Service[$::tomcat::service_name_real];

'tomcat setenv.sh':
ensure => link,
path => "${::tomcat::catalina_home_real}/bin/setenv.sh",
target => $config_path
notify => Service[$::tomcat::service_name_real]
}

if $::osfamily == 'RedHat' {
file { 'tomcat default variables':
path => "${::tomcat::catalina_base_real}/conf/${::tomcat::service_name_real}.conf",
content => "# See ${$config_path}"
content => "# See ${::tomcat::config_path_real}"
}
}

Expand Down
35 changes: 24 additions & 11 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@
$service_name = undef,
$service_ensure = 'running',
$service_enable = true,
$tomcat_native = true,
$tomcat_native = false,
$tomcat_native_package_name = $::tomcat::params::tomcat_native_package_name,
$extras = false,
$log4j = true,
$log4j = false,
$log4j_package_name = $::tomcat::params::log4j_package_name,
$enable_extras = false,
#----------------------------------------------------------------------------------
# security and administration
#----------------------------------------------------------------------------------
Expand All @@ -79,7 +80,6 @@
# logging
#----------------------------------------------------------------------------------
$log4j_enable = false,
$log4j_package_name = $::tomcat::params::log4j_package_name,
$log4j_conf_type = 'ini',
$log4j_conf_source = "puppet:///modules/${module_name}/log4j/log4j.properties",
#----------------------------------------------------------------------------------
Expand Down Expand Up @@ -129,14 +129,15 @@
#----------------------------------------------------------------------------------
# global configuration file
#----------------------------------------------------------------------------------
$config_path = undef,
$catalina_home = undef,
$catalina_base = undef,
$jasper_home = undef,
$catalina_tmpdir = undef,
$catalina_pid = undef,
$java_home = undef,
$java_opts = '-server',
$catalina_opts = undef,
$java_opts = ['-server'],
$catalina_opts = [],
$security_manager = false,
$tomcat_user = undef,
$tomcat_group = undef,
Expand All @@ -158,6 +159,15 @@
} } else {
$admin_webapps_package_name_real = $admin_webapps_package_name
}

if $config_path == undef {
$config_path_real = $::osfamily ? {
'RedHat' => "/etc/sysconfig/${service_name_real}",
default => "/etc/default/${service_name_real}"
}
} else {
$config_path_real = $config_path
}

if $catalina_home == undef {
$catalina_home_real = "/usr/share/${service_name_real}"
Expand Down Expand Up @@ -192,6 +202,9 @@
} else {
$catalina_pid_real = $catalina_pid
}

$java_opts_real = join($java_opts, ' ')
$catalina_opts_real = join($catalina_opts, ' ')

if $tomcat_user == undef {
$tomcat_user_real = $::osfamily ? {
Expand Down Expand Up @@ -221,14 +234,14 @@

# should we force download extras libs?
if $log4j_enable or $jmx_listener {
$extras_real = true
$enable_extras_real = true
} else {
$extras_real = $extras
$enable_extras_real = $enable_extras
}

# dependency
# module dependency
if !defined(Class['archive']) {
include archive
include ::archive
}

# start the real action
Expand All @@ -248,7 +261,7 @@
}
}

if $extras_real {
if $enable_extras_real {
class { 'tomcat::extras':
require => Class['::tomcat::install']
}
Expand Down
51 changes: 28 additions & 23 deletions manifests/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
$service_enable = true,
$service_start = undef,
$service_stop = undef,
$extras = false,
$enable_extras = false,
#----------------------------------------------------------------------------------
# security and administration
#----------------------------------------------------------------------------------
Expand Down Expand Up @@ -89,14 +89,15 @@
#----------------------------------------------------------------------------------
# global configuration file
#----------------------------------------------------------------------------------
$config_path = undef,
$catalina_home = undef,
$catalina_base = undef,
$jasper_home = undef,
$catalina_tmpdir = undef,
$catalina_pid = undef,
$java_home = undef,
$java_opts = '-server',
$catalina_opts = undef,
$java_opts = ['-server'],
$catalina_opts = [],
$security_manager = false,
$lang = undef,
$shutdown_wait = 30,
Expand All @@ -120,6 +121,14 @@
$service_name_real = $service_name
}

if $config_path == undef {
$config_path_real = $::osfamily ? {
'RedHat' => "/etc/sysconfig/${service_name_real}",
default => "/etc/default/${service_name_real}"
} } else {
$config_path_real = $config_path
}

if $catalina_home == undef {
$catalina_home_real = $::tomcat::catalina_home_real
} else {
Expand Down Expand Up @@ -152,6 +161,9 @@
$catalina_pid_real = $catalina_pid
}

$java_opts_real = join($java_opts, ' ')
$catalina_opts_real = join($catalina_opts, ' ')

if $::osfamily == 'Debian' {
$security_manager_real = $security_manager ? {
true => 'yes',
Expand All @@ -162,9 +174,9 @@

# should we force download extras libs?
if $log4j_enable or $jmx_listener {
$extras_real = true
$enable_extras_real = true
} else {
$extras_real = $extras
$enable_extras_real = $enable_extras
}

# --------#
Expand Down Expand Up @@ -276,12 +288,6 @@
# configuration files #
# --------------------#

# generate OS-specific variables
$config_path = $::osfamily ? {
'RedHat' => "/etc/sysconfig/${service_name_real}",
default => "/etc/default/${service_name_real}"
}

# generate and manage server configuration
# Template uses:
#-
Expand All @@ -296,22 +302,16 @@
#-
# note: defining the exact same parameters in several files may seem awkward,
# but it avoids the randomness observed in some older releases due to buggy startup scripts
file {
"instance ${name} environment variables":
path => $config_path,
content => template("${module_name}/common/setenv.erb"),
notify => Service[$service_name_real];

"instance ${name} setenv.sh":
ensure => link,
path => "${catalina_base_real}/bin/setenv.sh",
target => $config_path
file { "instance ${name} environment variables":
path => $config_path_real,
content => template("${module_name}/common/setenv.erb"),
notify => Service[$service_name_real]
}

if $::osfamily == 'RedHat' {
file { "instance ${name} default variables":
path => "${catalina_base_real}/conf/${service_name_real}.conf",
content => "# See ${$config_path}"
content => "# See ${config_path_real}"
}
}

Expand Down Expand Up @@ -385,6 +385,11 @@
# --------#

if $log4j_enable {
# warn user if log4j is not installed
unless $::tomcat::log4j {
warning('Logging with log4j will not work unless the log4j library is installed')
}

# no need to duplicate libraries if enabled globally
unless $::tomcat::log4j_enable {
# generate OS-specific variables
Expand Down Expand Up @@ -447,7 +452,7 @@
# extras #
# -------#

if $extras_real and !$::tomcat::extras_real { # no need to duplicate libraries if enabled globally
if $enable_extras_real and !$::tomcat::enable_extras_real { # no need to duplicate libraries if enabled globally
Archive {
cleanup => false,
require => File["instance ${name} extras directory"],
Expand Down
5 changes: 5 additions & 0 deletions manifests/log4j.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
if !defined(Class['tomcat']) {
fail('You must include the tomcat base class before using any tomcat sub class')
}

# warn user if log4j is not installed
unless $::tomcat::log4j {
warning('Logging with log4j will not work unless the log4j library is installed')
}

# generate OS-specific variables
$log4j_path = $::osfamily ? {
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "aco-tomcat",
"summary": "Puppet module for Tomcat",
"author": "Antoine Cotten",
"version": "0.3.0",
"version": "0.3.1",
"license": "Apache-2.0",
"project_page": "https://github.com/tOnI0/aco-tomcat",
"source": "git://github.com/tOnI0/aco-tomcat.git",
Expand Down
4 changes: 2 additions & 2 deletions templates/common/setenv.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ CATALINA_TMPDIR="<%= @catalina_tmpdir_real %>"
<% if @catalina_pid_real and @catalina_pid_real != '' %>CATALINA_PID="<%= @catalina_pid_real %>"
<% end -%>

<% if @java_opts and @java_opts != '' %>JAVA_OPTS="<%= @java_opts %>"
<% if @java_opts and @java_opts != [] %>JAVA_OPTS="<%= @java_opts_real %>"
<% end -%>
<% if @catalina_opts and @catalina_opts != '' %>CATALINA_OPTS="<%= @catalina_opts %>"
<% if @catalina_opts and @catalina_opts != [] %>CATALINA_OPTS="<%= @catalina_opts_real %>"
<% end -%>

<% if scope['::osfamily'] == 'Debian' -%>
Expand Down

0 comments on commit 562f280

Please sign in to comment.