Skip to content

Commit c56f338

Browse files
author
Colleen Murphy
committed
(MODULES-636) Allow version to be user-defined
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.
1 parent ed96902 commit c56f338

4 files changed

Lines changed: 29 additions & 12 deletions

File tree

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,12 @@ What provider to use to install the package.
288288

289289
Where should the package be installed from?
290290

291+
On Debian- and Arch-based systems using the default package provider,
292+
this parameter is ignored and the package is installed from the
293+
rabbitmq repository, if enabled with manage_repo => true, or from the
294+
system repository otherwise. If you want to use dpkg as the
295+
package_provider, you must specify a local package_source.
296+
291297
####`plugin_dir`
292298

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

362368
Sets the version to install.
363369

370+
On Debian- and Arch-based operating systems, the version parameter is
371+
ignored and the latest version is installed from the rabbitmq
372+
repository, if enabled with manage_repo => true, or from the system
373+
repository otherwise.
374+
364375
####`wipe_db_on_cookie_change`
365376

366377
Boolean to determine if we should DESTROY AND DELETE the RabbitMQ database.

manifests/init.pp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
$package_gpg_key = $rabbitmq::params::package_gpg_key,
2222
$package_name = $rabbitmq::params::package_name,
2323
$package_provider = $rabbitmq::params::package_provider,
24-
$package_source = $rabbitmq::params::package_source,
24+
$package_source = undef,
2525
$repos_ensure = $rabbitmq::params::repos_ensure,
2626
$manage_repos = $rabbitmq::params::manage_repos,
2727
$plugin_dir = $rabbitmq::params::plugin_dir,
@@ -119,6 +119,22 @@
119119
warning('$ssl_stomp_port requires that $ssl => true and will be ignored')
120120
}
121121

122+
# This needs to happen here instead of params.pp because
123+
# $package_source needs to override the constructed value in params.pp
124+
if $package_source { # $package_source was specified by user so use that one
125+
$real_package_source = $package_source
126+
} else { # package_source was not specified, so construct it
127+
case $::osfamily {
128+
'RedHat', 'SUSE': {
129+
$base_version = regsubst($version,'^(.*)-\d$','\1')
130+
$real_package_source = "http://www.rabbitmq.com/releases/rabbitmq-server/v${base_version}/rabbitmq-server-${version}.noarch.rpm"
131+
}
132+
default: { # Archlinux and Debian
133+
$real_package_source = ''
134+
}
135+
}
136+
}
137+
122138
include '::rabbitmq::install'
123139
include '::rabbitmq::config'
124140
include '::rabbitmq::service'

manifests/install.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
$package_ensure = $rabbitmq::package_ensure
66
$package_name = $rabbitmq::package_name
77
$package_provider = $rabbitmq::package_provider
8-
$package_source = $rabbitmq::package_source
8+
$package_source = $rabbitmq::real_package_source
99

1010
package { 'rabbitmq-server':
1111
ensure => $package_ensure,

manifests/params.pp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,13 @@
99
$package_ensure = 'installed'
1010
$package_name = 'rabbitmq'
1111
$service_name = 'rabbitmq'
12-
$package_source = ''
1312
$version = '3.1.3-1'
14-
$base_version = regsubst($version,'^(.*)-\d$','\1')
15-
# This must remain at the end as we need $base_version and $version defined first
1613
}
1714
'Debian': {
1815
$package_ensure = 'installed'
1916
$package_name = 'rabbitmq-server'
2017
$service_name = 'rabbitmq-server'
2118
$package_provider = 'apt'
22-
$package_source = ''
2319
$version = '3.1.5'
2420
}
2521
'RedHat': {
@@ -28,19 +24,13 @@
2824
$service_name = 'rabbitmq-server'
2925
$package_provider = 'rpm'
3026
$version = '3.1.5-1'
31-
$base_version = regsubst($version,'^(.*)-\d$','\1')
32-
# This must remain at the end as we need $base_version and $version defined first.
33-
$package_source = "http://www.rabbitmq.com/releases/rabbitmq-server/v${base_version}/rabbitmq-server-${version}.noarch.rpm"
3427
}
3528
'SUSE': {
3629
$package_ensure = 'installed'
3730
$package_name = 'rabbitmq-server'
3831
$service_name = 'rabbitmq-server'
3932
$package_provider = 'zypper'
4033
$version = '3.1.5-1'
41-
$base_version = regsubst($version,'^(.*)-\d$','\1')
42-
# This must remain at the end as we need $base_version and $version defined first.
43-
$package_source = "http://www.rabbitmq.com/releases/rabbitmq-server/v${base_version}/rabbitmq-server-${version}.noarch.rpm"
4434
}
4535
default: {
4636
fail("The ${module_name} module is not supported on an ${::osfamily} based system.")

0 commit comments

Comments
 (0)