From dad2ae1f98edfddc0b9e7a150bf550d38115d183 Mon Sep 17 00:00:00 2001 From: Justin Lambert Date: Tue, 13 Jan 2015 01:48:20 -0700 Subject: [PATCH] add ability to specify name and provider for sensu-plugin package --- manifests/init.pp | 10 ++++++++++ manifests/package.pp | 14 +++++++++----- spec/classes/sensu_package_spec.rb | 12 ++++++++++++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index f7d0e8c3b2..ba0c39b861 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -9,6 +9,14 @@ # Default: latest # Valid values: absent, installed, latest, present, [\d\.\-]+ # +# [*sensu_plugin_name*] +# String. Name of the sensu-plugin package +# Default: sensu-plugin +# +# [*sensu_plugin_provider*] +# String. Provider used to install the sensu-plugin package +# Default: undef +# # [*sensu_plugin_version*] # String. Version of the sensu-plugin gem to install # Default: absent @@ -187,6 +195,8 @@ # class sensu ( $version = 'latest', + $sensu_plugin_name = 'sensu-plugin', + $sensu_plugin_provider = undef, $sensu_plugin_version = 'absent', $install_repo = true, $repo = 'main', diff --git a/manifests/package.pp b/manifests/package.pp index b38b9a4f54..d60121211a 100644 --- a/manifests/package.pp +++ b/manifests/package.pp @@ -36,14 +36,18 @@ ensure => $sensu::version, } - $gem_provider = $sensu::use_embedded_ruby ? { - true => 'sensu_gem', - default => 'gem', + if $::sensu::sensu_plugin_provider { + $plugin_provider = $::sensu::sensu_plugin_provider + } else { + $plugin_provider = $sensu::use_embedded_ruby ? { + true => 'sensu_gem', + default => 'gem', + } } - package { 'sensu-plugin' : + package { $::sensu::sensu_plugin_name : ensure => $sensu::sensu_plugin_version, - provider => $gem_provider, + provider => $plugin_provider, } file { '/etc/default/sensu': diff --git a/spec/classes/sensu_package_spec.rb b/spec/classes/sensu_package_spec.rb index 4ca0010757..6997193acc 100644 --- a/spec/classes/sensu_package_spec.rb +++ b/spec/classes/sensu_package_spec.rb @@ -35,6 +35,18 @@ ) } end + context 'embeded_ruby' do + let(:params) { { :use_embedded_ruby => true } } + + it { should contain_package('sensu-plugin').with(:provider => 'sensu_gem') } + end + + context 'sensu_plugin_provider and sensu_plugin_name' do + let(:params) { { :sensu_plugin_name => 'rubygem-sensu-plugin', :sensu_plugin_provider => 'rpm' } } + + it { should contain_package('rubygem-sensu-plugin').with(:provider => 'rpm') } + end + context 'repos' do context 'ubuntu' do