From c56f338431a0277b183ef055ada7410f54f2766a Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Mon, 15 Dec 2014 16:03:39 -0800 Subject: [PATCH] (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. --- README.md | 11 +++++++++++ manifests/init.pp | 18 +++++++++++++++++- manifests/install.pp | 2 +- manifests/params.pp | 10 ---------- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 01ce41638..2176a6a90 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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. diff --git a/manifests/init.pp b/manifests/init.pp index 7fba34615..f145d90c0 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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, @@ -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' diff --git a/manifests/install.pp b/manifests/install.pp index 65675ac75..f2df83aa0 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -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, diff --git a/manifests/params.pp b/manifests/params.pp index 574a7d539..e3b87b24f 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -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': { @@ -28,9 +24,6 @@ $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' @@ -38,9 +31,6 @@ $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.")