Skip to content

Commit

Permalink
Merge pull request #56 from jvanlieshout/master
Browse files Browse the repository at this point in the history
use_inline_resources breaks this cookbook on chef11 and older chef12 clients
  • Loading branch information
sbotman authored Aug 12, 2016
2 parents 052b179 + 818a39d commit d5a6bb6
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
AllCops:
Include:
- Berksfile
- Gemfile
- Rakefile

Metrics/LineLength:
Max: 120
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
license 'Apache 2.0'
description 'Installs and configures Nagios NRPE client'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '1.6.0'
version '1.6.1'
issues_url 'https://github.com/schubergphilis/nrpe/issues' if respond_to?(:issues_url)
source_url 'https://github.com/schubergphilis/nrpe' if respond_to?(:source_url)
chef_version '>= 11.0' if respond_to?(:chef_version)
Expand Down
17 changes: 17 additions & 0 deletions providers/check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ def whyrun_supported?

config_file = "#{node['nrpe']['conf_dir']}/nrpe.d/#{new_resource.command_name}.cfg"

begin
_r = run_context.resource_collection.find("service[#{node['nrpe']['service_name']}]")
rescue Chef::Exceptions::ResourceNotFound
service node['nrpe']['service_name'] do
action :nothing
end
end

if new_resource.template
unless new_resource.command.nil?
raise 'You cannot specify command and template!'
Expand Down Expand Up @@ -60,6 +68,15 @@ def whyrun_supported?

action :remove do
config_file = "#{node['nrpe']['conf_dir']}/nrpe.d/#{new_resource.command_name}.cfg"

begin
_r = run_context.resource_collection.find("service[#{node['nrpe']['service_name']}]")
rescue Chef::Exceptions::ResourceNotFound
service node['nrpe']['service_name'] do
action :nothing
end
end

if ::File.exist?(config_file)
Chef::Log.info "Removing #{new_resource.command_name} from #{node['nrpe']['conf_dir']}/nrpe.d/"
f = file config_file do
Expand Down
6 changes: 4 additions & 2 deletions recipes/_package_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
#
# For backward compatibility it can be defined as an array or as a Hash.
#
# If it is defined as a hash, by default versions for each packages is nil. So it will install the latest one available in repositories.
# If it is defined as a hash, by default versions for each packages is nil. So it will install the
# latest one available in repositories.
#
# By default followings are defined and can be adjusted for your tate in your wrapper cookbook
# default['nrpe']['packages'] = {
Expand All @@ -39,7 +40,8 @@
# 'nagios-plugins-basic' => {'version' => nil},
# 'nagios-plugins-standard' => {'version' => nil}
# }
# These version information can be overriden in your environment specific attributes so you can intall any version you prefer
# These version information can be overriden in your environment specific attributes so you can intall
# any version you prefer
#
# In case of defining as an array, it is as usual. It will install latest version found in repositories

Expand Down
4 changes: 3 additions & 1 deletion recipes/configure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@
# The updating of the list of checks.
ruby_block 'updating of the list of checks' do
block do
checks = run_context.resource_collection.select { |r| r.is_a?(Chef::Resource::NrpeCheck) && r.action == [:add] }.map(&:command_name)
checks = run_context.resource_collection.select do |r|
r.is_a?(Chef::Resource::NrpeCheck) && r.action == [:add]
end.map(&:command_name)
node.default['nrpe']['checks'] = checks
end
end

0 comments on commit d5a6bb6

Please sign in to comment.