16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
##2014-10-28 - Supported Release 1.1.0
###Summary

This release includes documentation and test updates, strict variable support, metadata bugs, and added support for multiple connectors with the same protocol.

###Features
- Strict variable support
- Support multiple connectors with the same protocol
- Update tests to not break when tomcat releases happen
- Update README based on QA feedback

###Bugfixes
- Update stdlib requirement to 4.2.0
- Fix illegal version range in metadata.json
- Fix typo in README

##2014-09-04 - Supported Release 1.0.1
###Summary

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ tomcat::war { 'sample.war':
```
The `war_source` can be a local file, puppet:/// file, http, or ftp.

###I want to change my congfiguration
###I want to change my configuration

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

Expand Down Expand Up @@ -499,7 +499,7 @@ Sets the stop command to use for the service.

#####`$value`

Specifies the value of the parameter you're setting.
Specifies the value of the parameter you're setting. If array is passed, values are separated with a single space.

#####`$ensure`

Expand Down Expand Up @@ -557,7 +557,7 @@ This module only supports Tomcat installations on \*nix systems. The `tomcat::c

###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:
This module requires puppetlabs-stdlib >= 4.2.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
Expand Down
9 changes: 9 additions & 0 deletions manifests/config/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,28 @@
$_class_name = 'rm Server/#attribute/className'
} elsif $class_name {
$_class_name = "set Server/#attribute/className ${class_name}"
} else {
$_class_name = undef
}

if $address_ensure =~ /^(absent|false)$/ {
$_address = 'rm Server/#attribute/address'
} elsif $address {
$_address = "set Server/#attribute/address ${address}"
} else {
$_address = undef
}

if $port {
$_port = "set Server/#attribute/port ${port}"
} else {
$_port = undef
}

if $shutdown {
$_shutdown = "set Server/#attribute/shutdown ${shutdown}"
} else {
$_shutdown = undef
}

$changes = delete_undef_values([$_class_name, $_address, $_port, $_shutdown])
Expand Down
20 changes: 15 additions & 5 deletions manifests/config/server/connector.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,38 @@
$_protocol = $name
}

$base_path = "Server/Service[#attribute/name='${parent_service}']/Connector[#attribute/protocol='${_protocol}']"
$path = "Server/Service[#attribute/name='${parent_service}']"

if $connector_ensure =~ /^(absent|false)$/ {
if ! $port {
$base_path = "${path}/Connector[#attribute/protocol='${_protocol}']"
} else {
$base_path = "${path}/Connector[#attribute/port='${port}']"
}
$changes = "rm ${base_path}"
} else {
if ! $port {
fail('$port must be specified if you aren\'t removing the connector')
fail('$port must be specified unless $connector_ensure is set to \'absent\' or \'false\'')
}

$_protocol_change = "set ${base_path}/#attribute/protocol ${_protocol}"
$base_path = "${path}/Connector[#attribute/port='${port}']"
$_port = "set ${base_path}/#attribute/port ${port}"
$_protocol_change = "set ${base_path}/#attribute/protocol ${_protocol}"
if ! empty($additional_attributes) {
$_additional_attributes = prefix(join_keys_to_values($additional_attributes, ' '), "set ${base_path}/#attribute/")
} else {
$_additional_attributes = undef
}
if ! empty(any2array($attributes_to_remove)) {
$_attributes_to_remove = prefix(any2array($attributes_to_remove), "rm ${base_path}/#attribute/")
} else {
$_attributes_to_remove = undef
}

$changes = delete_undef_values(flatten([$_protocol_change, $_port, $_additional_attributes, $_attributes_to_remove]))
$changes = delete_undef_values(flatten([$_port, $_protocol_change, $_additional_attributes, $_attributes_to_remove]))
}

augeas { "server-${catalina_base}-${parent_service}-connector-${_protocol}":
augeas { "server-${catalina_base}-${parent_service}-connector-${port}":
lens => 'Xml.lns',
incl => "${catalina_base}/conf/server.xml",
changes => $changes,
Expand Down
11 changes: 11 additions & 0 deletions manifests/config/server/engine.pp
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,32 @@
$_background_processor_delay = "rm ${base_path}/#attribute/backgroundProcessorDelay"
} elsif $background_processor_delay {
$_background_processor_delay = "set ${base_path}/#attribute/backgroundProcessorDelay ${background_processor_delay}"
} else {
$_background_processor_delay = undef
}

if $class_name_ensure =~ /^(absent|false)$/ {
$_class_name = "rm ${base_path}/#attribute/className"
} elsif $class_name {
$_class_name = "set ${base_path}/#attribute/className ${class_name}"
} else {
$_class_name = undef
}

if $jvm_route_ensure =~ /^(absent|false)$/ {
$_jvm_route = "rm ${base_path}/#attribute/jvmRoute"
} elsif $jvm_route {
$_jvm_route = "set ${base_path}/#attribute/jvmRoute ${jvm_route}"
} else {
$_jvm_route = undef
}

if $start_stop_threads_ensure =~ /^(absent|false)$/ {
$_start_stop_threads = "rm ${base_path}/#attribute/startStopThreads"
} elsif $start_stop_threads {
$_start_stop_threads = "set ${base_path}/#attribute/startStopThreads ${start_stop_threads}"
} else {
$_start_stop_threads = undef
}

$changes = delete_undef_values([$_name_change, $_default_host, $_background_processor_delay, $_class_name, $_jvm_route, $_start_stop_threads])
Expand Down
5 changes: 5 additions & 0 deletions manifests/config/server/host.pp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,14 @@

if ! empty($additional_attributes) {
$_additional_attributes = prefix(join_keys_to_values($additional_attributes, ' '), "set ${base_path}/#attribute/")
} else {
$_additional_attributes = undef
}

if ! empty(any2array($attributes_to_remove)) {
$_attributes_to_remove = prefix(any2array($attributes_to_remove), "rm ${base_path}/#attribute/")
} else {
$_attributes_to_remove = undef
}

$changes = delete_undef_values(flatten([$_host_name_change, $_app_base, $_additional_attributes, $_attributes_to_remove]))
Expand Down
4 changes: 4 additions & 0 deletions manifests/config/server/valve.pp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,13 @@
$_class_name_change = "set ${base_path}/#attribute/className ${_class_name}"
if ! empty($additional_attributes) {
$_additional_attributes = prefix(join_keys_to_values($additional_attributes, ' '), "set ${base_path}/#attribute/")
} else {
$_additional_attributes = undef
}
if ! empty(any2array($attributes_to_remove)) {
$_attributes_to_remove = prefix(any2array($attributes_to_remove), "rm ${base_path}/#attribute/")
} else {
$_attributes_to_remove = undef
}

$changes = delete_undef_values(flatten([$_class_name_change, $_additional_attributes, $_attributes_to_remove]))
Expand Down
2 changes: 2 additions & 0 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
if $use_jsvc {
if $java_home {
$_jsvc_home = "-home ${java_home} "
} else {
$_jsvc_home = undef
}
$_service_name = "tomcat-${name}"
$_hasstatus = false
Expand Down
7 changes: 4 additions & 3 deletions manifests/setenv/entry.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@

if ! defined(Concat[$_config_file]) {
concat { $_config_file:
owner => $::tomcat::user,
group => $::tomcat::group,
owner => $::tomcat::user,
group => $::tomcat::group,
ensure_newline => true,
}
}

concat::fragment { "setenv-${name}":
ensure => $ensure,
target => $_config_file,
content => inline_template('<%= @param %>=<%= @_quote_char %><%= @value %><%= @_quote_char %>'),
content => inline_template('<%= @param %>=<%= @_quote_char %><%= Array(@value).join(" ") %><%= @_quote_char %>'),
}
}
28 changes: 11 additions & 17 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppetlabs-tomcat",
"version": "1.0.1",
"version": "1.1.0",
"author": "puppetlabs",
"summary": "Puppet module for managing Apache Tomcat.",
"license": "Apache 2.0",
Expand All @@ -20,21 +20,24 @@
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6"
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6"
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6"
"6",
"7"
]
},
{
Expand All @@ -56,25 +59,16 @@
"requirements": [
{
"name": "pe",
"version_requirement": "3.3.x"
"version_requirement": ">= 3.3.0 < 4.0.0"
},
{
"name": "puppet",
"version_requirement": "3.x"
}
],
"dependencies": [
{
"name": "puppetlabs-stdlib",
"version_range": ">= 4.0.0"
},
{
"name": "puppetlabs-concat",
"version_range": ">= 1.0.4"
},
{
"name": "nanliu-staging",
"version_range": ">= 0.4.1"
}
{"name":"puppetlabs-stdlib","version_requirement":">= 4.2.0"},
{"name":"puppetlabs-concat","version_requirement":">= 1.0.4"},
{"name":"nanliu-staging","version_requirement":">= 0.4.1"}
]
}
6 changes: 5 additions & 1 deletion spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
require 'spec_helper'
describe 'tomcat' do

let :facts do
{
:osfamily => 'Debian'
}
end
context 'with defaults for all parameters' do
it { is_expected.to contain_class('tomcat') }
end
Expand Down
57 changes: 45 additions & 12 deletions spec/defines/config/server/connector_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@
],
}
end
it { is_expected.to contain_augeas('server-/opt/apache-tomcat/test-Catalina2-connector-AJP/1.3').with(
it { is_expected.to contain_augeas('server-/opt/apache-tomcat/test-Catalina2-connector-8180').with(
'lens' => 'Xml.lns',
'incl' => '/opt/apache-tomcat/test/conf/server.xml',
'changes' => [
'set Server/Service[#attribute/name=\'Catalina2\']/Connector[#attribute/protocol=\'AJP/1.3\']/#attribute/protocol AJP/1.3',
'set Server/Service[#attribute/name=\'Catalina2\']/Connector[#attribute/protocol=\'AJP/1.3\']/#attribute/port 8180',
'set Server/Service[#attribute/name=\'Catalina2\']/Connector[#attribute/protocol=\'AJP/1.3\']/#attribute/redirectPort 8543',
'set Server/Service[#attribute/name=\'Catalina2\']/Connector[#attribute/protocol=\'AJP/1.3\']/#attribute/connectionTimeout 20000',
'rm Server/Service[#attribute/name=\'Catalina2\']/Connector[#attribute/protocol=\'AJP/1.3\']/#attribute/foo',
'rm Server/Service[#attribute/name=\'Catalina2\']/Connector[#attribute/protocol=\'AJP/1.3\']/#attribute/bar',
'rm Server/Service[#attribute/name=\'Catalina2\']/Connector[#attribute/protocol=\'AJP/1.3\']/#attribute/baz',
'set Server/Service[#attribute/name=\'Catalina2\']/Connector[#attribute/port=\'8180\']/#attribute/port 8180',
'set Server/Service[#attribute/name=\'Catalina2\']/Connector[#attribute/port=\'8180\']/#attribute/protocol AJP/1.3',
'set Server/Service[#attribute/name=\'Catalina2\']/Connector[#attribute/port=\'8180\']/#attribute/redirectPort 8543',
'set Server/Service[#attribute/name=\'Catalina2\']/Connector[#attribute/port=\'8180\']/#attribute/connectionTimeout 20000',
'rm Server/Service[#attribute/name=\'Catalina2\']/Connector[#attribute/port=\'8180\']/#attribute/foo',
'rm Server/Service[#attribute/name=\'Catalina2\']/Connector[#attribute/port=\'8180\']/#attribute/bar',
'rm Server/Service[#attribute/name=\'Catalina2\']/Connector[#attribute/port=\'8180\']/#attribute/baz',
],
)
}
Expand All @@ -51,9 +51,26 @@
{
:catalina_base => '/opt/apache-tomcat/test',
:connector_ensure => 'absent',
:port => '8180',
}
end
it { is_expected.to contain_augeas('server-/opt/apache-tomcat/test-Catalina-connector-HTTP/1.1').with(
it { is_expected.to contain_augeas('server-/opt/apache-tomcat/test-Catalina-connector-8180').with(
'lens' => 'Xml.lns',
'incl' => '/opt/apache-tomcat/test/conf/server.xml',
'changes' => [
'rm Server/Service[#attribute/name=\'Catalina\']/Connector[#attribute/port=\'8180\']',
],
)
}
end
context 'remove connector no port' do
let :params do
{
:catalina_base => '/opt/apache-tomcat/test',
:connector_ensure => 'absent',
}
end
it { is_expected.to contain_augeas('server-/opt/apache-tomcat/test-Catalina-connector-').with(
'lens' => 'Xml.lns',
'incl' => '/opt/apache-tomcat/test/conf/server.xml',
'changes' => [
Expand All @@ -62,11 +79,27 @@
)
}
end
context 'two connectors with same protocol' do
let :pre_condition do
'class { "tomcat": }
tomcat::config::server::connector { "temp":
protocol => "HTTP/1.1",
port => "443",
}
'
end
let :params do
{
:port => '8180',
}
end
it { is_expected.to compile }
end
describe 'failing tests' do
context 'bad connector_ensure' do
let :params do
{
:connector_ensure => 'foo'
:connector_ensure => 'foo',
}
end
it do
Expand All @@ -78,7 +111,7 @@
context 'bad additional_attributes' do
let :params do
{
:additional_attributes => 'foo'
:additional_attributes => 'foo',
}
end
it do
Expand All @@ -96,7 +129,7 @@
it do
expect {
is_expected.to compile
}.to raise_error(Puppet::Error, /\$port must be specified/)
}.to raise_error(Puppet::Error)
end
end
context 'old augeas' do
Expand Down
3 changes: 2 additions & 1 deletion spec/defines/instance/package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
context 'private class fails' do
let :facts do
{
:osfamily => 'Debian'
:osfamily => 'Debian',
:caller_module_name => 'Test'
}
end
it do
Expand Down
Loading