Showing with 384 additions and 374 deletions.
  1. +35 −26 CHANGELOG.md
  2. +2 −1 manifests/config/server/connector.pp
  3. +97 −97 manifests/config/server/tomcat_users.pp
  4. +3 −3 metadata.json
  5. +247 −247 spec/defines/config/server/tomcat_users_spec.rb
61 changes: 35 additions & 26 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
## 2015-08-11 - Supported Release 1.3.2
### Summary
This release fixes username quoting and metadata.

#### Bugfixes
- Allow username values that contain non-string characters like whitespace
- Validate $catalina\_base
- Correct pe/puppet compatibility metadata

## 2015-07-16 - Supported Release 1.3.1
### Summary
This release fixes metadata because it supports puppet 4.

##2015-06-09 - Supported Release 1.3.0
###Summary
## 2015-06-09 - Supported Release 1.3.0
### Summary

This is a feature release, with a couple of bugfixes and readme changes.

####Features
#### Features
- Update additional_attributes to support values with spaces
- Documentation changes
- Add a manifest for Context Containers in Tomcat configuration
Expand All @@ -19,80 +28,80 @@ This is a feature release, with a couple of bugfixes and readme changes.
- Add ability to specify server_config location
- Allow configuration of location of server.xml

####Bugfixes
#### Bugfixes
- Make sure setenv entries have export
- Test improvements
- version pinning for acceptance tests

##2014-11-11 - Supported Release 1.2.0
###Summary
## 2014-11-11 - Supported Release 1.2.0
### Summary

This is primarily a feature release, with a couple of bugfixes for tests and metadata.

####Features
#### Features
- Add `install_from_source` parameter to class `tomcat`
- Add `purge_connectors` parameter to class `tomcat` and define `tomcat::server::connector`

####Bugfixes
#### Bugfixes
- Fix dependencies to remove missing dependency warnings with the PMT
- Use `curl -k` in the tests

##2014-10-28 - Supported Release 1.1.0
###Summary
## 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
### 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
### 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
## 2014-09-04 - Supported Release 1.0.1
### Summary

This is a bugfix release.

###Bugfixes
### Bugfixes
- Fix typo in tomcat::instance
- Update acceptance tests for new tomcat releases

##2014-08-27 - Supported Release 1.0.0
###Summary
## 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
### 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
### 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
## 2014-08-20 - Release 0.1.2
### Summary

This release adds compatibility information and updates the README with information on the requirement of augeas >= 1.0.0.

##2014-08-14 - Release 0.1.1
###Summary
## 2014-08-14 - Release 0.1.1
### Summary

This is a bugfix release.

###Bugfixes
### Bugfixes
- Update 'warn' to correct 'warning' function.
- Update README for use_init.
- Test updates and fixes.

##2014-08-06 - Release 0.1.0
###Summary
## 2014-08-06 - Release 0.1.0
### Summary

Initial release of the tomcat module.
3 changes: 2 additions & 1 deletion manifests/config/server/connector.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
validate_re($connector_ensure, '^(present|absent|true|false)$')
validate_hash($additional_attributes)
validate_bool($purge_connectors)

validate_re($catalina_base, '^.*[^/]$', '$catalina_base must not end in a /!')

if $protocol {
$_protocol = $protocol
} else {
Expand Down
194 changes: 97 additions & 97 deletions manifests/config/server/tomcat_users.pp
Original file line number Diff line number Diff line change
@@ -1,97 +1,97 @@
# Definition tomcat::config::server::tomcat_users
#
# Configures roles and users in $CATALINA_BASE/conf/tomcat-users.xml
# or any other specified file
#
# Parameters:
# - $catalina_base is the base directory for the Tomcat installation
# - $element specifies the element type. Valid values are 'user' or 'role'.
# Defaults to 'user'.
# - $element_name sets the 'username' or 'rolename'. Depends on the $element.
# Defaults to $name.
# - $ensure specifies whether you are trying to add or remove the element.
# Valid values are 'present', 'absent', 'true', and 'false'. Defaults to
# 'present'.
# - $file: The path to the file to manage. Must be fully qualified.
# Defaults to $CATALINA_BASE/conf/tomcat-users.xml.
# - Set $manage_file to true for managing the file. It sets file permission,
# owner, group and create a basic tomcat-users XML if file does not exist yet.
# - $password specifies the password for a user ($element = 'user').
# - $roles specifies the roles for a user ($element = 'user').
#
define tomcat::config::server::tomcat_users (
$catalina_base = $::tomcat::catalina_home,
$element = 'user',
$element_name = undef,
$ensure = present,
$file = undef,
$manage_file = true,
$password = undef,
$roles = [],
) {

if versioncmp($::augeasversion, '1.0.0') < 0 {
fail('Server configurations require Augeas >= 1.0.0')
}

validate_re($element, '^(user|role)$')
validate_re($ensure, '^(present|absent|true|false)$')
validate_array($roles)
validate_bool($manage_file)

if $element == 'role' and ( $password or ! empty($roles) ) {
warning('$password and $roles are useless when $element is set to \'role\'')
}
if $element == 'user' {
$element_identifier = 'username'
} else {
$element_identifier = 'rolename'
}

if $element_name {
$_element_name = $element_name
} else {
$_element_name = $name
}
if $file {
$_file = $file
} else {
$_file = "${catalina_base}/conf/tomcat-users.xml"
}
if $manage_file {
ensure_resource('file', $_file, {
ensure => file,
path => $_file,
replace => false,
content => '<?xml version=\'1.0\' encoding=\'utf-8\'?><tomcat-users></tomcat-users>',
owner => $::tomcat::user,
group => $::tomcat::group,
mode => '0640',
})
}

$path = "tomcat-users/${element}[#attribute/${element_identifier}='${_element_name}']"

if $ensure =~ /^(absent|false)$/ {
$remove_entry = "rm ${path}"
} else {
$add_entry = "set ${path}/#attribute/${element_identifier} ${_element_name}"
if $element == 'user' {
$add_password = "set ${path}/#attribute/password '${password}'"
$add_roles = join(["set ${path}/#attribute/roles '",join($roles, ','),"'"])
}
}

$changes = delete_undef_values(flatten([$remove_entry, $add_entry, $add_password, $add_roles]))

augeas { "${catalina_base}-tomcat_users-${element}-${_element_name}-${name}":
lens => 'Xml.lns',
incl => $_file,
changes => $changes,
require => File[$_file],
}

}
# Definition tomcat::config::server::tomcat_users
#
# Configures roles and users in $CATALINA_BASE/conf/tomcat-users.xml
# or any other specified file
#
# Parameters:
# - $catalina_base is the base directory for the Tomcat installation
# - $element specifies the element type. Valid values are 'user' or 'role'.
# Defaults to 'user'.
# - $element_name sets the 'username' or 'rolename'. Depends on the $element.
# Defaults to $name.
# - $ensure specifies whether you are trying to add or remove the element.
# Valid values are 'present', 'absent', 'true', and 'false'. Defaults to
# 'present'.
# - $file: The path to the file to manage. Must be fully qualified.
# Defaults to $CATALINA_BASE/conf/tomcat-users.xml.
# - Set $manage_file to true for managing the file. It sets file permission,
# owner, group and create a basic tomcat-users XML if file does not exist yet.
# - $password specifies the password for a user ($element = 'user').
# - $roles specifies the roles for a user ($element = 'user').
#
define tomcat::config::server::tomcat_users (
$catalina_base = $::tomcat::catalina_home,
$element = 'user',
$element_name = undef,
$ensure = present,
$file = undef,
$manage_file = true,
$password = undef,
$roles = [],
) {

if versioncmp($::augeasversion, '1.0.0') < 0 {
fail('Server configurations require Augeas >= 1.0.0')
}

validate_re($element, '^(user|role)$')
validate_re($ensure, '^(present|absent|true|false)$')
validate_array($roles)
validate_bool($manage_file)

if $element == 'role' and ( $password or ! empty($roles) ) {
warning('$password and $roles are useless when $element is set to \'role\'')
}

if $element == 'user' {
$element_identifier = 'username'
} else {
$element_identifier = 'rolename'
}

if $element_name {
$_element_name = $element_name
} else {
$_element_name = $name
}

if $file {
$_file = $file
} else {
$_file = "${catalina_base}/conf/tomcat-users.xml"
}

if $manage_file {
ensure_resource('file', $_file, {
ensure => file,
path => $_file,
replace => false,
content => '<?xml version=\'1.0\' encoding=\'utf-8\'?><tomcat-users></tomcat-users>',
owner => $::tomcat::user,
group => $::tomcat::group,
mode => '0640',
})
}

$path = "tomcat-users/${element}[#attribute/${element_identifier}='${_element_name}']"

if $ensure =~ /^(absent|false)$/ {
$remove_entry = "rm ${path}"
} else {
$add_entry = "set ${path}/#attribute/${element_identifier} '${_element_name}'"
if $element == 'user' {
$add_password = "set ${path}/#attribute/password '${password}'"
$add_roles = join(["set ${path}/#attribute/roles '",join($roles, ','),"'"])
}
}

$changes = delete_undef_values(flatten([$remove_entry, $add_entry, $add_password, $add_roles]))

augeas { "${catalina_base}-tomcat_users-${element}-${_element_name}-${name}":
lens => 'Xml.lns',
incl => $_file,
changes => $changes,
require => File[$_file],
}

}
6 changes: 3 additions & 3 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppetlabs-tomcat",
"version": "1.3.1",
"version": "1.3.2",
"author": "puppetlabs",
"summary": "Installs, deploys, and configures Apache Tomcat web services.",
"license": "Apache 2.0",
Expand Down Expand Up @@ -64,11 +64,11 @@
"requirements": [
{
"name": "pe",
"version_requirement": ">= 3.3.0 < 5.0.0"
"version_requirement": ">= 3.3.0 < 2015.3.0"
},
{
"name": "puppet",
"version_requirement": ">= 3.0.0 < 2015.3.0"
"version_requirement": ">= 3.0.0 < 5.0.0"
}
]
}
Loading