Skip to content
This repository was archived by the owner on Feb 18, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
fixtures:
repositories:
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
staging: "git://github.com/nanliu/puppet-staging"
symlinks:
activemq: "#{source_dir}"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ pkg/
tmp/
.DS_Store
spec/fixtures
.ruby-gemset
.ruby-version
Gemfile.lock
activemq.iml
11 changes: 3 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,21 @@ language: ruby
bundler_args: --without development
script: "bundle exec rake spec SPEC_OPTS='--format documentation'"
rvm:
- 1.8.7
- 1.9.3
- 2.0.0
env:
matrix:
- PUPPET_GEM_VERSION="~> 2.7.0"
- PUPPET_GEM_VERSION="~> 3.0.0"
- PUPPET_GEM_VERSION="~> 3.1.0"
- PUPPET_GEM_VERSION="~> 3.2.0"
- PUPPET_GEM_VERSION="~> 3.6.2"
- PUPPET_GEM_VERSION="~> 3.8.1"
matrix:
exclude:
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 2.7.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 2.7.0"
env: PUPPET_GEM_VERSION="~> 3.8.1"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.0.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.1.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 3.2.0"
notifications:
email: false
18 changes: 18 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,22 @@ To disable this behavior, pass in webconsole => false to the class. e.g.
webconsole => false,
}
}

# Custom configuration #

node default {
class { 'activemq':
server_config => template("${module_name}/activemq.xml.erb"),
}
}

# Install from binary #

If you do not have a activemq package ready for your favorite distribution, you can install it from the binary

node default {
class { 'activemq':
install_from_binary => true,
package => 'http://www.eu.apache.org/dist/activemq/5.13.0/apache-activemq-5.13.0-bin.tar.gz',
}
}
43 changes: 25 additions & 18 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,34 @@
# Sample Usage:
#
class activemq::config (
$server_config,
$instance,
$package,
$path = '/etc/activemq/activemq.xml',
$server_config_show_diff = 'UNSET',
$server_config = $activemq::server_config_content,
$instance = $activemq::instance,
$path = $activemq::config_path,
$server_config_show_diff = $activemq::server_config_show_diff,
$system_user = $activemq::system_user,
$system_group = $activemq::system_group,
$install_from_binary = $activemq::install_from_binary,
$log_path = $activemq::log_path,
) {

# Resource defaults
File {
owner => 'activemq',
group => 'activemq',
owner => $system_user,
group => $system_group,
mode => '0644',
notify => Service['activemq'],
require => Package[$package],
notify => Class['activemq::service'],
require => Class['activemq::packages'],
}

if $server_config_show_diff != 'UNSET' {
if versioncmp($settings::puppetversion, '3.2.0') >= 0 {
if versioncmp($::puppetversion, '3.2.0') >= 0 {
File { show_diff => $server_config_show_diff }
} else {
warning('show_diff not supported in puppet prior to 3.2, ignoring')
}
}

$server_config_real = $server_config

if $::osfamily == 'Debian' {
if $::osfamily == 'Debian' and !$install_from_binary {
$available = "/etc/activemq/instances-available/${instance}"
$path_real = "${available}/activemq.xml"

Expand All @@ -49,20 +50,26 @@
ensure => link,
target => $available,
}
}
else {
} else {
validate_re($path, '^/')
$path_real = $path
}

if $install_from_binary {
file { $log_path:
ensure => directory,
}
}

# The configuration file itself.
file { 'activemq.xml':
ensure => file,
path => $path_real,
owner => 'activemq',
group => 'activemq',
owner => $system_user,
group => $system_group,
mode => '0600',
content => $server_config_real,
content => $server_config,
notify => Class['activemq::service'],
}

}
65 changes: 31 additions & 34 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
# }
#
class activemq(
$install_from_binary = $activemq::params::install_from_binary,
$home = $activemq::params::home,
$log_path = $activemq::params::log_path,
$system_user = $activemq::params::system_user,
$system_group = $activemq::params::system_group,
$version = $activemq::params::version,
$package = $activemq::params::package,
$ensure = $activemq::params::ensure,
Expand All @@ -44,35 +49,37 @@
validate_re($version, '^present$|^latest$|^[~+._0-9a-zA-Z:-]+$')
validate_bool($webconsole)

$package_real = $package
$version_real = $version
$ensure_real = $ensure
$webconsole_real = $webconsole
$mq_admin_username_real = $mq_admin_username
$mq_admin_password_real = $mq_admin_password
$mq_cluster_username_real = $mq_cluster_username
$mq_cluster_password_real = $mq_cluster_password
$mq_cluster_brokers_real = $mq_cluster_brokers

if $mq_admin_username_real == 'admin' {
warning '$mq_admin_username is set to the default value. This should be changed.'
if $server_config == 'UNSET' {
if $mq_admin_username == $activemq::params::mq_admin_username {
warning '$mq_admin_username is set to the default value. This should be changed.'
}
if $mq_admin_password == $activemq::params::mq_admin_password {
warning '$mq_admin_password is set to the default value. This should be changed.'
}
if size($mq_cluster_brokers) > 0 and $mq_cluster_username == $activemq::params::mq_cluster_username {
warning '$mq_cluster_username is set to the default value. This should be changed.'
}
if size($mq_cluster_brokers) > 0 and $mq_cluster_password == $activemq::params::mq_cluster_password {
warning '$mq_cluster_password is set to the default value. This should be changed.'
}
}

if $mq_admin_password_real == 'admin' {
warning '$mq_admin_password is set to the default value. This should be changed.'
if $home != $activemq::params::home and !$install_from_binary {
fail 'home must not be set when install_from_binary=false(default)'
}

if size($mq_cluster_brokers_real) > 0 and $mq_cluster_username_real == 'amq' {
warning '$mq_cluster_username is set to the default value. This should be changed.'
if $log_path != $activemq::params::log_path and !$install_from_binary {
fail 'log_path must not be set when install_from_binary=false(default)'
}

if size($mq_cluster_brokers_real) > 0 and $mq_cluster_password_real == 'secret' {
warning '$mq_cluster_password is set to the default value. This should be changed.'
$config_path = $install_from_binary ? {
true => "${home}/conf/activemq.xml",
default => '/etc/activemq/activemq.xml',
}

# Since this is a template, it should come _after_ all variables are set for
# this class.
$server_config_real = $server_config ? {
$server_config_content = $server_config ? {
'UNSET' => template("${module_name}/activemq.xml.erb"),
default => $server_config,
}
Expand All @@ -83,23 +90,13 @@
notify => Class['activemq::service'],
}

class { 'activemq::packages':
version => $version_real,
package => $package_real,
notify => Class['activemq::service'],
}
class { 'activemq::packages': }
~>
class { 'activemq::service': }

class { 'activemq::config':
instance => $instance,
package => $package_real,
server_config => $server_config_real,
server_config_show_diff => $server_config_show_diff,
require => Class['activemq::packages'],
notify => Class['activemq::service'],
}

class { 'activemq::service':
ensure => $ensure_real,
require => Class['activemq::packages'],
notify => Class['activemq::service'],
}

anchor { 'activemq::end':
Expand Down
108 changes: 95 additions & 13 deletions manifests/packages.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,112 @@
# Sample Usage:
#
class activemq::packages (
$version,
$package
$version = $activemq::version,
$package = $activemq::package,
$install_from_binary = $activemq::install_from_binary,
$system_user = $activemq::system_user,
$system_group = $activemq::system_group,
$activemq_home = $activemq::home,
$config_path = $activemq::config_path,
$log_path = $activemq::log_path,
) {

validate_re($version, '^[~+._0-9a-zA-Z:-]+$')
validate_bool($install_from_binary)

$version_real = $version
$package_real = $package

package { $package_real:
ensure => $version_real,
notify => Service['activemq'],
unless $install_from_binary {
package { $package:
ensure => $version,
notify => Class['activemq::service'],
}
}

if $install_from_binary {
include staging

file { '/etc/init.d/activemq':
ensure => file,
content => template("${module_name}/init/default/activemq"),
owner => 'root',
group => 'root',
mode => '0755',
}

# Manage user and group only if installed from source, it is managed by
# packaging system otherwise
group { $system_group:
ensure => 'present',
system => true,
}

user { $system_user:
ensure => 'present',
gid => $system_group,
home => $activemq_home,
managehome => false,
system => true,
shell => '/bin/false',
require => Group[$system_group],
}

validate_absolute_path($activemq_home)
validate_re(
$package,
'^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$',
"Expected to `package' parameter be a valid HTTP URI, when
`install_from_binary' is true."
)

file { $activemq_home:
ensure => directory,
owner => $system_user,
group => $system_group,
require => User[$system_user],
}

$filename = regsubst($package, '.*/(.*)', '\1')

if ! defined(Staging::File[$filename]) {
staging::file { $filename:
source => $package,
timeout => 0,
}
}

staging::extract { $filename:
source => "${::staging::path}/activemq/${filename}",
target => $activemq_home,
require => [Staging::File[$filename], File[$activemq_home]],
unless => "test \"\$(ls -A ${activemq_home})\"",
strip => 1,
user => $system_user,
group => $system_group,
}

file_line { 'audit.file':
path => "${activemq_home}/conf/log4j.properties",
line => "log4j.appender.audit.file=${log_path}/audit.log",
match => '^log4j\.appender\.audit\.file.*',
require => [Staging::Extract[$filename]],
}

file_line { 'logfile':
path => "${activemq_home}/conf/log4j.properties",
line => "log4j.appender.logfile.file=${log_path}/activemq.log",
match => '^log4j\.appender\.logfile\.file.*',
require => [Staging::Extract[$filename]],
}

# Has been reworked in 5.9 and no longer needed
if $::osfamily == 'RedHat' and ($version == 'present' or versioncmp($version, '5.9') < 0) {
} elsif $::osfamily == 'RedHat' and ($version == 'present' or versioncmp($version, '5.9') < 0) {

# JJM Fix the activemq init script always exiting with status 0
# FIXME This should be corrected in the upstream packages
file { '/etc/init.d/activemq':
ensure => file,
path => '/etc/init.d/activemq',
content => template("${module_name}/init/activemq"),
owner => '0',
group => '0',
content => template("${module_name}/init/redhat/activemq"),
owner => 'root',
group => 'root',
mode => '0755',
}
}
Expand Down
Loading