Skip to content

Commit

Permalink
(MODULES-636) Allow version to be user-defined
Browse files Browse the repository at this point in the history
Without this patch, the rabbitmq class defines a package source for
RedHat and Suse systems in params.pp, based on the version in
params.pp. This means that the version is not overrideable. This patch
moves the construction of the RPM package source to the rabbitmq class
so that it takes into account the version that a user has defined, if
any. It also adds clarification about the behavior of the
package_source and version parameters for systems that don't use RPM.
  • Loading branch information
Colleen Murphy committed Dec 16, 2014
1 parent ed96902 commit c56f338
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,12 @@ What provider to use to install the package.

Where should the package be installed from?

On Debian- and Arch-based systems using the default package provider,
this parameter is ignored and the package is installed from the
rabbitmq repository, if enabled with manage_repo => true, or from the
system repository otherwise. If you want to use dpkg as the
package_provider, you must specify a local package_source.

####`plugin_dir`

Location of RabbitMQ plugins.
Expand Down Expand Up @@ -361,6 +367,11 @@ Boolean to enable TCP connection keepalive for RabbitMQ service.

Sets the version to install.

On Debian- and Arch-based operating systems, the version parameter is
ignored and the latest version is installed from the rabbitmq
repository, if enabled with manage_repo => true, or from the system
repository otherwise.

####`wipe_db_on_cookie_change`

Boolean to determine if we should DESTROY AND DELETE the RabbitMQ database.
Expand Down
18 changes: 17 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
$package_gpg_key = $rabbitmq::params::package_gpg_key,
$package_name = $rabbitmq::params::package_name,
$package_provider = $rabbitmq::params::package_provider,
$package_source = $rabbitmq::params::package_source,
$package_source = undef,
$repos_ensure = $rabbitmq::params::repos_ensure,
$manage_repos = $rabbitmq::params::manage_repos,
$plugin_dir = $rabbitmq::params::plugin_dir,
Expand Down Expand Up @@ -119,6 +119,22 @@
warning('$ssl_stomp_port requires that $ssl => true and will be ignored')
}

# This needs to happen here instead of params.pp because
# $package_source needs to override the constructed value in params.pp
if $package_source { # $package_source was specified by user so use that one
$real_package_source = $package_source
} else { # package_source was not specified, so construct it
case $::osfamily {
'RedHat', 'SUSE': {
$base_version = regsubst($version,'^(.*)-\d$','\1')
$real_package_source = "http://www.rabbitmq.com/releases/rabbitmq-server/v${base_version}/rabbitmq-server-${version}.noarch.rpm"
}
default: { # Archlinux and Debian
$real_package_source = ''
}
}
}

include '::rabbitmq::install'
include '::rabbitmq::config'
include '::rabbitmq::service'
Expand Down
2 changes: 1 addition & 1 deletion manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
$package_ensure = $rabbitmq::package_ensure
$package_name = $rabbitmq::package_name
$package_provider = $rabbitmq::package_provider
$package_source = $rabbitmq::package_source
$package_source = $rabbitmq::real_package_source

package { 'rabbitmq-server':
ensure => $package_ensure,
Expand Down
10 changes: 0 additions & 10 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@
$package_ensure = 'installed'
$package_name = 'rabbitmq'
$service_name = 'rabbitmq'
$package_source = ''
$version = '3.1.3-1'
$base_version = regsubst($version,'^(.*)-\d$','\1')
# This must remain at the end as we need $base_version and $version defined first
}
'Debian': {
$package_ensure = 'installed'
$package_name = 'rabbitmq-server'
$service_name = 'rabbitmq-server'
$package_provider = 'apt'
$package_source = ''
$version = '3.1.5'
}
'RedHat': {
Expand All @@ -28,19 +24,13 @@
$service_name = 'rabbitmq-server'
$package_provider = 'rpm'
$version = '3.1.5-1'
$base_version = regsubst($version,'^(.*)-\d$','\1')
# This must remain at the end as we need $base_version and $version defined first.
$package_source = "http://www.rabbitmq.com/releases/rabbitmq-server/v${base_version}/rabbitmq-server-${version}.noarch.rpm"
}
'SUSE': {
$package_ensure = 'installed'
$package_name = 'rabbitmq-server'
$service_name = 'rabbitmq-server'
$package_provider = 'zypper'
$version = '3.1.5-1'
$base_version = regsubst($version,'^(.*)-\d$','\1')
# This must remain at the end as we need $base_version and $version defined first.
$package_source = "http://www.rabbitmq.com/releases/rabbitmq-server/v${base_version}/rabbitmq-server-${version}.noarch.rpm"
}
default: {
fail("The ${module_name} module is not supported on an ${::osfamily} based system.")
Expand Down

0 comments on commit c56f338

Please sign in to comment.