From 0c792d27759f561cc7c8252ecc63fe13c419dcf7 Mon Sep 17 00:00:00 2001 From: Yanis Guenane Date: Thu, 31 Jul 2014 15:38:16 -0400 Subject: [PATCH] sensu-plugin: Allow one to install the gem This PR aims to allow an administrator to decide to install the sensu-plugin gem or not. --- manifests/init.pp | 7 +++++++ manifests/package.pp | 5 +++++ spec/classes/sensu_package_spec.rb | 8 +++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 31bb64bc69..80f6693f6d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -9,6 +9,11 @@ # Default: latest # Valid values: absent, installed, latest, present, [\d\.\-]+ # +# [*sensu_plugin_version*] +# String. Version of the sensu-plugin gem to install +# Default: absent +# Valid values: absent, installed, latest, present, [\d\.\-]+ +# # [*install_repo*] # Boolean. Whether or not to install the sensu repo # Default: true @@ -180,6 +185,7 @@ # class sensu ( $version = 'latest', + $sensu_plugin_version = 'absent', $install_repo = true, $repo = 'main', $repo_source = undef, @@ -227,6 +233,7 @@ validate_re($repo, ['^main$', '^unstable$'], "Repo must be 'main' or 'unstable'. Found: ${repo}") validate_re($version, ['^absent$', '^installed$', '^latest$', '^present$', '^[\d\.\-]+$'], "Invalid package version: ${version}") + validate_re($sensu_plugin_version, ['^absent$', '^installed$', '^latest$', '^present$', '^[\d\.\-]+$'], "Invalid sensu-plugin package version: ${sensu_plugin_version}") validate_re($log_level, ['^debug$', '^info$', '^warn$', '^error$', '^fatal$'] ) if !is_integer($rabbitmq_port) { fail('rabbitmq_port must be an integer') } if !is_integer($redis_port) { fail('redis_port must be an integer') } diff --git a/manifests/package.pp b/manifests/package.pp index 30257ac2b3..b485a9e181 100644 --- a/manifests/package.pp +++ b/manifests/package.pp @@ -26,6 +26,11 @@ ensure => $sensu::version, } + package { 'sensu-plugin' : + ensure => $sensu::sensu_plugin_version, + provider => 'gem', + } + file { '/etc/default/sensu': ensure => file, content => template("${module_name}/sensu.erb"), diff --git a/spec/classes/sensu_package_spec.rb b/spec/classes/sensu_package_spec.rb index 01641a4172..bb39a90946 100644 --- a/spec/classes/sensu_package_spec.rb +++ b/spec/classes/sensu_package_spec.rb @@ -21,12 +21,18 @@ context 'setting version' do let(:params) { { - :version => '0.9.10', + :version => '0.9.10', + :sensu_plugin_version => 'installed', } } it { should contain_package('sensu').with( :ensure => '0.9.10' ) } + + it { should contain_package('sensu-plugin').with( + :ensure => 'installed', + :provider => 'gem' + ) } end context 'repos' do