Skip to content

Commit

Permalink
Merge pull request #264 from dhgwilliam/master
Browse files Browse the repository at this point in the history
add support for insecure HTTPS in sensu::plugin
  • Loading branch information
jlambert121 committed Nov 14, 2014
2 parents 4f48887 + 2633b50 commit a37c512
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 21 deletions.
32 changes: 19 additions & 13 deletions manifests/plugin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,21 @@
# Default: latest
# Valid values: absent, installed, latest, present, [\d\.\-]+
#
# [*nocheckcertificate*]
# Boolean. When using url source, disable certificate checking for HTTPS
# Default: false
# Valid values: true, false
define sensu::plugin(
$type = 'file',
$install_path = '/etc/sensu/plugins',
$purge = true,
$recurse = true,
$force = true,
$pkg_version = 'latest',
$type = 'file',
$install_path = '/etc/sensu/plugins',
$purge = true,
$recurse = true,
$force = true,
$pkg_version = 'latest',
$nocheckcertificate = false,
){

validate_bool($purge, $recurse, $force)
validate_bool($purge, $recurse, $force, $nocheckcertificate)
validate_re($pkg_version, ['^absent$', '^installed$', '^latest$', '^present$', '^[\d\.\-]+$'], "Invalid package version: ${pkg_version}")
validate_re($type, ['^file$', '^url$', '^package$', '^directory$'], "Invalid plugin type: ${type}")

Expand All @@ -56,7 +61,7 @@
recurse => $recurse,
force => $force,
}

file { "${install_path}/${filename}":
ensure => file,
mode => '0555',
Expand All @@ -74,11 +79,12 @@
force => $force,
}

wget::fetch { $name :
destination => "${install_path}/${filename}",
timeout => 0,
verbose => false,
require => File[$install_path],
wget::fetch { $name:
destination => "${install_path}/${filename}",
timeout => 0,
verbose => false,
nocheckcertificate => $nocheckcertificate,
require => File[$install_path],
} ->
file { "${install_path}/${filename}":
ensure => file,
Expand Down
32 changes: 24 additions & 8 deletions spec/defines/sensu_plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
context 'defaults' do

it { should contain_file('/etc/sensu/plugins/plug1').with(
'source' => 'puppet:///data/plug1'
'source' => 'puppet:///data/plug1'
) }
end

Expand All @@ -18,7 +18,7 @@
} }

it { should contain_file('/var/sensu/plugins/plug1').with(
'source' => 'puppet:///data/plug1'
'source' => 'puppet:///data/plug1'
) }
end
end #file
Expand All @@ -28,21 +28,22 @@

context 'defaults' do
let(:params) { {
:type => 'url',
:type => 'url',
} }

it { should contain_wget__fetch('https://raw.githubusercontent.com/sensu/sensu-community-plugins/master/plugins/system/check-mem.sh').with(
'destination' => '/etc/sensu/plugins/check-mem.sh',
'verbose' => 'false',
'timeout' => '0'
'destination' => '/etc/sensu/plugins/check-mem.sh',
'verbose' => 'false',
'timeout' => '0',
'nocheckcertificate' => 'false'
) }

end

context 'setting params' do
let(:params) { {
:type => 'url',
:install_path => '/var/sensu/plugins'
:type => 'url',
:install_path => '/var/sensu/plugins'
} }

it { should contain_wget__fetch('https://raw.githubusercontent.com/sensu/sensu-community-plugins/master/plugins/system/check-mem.sh').with(
Expand All @@ -53,6 +54,21 @@

end

context 'nocheckcertificate' do
let(:params) { {
:type => 'url',
:nocheckcertificate => true,
} }

it { should contain_wget__fetch('https://raw.githubusercontent.com/sensu/sensu-community-plugins/master/plugins/system/check-mem.sh').with(
'destination' => '/etc/sensu/plugins/check-mem.sh',
'verbose' => 'false',
'timeout' => '0',
'nocheckcertificate' => 'true'
) }

end

end #url

context 'directory' do
Expand Down

0 comments on commit a37c512

Please sign in to comment.