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

Commit

Permalink
v0.5.0
Browse files Browse the repository at this point in the history
* Support SuSE OS family
* Configures instance admin webapps properly when installed from archive
* Does not uninstall unrequired libraries anymore (native, log4j)
* Improve warning logging
* Cleanup
  • Loading branch information
antoineco committed Dec 19, 2014
1 parent 8073b8e commit 137d902
Show file tree
Hide file tree
Showing 16 changed files with 324 additions and 189 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
###0.5.0

* Support SuSE OS family
* Configures instance admin webapps properly when installed from archive
* Does not uninstall unrequired libraries anymore (native, log4j)
* Improve warning logging
* Cleanup

###0.4.1

* Document missing parameter `installation_support`
Expand Down
67 changes: 31 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
1. [Overview](#overview)
2. [Module Description](#module-description)
3. [Setup](#setup)
* [A couple of examples](#a-couple-of-examples)
4. [Usage](#usage)
* [Class: tomcat](#class-tomcat)
* [Define: tomcat::instance](#define-tomcatinstance)
* [Common parameters](#common-parameters)
* [Define: tomcat::userdb_entry](#define-tomcatuserdb_entry)
5. [Limitations](#limitations)
6. [To Do](#to-do)
* [Classes and Defined Types](#classes-and-defined-types)
* [Class: tomcat](#class-tomcat)
* [Define: tomcat::instance](#define-tomcatinstance)
* [Common parameters](#common-parameters)
* [Define: tomcat::userdb_entry](#define-tomcatuserdb_entry)
5. [To Do](#to-do)

##Overview

The tomcat module installs and configures Apache Tomcat instances from either the packages available in your distribution's repositories, or from any archive file you provide to it.

##Module description

This module will install the desired version of the Apache Tomcat Web Application Container from almost any possible source, including the repositories available on the target system (distribution repositories or third-party sources like [JPackage](http://www.jpackage.org) and [EPEL](https://fedoraproject.org/wiki/EPEL)
This module will install the desired version of the Apache Tomcat Web Application Container from almost any possible source, including the repositories available on the target system (distribution repositories or third-party sources like [JPackage](http://www.jpackage.org) and [EPEL](https://fedoraproject.org/wiki/EPEL))
A long list of parameters permit a fine-tuning of the server and the JVM. It is for example possible to configure admin applications, install extra tomcat libraries, configure log4j as the standard logger, or enable the remote JMX listener.
The creation of individual instances is also supported via a custom type.

Expand Down Expand Up @@ -49,6 +50,25 @@ class { '::tomcat':
}
```

Disable default instance and setup 2 individual instances

```puppet
class { '::tomcat':
service_ensure => 'stopped',
service_enable => false
}
tomcat::instance { 'instance1':
control_port => 8005,
http_port => 8080,
ajp_connector => false
}
tomcat::instance { 'instance2':
control_port => 8006,
http_port => 8081,
manage_firewall => true
}
```

Use a non-default JVM and run it with custom options

```puppet
Expand Down Expand Up @@ -107,6 +127,7 @@ Use log4j for Tomcat internal logging and provide a custom XML configuration fil
class { '::tomcat':
log4j => true,
log4j_enable => true,
log4j_conf_type => 'xml',
log4j_conf_source => 'puppet:///modules/my_configs/tomcat_log4j.xml'
}
Expand All @@ -128,36 +149,15 @@ class { '::tomcat':
}
```

Disable default instance and setup 2 individual instances

```puppet
class { '::tomcat':
service_ensure => 'stopped',
service_enable => false,
log4j => true
}
tomcat::instance { 'instance1':
control_port => 8005,
http_port => 8080,
ajp_connector => false,
java_home => '/usr/java/jre1.7.0_65',
java_opts => ['-server', '-Xms256m', '-Xmx2048m', '-XX:+UseConcMarkSweepGC'],
}
tomcat::instance { 'instance2':
control_port => 8006,
http_port => 8081,
log4j_enable => true,
manage_firewall => true
}
```

##Usage

This module distinguishes two different contexts:
* global: default instance and global libraries
* instance: individual tomcat instance

Both contexts have a lot of parameters in common
Both contexts share most of their parameters.

###Classes and Defined Types

####Class: `tomcat`

Expand Down Expand Up @@ -340,13 +340,8 @@ User password (string)
#####`roles`
User roles (array of strings)

##Limitations

* Only supports RedHat and Debian variants/derivatives (for now)

##To Do

* Support SuSE Linux
* Proper startup script for distributions which do not have systemd
* Parameters validation

Expand Down
16 changes: 0 additions & 16 deletions files/instance/systemd_unit.erb

This file was deleted.

20 changes: 10 additions & 10 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# generate and manage server configuration
# Template uses:
# -
#-
file { 'tomcat server configuration':
path => "${::tomcat::catalina_base_real}/conf/server.xml",
content => template("${module_name}/common/server.xml.erb"),
Expand All @@ -20,20 +20,20 @@

# generate and manage global parameters
# Template uses:
# -
#-
# note: defining the exact same parameters in two files may seem awkward,
# but it avoids the randomness observed in some releases due to buggy startup scripts
file {
'tomcat environment variables':
path => $::tomcat::config_path_real,
content => template("${module_name}/common/setenv.erb"),
owner => $::tomcat::tomcat_user_real,
group => $::tomcat::tomcat_group_real,
mode => '0644',
notify => Service[$::tomcat::service_name_real]
file { 'tomcat environment variables':
path => $::tomcat::config_path_real,
content => template("${module_name}/common/setenv.erb"),
owner => $::tomcat::tomcat_user_real,
group => $::tomcat::tomcat_group_real,
mode => '0644',
notify => Service[$::tomcat::service_name_real]
}

if $::osfamily == 'RedHat' {
# make sure system variables are in the right place
file { 'tomcat default variables':
path => "${::tomcat::catalina_base_real}/conf/${::tomcat::service_name_real}.conf",
content => "# See ${::tomcat::config_path_real}"
Expand Down
17 changes: 9 additions & 8 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@

if $admin_webapps_package_name == undef {
$admin_webapps_package_name_real = $::osfamily ? {
'RedHat' => "${package_name}-admin-webapps",
default => "${package_name}-admin"
'Debian' => "${package_name}-admin",
default => "${package_name}-admin-webapps"
} } else {
$admin_webapps_package_name_real = $admin_webapps_package_name
}
Expand All @@ -206,8 +206,8 @@
case $installation_support {
'package' : {
$catalina_base_real = $::osfamily ? {
'RedHat' => $catalina_home_real,
default => "/var/lib/${service_name_real}"
'Debian' => "/var/lib/${service_name_real}",
default => $catalina_home_real
} }
default : {
$catalina_base_real = $catalina_home_real
Expand Down Expand Up @@ -251,8 +251,9 @@
case $installation_support {
'package' : {
$config_path_real = $::osfamily ? {
'RedHat' => "/etc/sysconfig/${service_name_real}",
default => "/etc/default/${service_name_real}"
'Debian' => "/etc/default/${service_name_real}",
'Suse' => "/etc/${service_name_real}/${service_name_real}.conf",
default => "/etc/sysconfig/${service_name_real}"
} }
default : {
$config_path_real = "${catalina_base_real}/bin/setenv.sh"
Expand Down Expand Up @@ -281,8 +282,8 @@

if $tomcat_user == undef {
$tomcat_user_real = $::osfamily ? {
'RedHat' => 'tomcat',
default => $package_name
'Debian' => $package_name,
default => 'tomcat'
} } else {
$tomcat_user_real = $tomcat_user
}
Expand Down
34 changes: 9 additions & 25 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,18 @@
}

# tomcat native library
$ensure_native_package = $::tomcat::tomcat_native ? {
true => 'present',
default => 'absent'
}
package { 'tomcat native library':
ensure => $ensure_native_package,
name => $::tomcat::tomcat_native_package_name
if $::tomcat::tomcat_native {
package { 'tomcat native library':
ensure => present,
name => $::tomcat::tomcat_native_package_name
}
}

# log4j library
$ensure_log4j_package = $::tomcat::log4j ? {
true => 'present',
default => 'absent'
}
package { 'tomcat log4j library':
ensure => $ensure_log4j_package,
name => $::tomcat::log4j_package_name
}

# install admin webapps
if $tomcat::installation_support == 'package' {
$ensure_manager_package = $::tomcat::admin_webapps ? {
true => 'present',
default => 'absent'
}
package { 'tomcat admin webapps':
ensure => $ensure_manager_package,
name => $::tomcat::admin_webapps_package_name_real
if $::tomcat::log4j {
package { 'tomcat log4j library':
ensure => present,
name => $::tomcat::log4j_package_name
}
}
}
5 changes: 5 additions & 0 deletions manifests/install/archive.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,9 @@
ensure => directory,
path => "/var/log/${::tomcat::service_name_real}"
}

# warn if admin webapps were selected for installation
if $::tomcat::admin_webapps {
warning("tomcat archives always contain admin webapps, ignoring parameter 'admin_webapps'")
}
}
10 changes: 9 additions & 1 deletion manifests/install/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@
name => $::tomcat::package_name
}

# install admin webapps
if $::tomcat::admin_webapps {
package { 'tomcat admin webapps':
ensure => present,
name => $::tomcat::admin_webapps_package_name_real
}
}

# fix broken status check in some tomcat init scripts
if $::osfamily == 'RedHat' and $::operatingsystemmajrelease < 7 and $::tomcat::installation_support == 'package' {
if $::osfamily == 'RedHat' and $::operatingsystemmajrelease < 7 {
file_line { 'fix broken tomcat init script':
path => "/etc/init.d/${::tomcat::service_name_real}",
line => " pid=\"$(/usr/bin/pgrep -d , -u \${TOMCAT_USER} -G \${TOMCAT_USER} -f Dcatalina.base=\${CATALINA_BASE})\"",
Expand Down
Loading

0 comments on commit 137d902

Please sign in to comment.