From 86b203ba52897820e795eb40b582e63dc2270eff Mon Sep 17 00:00:00 2001 From: Suleyman Kutlu Date: Sat, 28 Mar 2015 12:16:36 +0100 Subject: [PATCH 1/4] Ability to install desired version of NRPE packages instead of latest one ['nrpe']['packages'] is now a Hash. Each package has a version attribute which is nil by default default['nrpe']['packages'] = { 'nagios-nrpe-server' => {'version' => nil}, 'nagios-plugins' => {'version' => nil}, 'nagios-plugins-basic' => {'version' => nil}, 'nagios-plugins-standard' => {'version' => nil} } In your wrapper / role you can define version for any / all of the packages as example below: default!['nrpe']['packages']['nrpe']['version'] = "2.15-2.el#{node['platform_version'][0]}" Default behavious will be the same as before. If version is nil, latest version found in repositories will be installed otherwise requested version will be installed. --- attributes/default.rb | 39 ++++++++++++++++++++++++++++++++++--- metadata.rb | 2 +- recipes/_package_install.rb | 18 ++++++++++++++++- 3 files changed, 54 insertions(+), 5 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 311d914..c09a777 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -70,7 +70,20 @@ default['nrpe']['install_method'] = 'package' default['nrpe']['pid_file'] = '/var/run/nagios/nrpe.pid' default['nrpe']['home'] = '/usr/lib/nagios' - default['nrpe']['packages'] = %w(nagios-nrpe-server nagios-plugins nagios-plugins-basic nagios-plugins-standard) + default['nrpe']['packages'] = { + 'nagios-nrpe-server' => { + 'version' => nil + }, + 'nagios-plugins' => { + 'version' => nil + }, + 'nagios-plugins-basic' => { + 'version' => nil + }, + 'nagios-plugins-standard' => { + 'version' => nil + } + } default['nrpe']['plugin_dir'] = '/usr/lib/nagios/plugins' default['nrpe']['conf_dir'] = '/etc/nagios' if node['kernel']['machine'] == 'i686' @@ -91,7 +104,23 @@ default['nrpe']['install_method'] = 'package' default['nrpe']['install_yum-epel'] = true default['nrpe']['pid_file'] = '/var/run/nrpe.pid' - default['nrpe']['packages'] = %w(nrpe nagios-plugins-disk nagios-plugins-load nagios-plugins-procs nagios-plugins-users) + default['nrpe']['packages'] = { + 'nrpe' => { + 'version' => nil + }, + 'nagios-plugins-disk' => { + 'version' => nil + }, + 'nagios-plugins-load' => { + 'version' => nil + }, + 'nagios-plugins-procs' => { + 'version' => nil + }, + 'nagios-plugins-users' => { + 'version' => nil + } + } if node['kernel']['machine'] == 'i686' default['nrpe']['home'] = '/usr/lib/nagios' default['nrpe']['ssl_lib_dir'] = '/usr/lib' @@ -106,7 +135,11 @@ when 'freebsd' default['nrpe']['install_method'] = 'package' default['nrpe']['pid_file'] = '/var/run/nrpe2/nrpe2.pid' - default['nrpe']['packages'] = %w(nrpe) + default['nrpe']['packages'] = { + 'nrpe' => { + 'version' => nil + } + } default['nrpe']['log_facility'] = 'daemon' default['nrpe']['service_name'] = 'nrpe2' default['nrpe']['conf_dir'] = '/usr/local/etc' diff --git a/metadata.rb b/metadata.rb index 9b83a75..63c9a86 100644 --- a/metadata.rb +++ b/metadata.rb @@ -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.4.13' +version '1.4.13001' recipe 'default', 'Installs and configures a nrpe client' %w(build-essential yum-epel).each do |cb| diff --git a/recipes/_package_install.rb b/recipes/_package_install.rb index 25ab610..855db22 100644 --- a/recipes/_package_install.rb +++ b/recipes/_package_install.rb @@ -30,8 +30,24 @@ end # install the nrpe packages specified in the ['nrpe']['packages'] attribute -node['nrpe']['packages'].each do |pkg| +# +# It is defined as Hash. +# +# In the 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'] = { +# 'nagios-nrpe-server' => {'version' => nil}, +# 'nagios-plugins' => {'version' => nil}, +# '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 +# + +node['nrpe']['packages'].each do |pkg, pkg_details| package pkg do + version pkg_details['version'] unless pkg_details['version'].nil? options node['nrpe']['package']['options'] unless node['nrpe']['package']['options'].nil? end end From e347584f292d441fa5be48af7d2174be1b3159bd Mon Sep 17 00:00:00 2001 From: Suleyman Kutlu Date: Wed, 8 Apr 2015 15:24:18 +0200 Subject: [PATCH 2/4] Correct versioning --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index 63c9a86..4511931 100644 --- a/metadata.rb +++ b/metadata.rb @@ -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.4.13001' +version '1.4.14' recipe 'default', 'Installs and configures a nrpe client' %w(build-essential yum-epel).each do |cb| From e1e9383fb6d0ea00bbdd63d9e0f75e342513a8b2 Mon Sep 17 00:00:00 2001 From: Suleyman Kutlu Date: Fri, 10 Apr 2015 15:11:22 +0200 Subject: [PATCH 3/4] for backward compatibility --- recipes/_package_install.rb | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/recipes/_package_install.rb b/recipes/_package_install.rb index 855db22..caad113 100644 --- a/recipes/_package_install.rb +++ b/recipes/_package_install.rb @@ -31,9 +31,9 @@ # install the nrpe packages specified in the ['nrpe']['packages'] attribute # -# It is defined as Hash. +# For backward compatibility it can be defined as an array or as a Hash. # -# In the 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'] = { @@ -44,10 +44,19 @@ # } # 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 -node['nrpe']['packages'].each do |pkg, pkg_details| - package pkg do - version pkg_details['version'] unless pkg_details['version'].nil? - options node['nrpe']['package']['options'] unless node['nrpe']['package']['options'].nil? +if node['nrpe']['packages'].is_a?(Array) + node['nrpe']['packages'].each do |pkg| + package pkg do + options node['nrpe']['package']['options'] unless node['nrpe']['package']['options'].nil? + end + end +else + node['nrpe']['packages'].each do |pkg, pkg_details| + package pkg do + version pkg_details['version'] unless pkg_details['version'].nil? + options node['nrpe']['package']['options'] unless node['nrpe']['package']['options'].nil? + end end end From e6dba3ac2e8f0f06fc9f3a00ea8465beab0a493a Mon Sep 17 00:00:00 2001 From: Suleyman Kutlu Date: Fri, 10 Apr 2015 15:20:54 +0200 Subject: [PATCH 4/4] explain the change in CHANGELOG.md and make version 1.5 as this is a major(ish) change --- CHANGELOG.md | 15 +++++++++++++++ metadata.rb | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae43da8..e35e6f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,21 @@ This file is used to list changes made in each version of nrpe +## 1.5.0 +* Added ability to define node['nrpe']['packages'] as a Hash to add version information as sample below. + In your environment specific cookbook, this version infomation for each individual package can be overriden + for required versions (instead of latest one). If it is nil it will install latest one from repositories. + + Sample: + default['nrpe']['packages'] = { + 'nagios-nrpe-server' => {'version' => nil}, + 'nagios-plugins' => {'version' => nil}, + 'nagios-plugins-basic' => {'version' => nil}, + 'nagios-plugins-standard' => {'version' => nil} + } + + For backward compatibiility, it will also install packages if it is defined as an array in your env specific cookbook. + # 1.4.12 * Added default['nrpe']['checks'] to store all checks as a node attribute * Removed Ruby 1.9.3 and added Ruby 2.2.0 to Travis diff --git a/metadata.rb b/metadata.rb index 4511931..852d985 100644 --- a/metadata.rb +++ b/metadata.rb @@ -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.4.14' +version '1.5.0' recipe 'default', 'Installs and configures a nrpe client' %w(build-essential yum-epel).each do |cb|