From a4f20599abd5dd6559180ab065bd36594c7f6f3a Mon Sep 17 00:00:00 2001 From: Pavel Yudin Date: Tue, 10 Feb 2015 17:29:47 +0300 Subject: [PATCH 1/4] Adding attribute ['nrpe']['checks'], which stores all configured checks on the node. --- attributes/default.rb | 3 +++ recipes/default.rb | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/attributes/default.rb b/attributes/default.rb index 92f8670..e6156ea 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -61,6 +61,9 @@ # this is mostly true except for centos-70 default['nrpe']['check_action'] = 'reload' +# attribute for storing information about checks on the node +default['nrpe']['checks'] = [] + # platform specific values case node['platform_family'] when 'debian' diff --git a/recipes/default.rb b/recipes/default.rb index 8a58dde..e7a867c 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -75,3 +75,11 @@ action [:start, :enable] supports :restart => true, :reload => true, :status => true end + +# 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) }.map(&:command_name) + node.set['nrpe']['checks'] = checks + end +end From 7a00131d2c9c32f40d8c6b5c13c62244c378ea6f Mon Sep 17 00:00:00 2001 From: Pavel Yudin Date: Thu, 12 Feb 2015 19:46:03 +0300 Subject: [PATCH 2/4] rubocop version changed --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 769029e..42fb0eb 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source 'https://rubygems.org' gem 'berkshelf', '~> 3.2.0' gem 'chefspec', '~> 4.2.0' gem 'foodcritic', '~> 4.0.0' -gem 'rubocop', '~> 0.8.0' +gem 'rubocop', '~> 0.28.0' group :integration do gem 'test-kitchen', '~> 1.3.1' From c83f688fe555a717f5a4f9e60e0da1acf31384f7 Mon Sep 17 00:00:00 2001 From: Pavel Yudin Date: Thu, 12 Feb 2015 20:01:15 +0300 Subject: [PATCH 3/4] ruby 1.9.3 removed, because ohai 8 doesn't support ruby less than 2.0.0. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index db53401..ec7d9cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: ruby rvm: - - 1.9.3 - 2.0.0 - 2.1.1 script: From eeb8c71c73903950a508fd0c693492f5a2979408 Mon Sep 17 00:00:00 2001 From: Pavel Yudin Date: Thu, 12 Feb 2015 21:47:25 +0300 Subject: [PATCH 4/4] I forgot about actions. --- recipes/default.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/default.rb b/recipes/default.rb index e7a867c..6b3c4e8 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -79,7 +79,7 @@ # 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) }.map(&:command_name) + checks = run_context.resource_collection.select { |r| r.is_a?(Chef::Resource::NrpeCheck) && r.action == [:add] }.map(&:command_name) node.set['nrpe']['checks'] = checks end end