Skip to content

Commit

Permalink
Merge pull request #740 from Phil-Friderici/GH-599
Browse files Browse the repository at this point in the history
(GH-599) Pass gem_install_options to sensu::plugin class
  • Loading branch information
ghoneycutt authored Jul 13, 2017
2 parents b2cfd3d + bc3c755 commit 3bea31b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 12 deletions.
39 changes: 27 additions & 12 deletions manifests/plugin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,25 @@
# Boolean. When using url source, disable certificate checking for HTTPS
# Default: false
# Valid values: true, false
#
# [*gem_install_options*]
# Optional configuration to use for the installation of the
# sensu plugin gem with sensu_gem provider.
# See: https://docs.puppetlabs.com/references/latest/type.html#package-attribute-install_options
# Default: $::sensu::gem_install_options
# Example value: [{ '-p' => 'http://user:[email protected]:8080' }]
#
define sensu::plugin (
$type = 'file',
$install_path = '/etc/sensu/plugins',
$purge = true,
$recurse = true,
$force = true,
$pkg_version = 'latest',
$pkg_provider = $::sensu::sensu_plugin_provider,
$pkg_checksum = undef,
$nocheckcertificate = false,
$type = 'file',
$install_path = '/etc/sensu/plugins',
$purge = true,
$recurse = true,
$force = true,
$pkg_version = 'latest',
$pkg_provider = $::sensu::sensu_plugin_provider,
$pkg_checksum = undef,
$nocheckcertificate = false,
$gem_install_options = $::sensu::gem_install_options,
) {

File {
Expand Down Expand Up @@ -126,10 +135,16 @@
require => Package[$sensu::package::pkg_title],
}
}
'package': {
'package': {
$gem_install_options_real = $pkg_provider ? {
'gem' => $gem_install_options,
default => undef,
}

package { $name:
ensure => $pkg_version,
provider => $pkg_provider,
ensure => $pkg_version,
provider => $pkg_provider,
install_options => $gem_install_options_real,
}
}
default: {
Expand Down
20 changes: 20 additions & 0 deletions spec/defines/sensu_plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ class { '::sensu':
let(:params) { { :type => 'package' } }

it { should contain_package('sensu-plugins').with_ensure('latest') }

it do
should contain_package('sensu-plugins').with({
'ensure' => 'latest',
'provider' => nil,
'install_options' => nil,
})
end
end

context 'set pkg_version' do
Expand All @@ -143,6 +151,18 @@ class { '::sensu':

it { should contain_package('sensu-plugins').with_provider(nil) }
end

# without pkg_provider => gem gem_install_options will be ignored
context 'set gem_install_options' do
let(:params) { { :type => 'package', :gem_install_options => [{ '-p' => 'http://user:[email protected]:8080' }] } }
it { should contain_package('sensu-plugins').with_install_options(nil) }
end

context 'set gem_install_options and pkg_provider = gem' do
let(:params) { { :type => 'package', :gem_install_options => [{ '-p' => 'http://user:[email protected]:8080' }], :pkg_provider => 'gem' } }
it { should contain_package('sensu-plugins').with_install_options([{ '-p' => 'http://user:[email protected]:8080' }]) }
end

end #package

context 'default' do
Expand Down

0 comments on commit 3bea31b

Please sign in to comment.