OSDN Git Service

adds the latest Debian and Ubuntu support. nagios-grid-0.1.3
authorwhitestar <whitestar@gaea.test>
Sun, 2 Jul 2017 00:43:01 +0000 (09:43 +0900)
committerwhitestar <whitestar@gaea.test>
Sun, 2 Jul 2017 00:43:01 +0000 (09:43 +0900)
cookbooks/nagios-grid/.foodcritic [new file with mode: 0644]
cookbooks/nagios-grid/.rubocop.yml
cookbooks/nagios-grid/CHANGELOG.md
cookbooks/nagios-grid/Gemfile
cookbooks/nagios-grid/Rakefile
cookbooks/nagios-grid/concourse.yml [new file with mode: 0644]
cookbooks/nagios-grid/fly-vars.yml [new file with mode: 0644]
cookbooks/nagios-grid/metadata.rb
cookbooks/nagios-grid/recipes/nagios-base.rb
cookbooks/nagios-grid/recipes/nagios-nrpe-server.rb

diff --git a/cookbooks/nagios-grid/.foodcritic b/cookbooks/nagios-grid/.foodcritic
new file mode 100644 (file)
index 0000000..3907cff
--- /dev/null
@@ -0,0 +1 @@
+~FC001
index 17f87f1..83458f1 100644 (file)
@@ -24,11 +24,15 @@ Style/RescueModifier:
   Enabled: false
 Style/SpaceBeforeFirstArg:
   Enabled: false
+Style/SpaceInsideBlockBraces:
+  Enabled: false
+Style/SpaceInsidePercentLiteralDelimiters:
+  Enabled: false
 Style/TrailingCommaInLiteral:
-  EnforcedStyleForMultiline: comma
+  EnforcedStyleForMultiline: consistent_comma
 Style/WordArray:
   Enabled: false
-  
+
 #Style/AccessorMethodName:
 #  Enabled: false
 #Style/MethodLength:
index f79a76c..11b4906 100644 (file)
@@ -1,6 +1,11 @@
 nagios-grid CHANGELOG
 =====================
 
+0.1.3
+-----
+- adds the Debian 9 (stretch) support.
+- adds the Ubuntu 17.04 support.
+
 0.1.2
 -----
 - adds the `check_mem.pl` plugin support.
index 907b097..ad84be7 100644 (file)
@@ -1,3 +1,4 @@
 source 'https://rubygems.org'
 
-#gem 'foodcritic'
+# with Chef DK
+gem 'stove'
index b05b9e3..64191a5 100644 (file)
@@ -1,16 +1,20 @@
 require 'rspec/core/rake_task'
 require 'rubocop/rake_task'
 require 'foodcritic'
+require 'stove/rake_task'
 
 namespace :style do
   desc 'Run Ruby style checks'
-  RuboCop::RakeTask.new(:ruby)
+  RuboCop::RakeTask.new(:ruby) do |t|
+    t.options = [
+      '--auto-gen-config',  # creates .rubocop_todo.yml
+    ]
+  end
 
   desc 'Run Chef style checks'
   FoodCritic::Rake::LintTask.new(:chef) do |t|
     t.options = {
       fail_tags: ['any'],
-      tags: ['~FC001'],
     }
   end
 end
@@ -21,4 +25,17 @@ task style: ['style:chef', 'style:ruby']
 desc 'Run ChefSpec examples'
 RSpec::Core::RakeTask.new(:spec)
 
+desc 'Publish cookbook'
+Stove::RakeTask.new(:publish) do |t|
+  t.stove_opts = [
+    # `--username` and `--key` are set in ~/.stove typically.
+    #'--username', 'somebody',
+    #'--key', '~/chef/chef.io.example.com/somebody.pem',
+    #'--endpoint', 'https://supermarket.io.example.com/api/v1',  # default: supermarket.chef.io
+    #'--no-ssl-verify',
+    '--no-git',
+    '--log-level', 'info',
+  ]
+end
+
 task default: ['style', 'spec']
diff --git a/cookbooks/nagios-grid/concourse.yml b/cookbooks/nagios-grid/concourse.yml
new file mode 100644 (file)
index 0000000..dae162c
--- /dev/null
@@ -0,0 +1,56 @@
+---
+# $ fly -t target sp -p nagios-grid-cookbook -c concourse.yml -l fly-vars.yml -l ~/credentials.yml
+resources:
+- name: src-git
+  type: git
+  source:
+    uri: git://git.osdn.net/gitroot/metasearch/grid-chef-repo.git
+    branch: master
+    paths:
+    - cookbooks/((cookbook-name))
+- name: chefdk-cache
+  type: docker-image
+  source:
+    repository: chef/chefdk
+    tag: ((chefdk-version))
+    # ((param)) style: fly >= 3.2.0
+    registry_mirror: https://((registry-mirror-domain))  # e.g. https://registry.docker.example.com:5000
+    ca_certs:
+    - domain: ((registry-mirror-domain))  # e.g. registry.docker.example.com:5000
+      cert: ((docker-reg-ca-cert))
+
+jobs:
+- name: build-cookbook
+  plan:
+  - get: src-git
+    trigger: true
+  - get: chefdk-cache
+  - task: ci-build
+    image: chefdk-cache
+    config:
+      platform: linux
+
+      #image_resource:
+      #  type: docker-image
+      #  source:
+      #    repository: chef/chefdk
+      #    tag: ((chefdk-version))
+          # NG, setting disable
+          #registry_mirror: https://((registry-mirror-domain))
+          #ca_certs:
+          #- domain: ((registry-mirror-domain))
+          #  cert: ((docker-reg-ca-cert))
+
+      inputs:
+      - name: src-git
+
+      run:
+        #dir: ./src-git/cookbooks/((cookbook-name))
+        #path: rake
+        path: /bin/bash
+        args:
+        - -c
+        - |
+          cd ./src-git/cookbooks/((cookbook-name))
+          bundle install
+          rake
diff --git a/cookbooks/nagios-grid/fly-vars.yml b/cookbooks/nagios-grid/fly-vars.yml
new file mode 100644 (file)
index 0000000..88ce16f
--- /dev/null
@@ -0,0 +1,3 @@
+---
+cookbook-name: nagios-grid
+chefdk-version: 1.4.3
index 7417350..f60a674 100644 (file)
@@ -5,7 +5,7 @@ maintainer_email ''
 license          'Apache 2.0'
 description      'Installs/Configures nagios-grid'
 long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
-version          '0.1.2'
+version          '0.1.3'
 source_url       'http://scm.osdn.jp/gitroot/metasearch/grid-chef-repo.git'
 issues_url       'https://osdn.jp/projects/metasearch/ticket'
 
@@ -13,7 +13,5 @@ issues_url       'https://osdn.jp/projects/metasearch/ticket'
   supports os
 end
 
-# local cookbooks
-
-# external cookbooks
+chef_version     '>= 12'
 depends          'yum-epel'
index 983affd..3c517a3 100644 (file)
@@ -17,6 +17,9 @@
 # limitations under the License.
 #
 
+platform = node['platform']
+platform_version = node['platform_version']
+
 root_cfg_dir = nil
 base_cfg_dir = nil
 site_cfg_dir = nil
@@ -29,12 +32,18 @@ when 'debian'
   root_cfg_dir = '/etc/nagios3'
   nagios_pkgs = [
     # Note: PHP is not php5 but php7.0 in Ubuntu 16.04 or later
-    'nagios3',
     'nagios-plugins',
     'nagios-images',
   ]
-  if node['nagios']['with_pnp4nagios'] && node['platform'] == 'debian'
-    # this recipe does not support pnp4nagios on Ubuntu!
+
+  unless platform == 'debian' && platform_version >= '9.0'
+    nagios_pkgs += [
+      'nagios3',
+    ]
+  end
+
+  if node['nagios']['with_pnp4nagios'] && platform == 'debian' && platform_version < '9.0'
+    # this recipe does not support pnp4nagios on Ubuntu and the latest Debian !
     nagios_pkgs += [
       # Debian and Ubuntu 15.10, 14.04, 12.04 only.
       'pnp4nagios',
@@ -42,9 +51,11 @@ when 'debian'
       'pnp4nagios-web-config-nagios3',
     ]
   end
+
   if node['nagios']['web']['AuthType'] == 'Kerberos'
     nagios_pkgs.push('libapache2-mod-auth-kerb')
   end
+
   nagios_service = 'nagios3'
   httpd_service = 'apache2'
   httpd_nagios_conf = "#{root_cfg_dir}/apache2.conf"
@@ -54,19 +65,23 @@ when 'rhel'
     'nagios',
     'nagios-plugins',
   ]
+
   nagios_pkgs += \
     %w(load users ping ssh ntp http disk swap procs file_age).map {|item|
       "nagios-plugins-#{item}"
     }
+
   if node['nagios']['with_pnp4nagios']
     include_recipe 'yum-epel'
     nagios_pkgs += [
       'pnp4nagios',
     ]
   end
+
   if node['nagios']['web']['AuthType'] == 'Kerberos'
     nagios_pkgs.push('mod_auth_kerb')
   end
+
   nagios_service = 'nagios'
   httpd_service = 'httpd'
   httpd_nagios_conf = '/etc/httpd/conf.d/nagios.conf'
index 04ebfb9..6476669 100644 (file)
 # limitations under the License.
 #
 
-[
+platform = node['platform']
+platform_version = node['platform_version']
+
+pkgs = [
   'nagios-nrpe-server',
   'nagios-plugins',
   'nagios-plugins-contrib',  # for check_memory
-  'libnagios-plugin-perl',   # for check_memory
-].each {|pkg|
+]
+
+if (platform == 'debian' && platform_version < '9.0') \
+  || (platform == 'ubuntu' && platform_version < '17.04')
+  pkgs += ['libnagios-plugin-perl']  # for check_memory
+end
+
+pkgs.each {|pkg|
   resources(package: pkg) rescue package pkg do
     action :install
   end