-
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.
(#463) Ensure sensu::plugins are managed before checks
Without this patch plugins may be managed after the checks which use them. This patch addresses the problem by adding a well known inert resource named `Anchor[plugins_before_checks]`. The sensu::check and sensu_check_config type are managed after this anchor. The sensu::plugin defined type is managed before this anchor. The anchor approach has been implemented over collections to avoid realizing resources which the end user may be using. Resolves #463
- Loading branch information
1 parent
c2b013b
commit a1b12b6
Showing
9 changed files
with
79 additions
and
17 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
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
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
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
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
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
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 |
---|---|---|
|
@@ -13,7 +13,6 @@ class { '::sensu': | |
let(:title) { 'puppet:///data/plug1' } | ||
|
||
context 'defaults' do | ||
|
||
it { should contain_file('/etc/sensu/plugins/plug1').with( | ||
:source => 'puppet:///data/plug1' | ||
) } | ||
|
@@ -28,7 +27,7 @@ class { '::sensu': | |
:source => 'puppet:///data/plug1' | ||
) } | ||
end | ||
end #file | ||
end | ||
|
||
context 'url' do | ||
let(:title) { 'https://raw.githubusercontent.com/sensu/sensu-community-plugins/master/plugins/system/check-mem.sh' } | ||
|
@@ -44,7 +43,6 @@ class { '::sensu': | |
:path => '/etc/sensu/plugins/check-mem.sh', | ||
:checksum => '1d58b78e9785f893889458f8e9fe8627' | ||
) } | ||
|
||
end | ||
|
||
context 'setting params' do | ||
|
@@ -59,7 +57,6 @@ class { '::sensu': | |
:path => '/var/sensu/plugins/check-mem.sh', | ||
:checksum => '1d58b78e9785f893889458f8e9fe8627' | ||
) } | ||
|
||
end | ||
|
||
context 'new plugin should provide source' do | ||
|
@@ -74,10 +71,8 @@ class { '::sensu': | |
:path => '/var/sensu/plugins/check-puppet-last-run.rb', | ||
:source => 'https://raw.githubusercontent.com/sensu-plugins/sensu-plugins-puppet/master/bin/check-puppet-last-run.rb' | ||
) } | ||
|
||
end | ||
|
||
end #url | ||
end | ||
|
||
context 'directory' do | ||
let(:title) { 'puppet:///data/sensu/plugins' } | ||
|
@@ -115,7 +110,7 @@ class { '::sensu': | |
'group' => 'sensu' | ||
) } | ||
end | ||
end #directory | ||
end | ||
|
||
context 'package' do | ||
let(:title) { 'sensu-plugins' } | ||
|
@@ -162,12 +157,34 @@ class { '::sensu': | |
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 | ||
end | ||
|
||
context 'default' do | ||
let(:params) { { :type => 'unknown' } } | ||
it { expect { should raise_error(Puppet::Error) } } | ||
end #default | ||
end | ||
|
||
describe 'ordering (#463)' do | ||
let(:pre_condition) do | ||
<<-'ENDofPUPPETcode' | ||
class { '::sensu': | ||
manage_plugins_dir => false, | ||
} | ||
sensu::check { 'ntp': | ||
command => 'check_ntp_time -H pool.ntp.org -w 30 -c 60', | ||
handlers => 'default', | ||
subscribers => 'sensu-test', | ||
} | ||
ENDofPUPPETcode | ||
end | ||
let(:title) { 'puppet:///data/plug1' } | ||
describe 'notifies the sensu-client service' do | ||
let(:expected) { { notify: ['Service[sensu-client]'] } } | ||
it { is_expected.to contain_sensu__plugin(title).with(expected)} | ||
end | ||
describe 'comes before sensu checks via Anchor[plugins_before_checks]' do | ||
let(:expected) { { before: ['Anchor[plugins_before_checks]'] } } | ||
it { is_expected.to contain_sensu__plugin(title).with(expected)} | ||
end | ||
end | ||
end |
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
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