OSDN Git Service

add Nagios4 support.
[metasearch/grid-chef-repo.git] / cookbooks / nagios-grid / recipes / nagios-base.rb
index 5f86176..b3f5b4b 100644 (file)
@@ -28,13 +28,20 @@ site_cfg_dir = nil
 nagios_pkgs = nil
 nagios_service = nil
 httpd_service = nil
+tpl_ctx = 'nagios3'
 
 case node['platform_family']
 when 'debian'
   root_cfg_dir = '/etc/nagios3'
+  nagios_service = 'nagios3'
+  if platform == 'ubuntu' && platform_version >= '20.04'
+    root_cfg_dir = '/etc/nagios4'
+    nagios_service = 'nagios4'
+  end
+
   nagios_pkgs = [
     # Note: PHP is not php5 but php7.0 in Ubuntu 16.04 or later
-    'nagios-plugins',
+    'nagios-plugins',  # virtual package -> monitoring-plugins (>= Ubuntu 20.04)
     'nagios-nrpe-plugin',
     'nagios-images',
   ]
@@ -59,7 +66,6 @@ when 'debian'
     nagios_pkgs.push('libapache2-mod-auth-kerb')
   end
 
-  nagios_service = 'nagios3'
   httpd_service = 'apache2'
   httpd_nagios_conf = "#{root_cfg_dir}/apache2.conf"
 when 'rhel'
@@ -139,7 +145,7 @@ end
   'services-generic.cfg',
 ].each {|tpl|
   template "#{base_cfg_dir}/#{tpl}" do
-    source  "etc/nagios3/base/#{tpl}"
+    source  "etc/#{tpl_ctx}/base/#{tpl}"
     owner 'root'
     group 'root'
     mode '0644'
@@ -161,7 +167,7 @@ end
   'checkcommands.cfg',
 ].each {|cfg_file|
   template "#{site_cfg_dir}/#{cfg_file}" do
-    source "etc/nagios3/site/#{cfg_file}"
+    source "etc/#{tpl_ctx}/site/#{cfg_file}"
     owner 'root'
     group 'root'
     mode '0644'