-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
(GH-599) Pass gem_install_options to sensu::plugin class
- Loading branch information
Showing
2 changed files
with
47 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
|
@@ -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: { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|