• R/O
  • HTTP
  • SSH
  • HTTPS

grid-chef-repo: Commit

Grid環境構築用のChefリポジトリです。


Commit MetaInfo

Revision9bfd3301f95cb5896612a5772060202c0680bba6 (tree)
Time2018-10-06 20:32:04
Authorwhitestar <whitestar@user...>
Commiterwhitestar

Log Message

adds workaround for check_all_disks command failure.

Change Summary

Incremental Difference

--- /dev/null
+++ b/cookbooks/nagios-grid/Berksfile
@@ -0,0 +1,19 @@
1+#
2+# Copyright 2018 whitestar
3+#
4+# Licensed under the Apache License, Version 2.0 (the "License");
5+# you may not use this file except in compliance with the License.
6+# You may obtain a copy of the License at
7+#
8+# http://www.apache.org/licenses/LICENSE-2.0
9+#
10+# Unless required by applicable law or agreed to in writing, software
11+# distributed under the License is distributed on an "AS IS" BASIS,
12+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+# See the License for the specific language governing permissions and
14+# limitations under the License.
15+#
16+
17+source 'https://supermarket.chef.io'
18+
19+metadata
--- a/cookbooks/nagios-grid/CHANGELOG.md
+++ b/cookbooks/nagios-grid/CHANGELOG.md
@@ -1,6 +1,10 @@
11 nagios-grid CHANGELOG
22 =====================
33
4+0.1.4
5+-----
6+- adds workaround for `check_all_disks` command failure.
7+
48 0.1.3
59 -----
610 - adds the Debian 9 (stretch) support.
--- /dev/null
+++ b/cookbooks/nagios-grid/Gemfile.lock
@@ -0,0 +1,22 @@
1+GEM
2+ remote: https://rubygems.org/
3+ specs:
4+ chef-api (0.8.0)
5+ logify (~> 0.1)
6+ mime-types
7+ logify (0.2.0)
8+ mime-types (3.2.2)
9+ mime-types-data (~> 3.2015)
10+ mime-types-data (3.2018.0812)
11+ stove (6.0.0)
12+ chef-api (~> 0.5)
13+ logify (~> 0.2)
14+
15+PLATFORMS
16+ ruby
17+
18+DEPENDENCIES
19+ stove
20+
21+BUNDLED WITH
22+ 1.16.0
--- a/cookbooks/nagios-grid/README.md
+++ b/cookbooks/nagios-grid/README.md
@@ -101,7 +101,7 @@ None.
101101 - Author:: whitestar at osdn.jp
102102
103103 ```text
104-Copyright 2016-2017, whitestar
104+Copyright 2016-2018, whitestar
105105
106106 Licensed under the Apache License, Version 2.0 (the "License");
107107 you may not use this file except in compliance with the License.
--- a/cookbooks/nagios-grid/Rakefile
+++ b/cookbooks/nagios-grid/Rakefile
@@ -3,12 +3,58 @@ require 'rubocop/rake_task'
33 require 'foodcritic'
44 require 'stove/rake_task'
55
6+tpl_cookbook = '00cookbook'
7+cookbook_name = File.basename(Dir.pwd)
8+
9+desc 'Initialize project'
10+task :init do
11+ next if cookbook_name == tpl_cookbook
12+
13+ [
14+ '.foodcritic',
15+ '.rubocop.yml',
16+ 'Berksfile',
17+ 'chefignore',
18+ 'concourse.yml',
19+ 'fly-vars.yml',
20+ 'fly-vars.local.yml',
21+ 'Gemfile',
22+ 'Gemfile.lock',
23+ 'version',
24+ ].each {|conf|
25+ sh "cp ../#{tpl_cookbook}/#{conf} ./" unless File.exist?(conf)
26+ }
27+
28+ ruby [
29+ %(-pne '$_.gsub!(/^cookbook-name: .*$/, "cookbook-name: #{cookbook_name}")'),
30+ '-i fly-vars.local.yml',
31+ ].join(' ')
32+end
33+
34+desc 'Update project'
35+task :update do
36+ next if cookbook_name == tpl_cookbook
37+
38+ [
39+ 'Rakefile',
40+ 'chefignore',
41+ 'concourse.yml',
42+ 'fly-vars.yml',
43+ 'Gemfile',
44+ 'Gemfile.lock',
45+ ].each {|conf|
46+ sh "cp ../#{tpl_cookbook}/#{conf} ./"
47+ }
48+end
49+
50+desc 'fly set-pipeline'
651 task :'set-pipeline' do
752 sh [
8- "fly -t $CC_TARGET sp -p #{File.basename(Dir.pwd)}-cookbook -c concourse.yml",
9- '-l fly-vars.yml -l ~/sec/credentials-prod.yml',
53+ "fly -t $CC_TARGET sp -p #{cookbook_name}-cookbook -c concourse.yml",
54+ '-l fly-vars.yml -l fly-vars.local.yml -l ~/sec/credentials-prod.yml',
1055 ].join(' ')
1156 end
57+desc 'rake set-pipeline alias'
1258 task sp: 'set-pipeline'
1359
1460 namespace :style do
--- /dev/null
+++ b/cookbooks/nagios-grid/chefignore
@@ -0,0 +1,20 @@
1+# Put files/directories that should be ignored in this file.
2+# Lines that start with '# ' are comments.
3+
4+Berksfile.lock
5+
6+# concourse
7+concourse.yml
8+fly-vars.yml
9+fly-vars.local.yml
10+
11+# emacs
12+*~
13+
14+.rubocop_todo.yml
15+
16+# vim
17+*.sw[a-z]
18+
19+# subversion
20+*/.svn/*
--- a/cookbooks/nagios-grid/concourse.yml
+++ b/cookbooks/nagios-grid/concourse.yml
@@ -1,13 +1,15 @@
11 ---
2-# $ fly -t $CC_TARGET sp -p nagios-grid-cookbook -c concourse.yml -l fly-vars.yml -l ~/credentials.yml
32 resources:
43 - name: src-git
54 type: git
65 source:
7- uri: git://git.osdn.net/gitroot/metasearch/grid-chef-repo.git
6+ uri: ((git-id-osdn))@git.osdn.net:/gitroot/metasearch/grid-chef-repo.git
87 branch: master
98 paths:
109 - cookbooks/((cookbook-name))
10+ private_key: ((git-private-key))
11+ git_user: ((git-user-osdn))
12+ #check_every: 1h # default: 1m
1113 - name: chefdk-cache
1214 type: docker-image
1315 source:
@@ -18,18 +20,24 @@ resources:
1820 ca_certs:
1921 - domain: ((registry-mirror-domain)) # e.g. registry.docker.example.com:5000
2022 cert: ((docker-reg-ca-cert))
23+ check_every: 6h # default: 1m
2124
2225 jobs:
23-- name: build-cookbook
26+- name: test-cookbook
2427 plan:
25- - get: src-git
26- trigger: true
27- - get: chefdk-cache
28+ - aggregate:
29+ - get: src-git
30+ params:
31+ depth: 5
32+ trigger: true
33+ - get: chefdk-cache
2834 - task: ci-build
2935 image: chefdk-cache
36+ params:
37+ http_proxy: ((http-proxy)) # e.g. http://proxy.example.com:3128
38+ #HTTP_PROXY: ((http-proxy))
3039 config:
3140 platform: linux
32-
3341 #image_resource:
3442 # type: docker-image
3543 # source:
@@ -40,10 +48,8 @@ jobs:
4048 #ca_certs:
4149 #- domain: ((registry-mirror-domain))
4250 # cert: ((docker-reg-ca-cert))
43-
4451 inputs:
4552 - name: src-git
46-
4753 run:
4854 #dir: ./src-git/cookbooks/((cookbook-name))
4955 #path: rake
@@ -55,3 +61,41 @@ jobs:
5561 bundle config --local silence_root_warning 1
5662 bundle install
5763 rake
64+- name: publish-cookbook
65+ plan:
66+ - aggregate:
67+ - get: src-git
68+ params:
69+ depth: 5
70+ trigger: false
71+ passed: [test-cookbook]
72+ - get: chefdk-cache
73+ passed: [test-cookbook]
74+ - task: publish
75+ image: chefdk-cache
76+ params:
77+ http_proxy: ((http-proxy))
78+ chef_username: ((chef-username))
79+ chef_client_key: ((chef-client-key))
80+ config:
81+ platform: linux
82+ inputs:
83+ - name: src-git
84+ run:
85+ path: /bin/bash
86+ args:
87+ - -c
88+ - |
89+ echo '{"username":"((chef-username))","key":"/root/chef-client-key.pem"}' > /root/.stove
90+ echo "$chef_client_key" > /root/chef-client-key.pem
91+ cd ./src-git/cookbooks/((cookbook-name))
92+ bundle config --local silence_root_warning 1
93+ bundle install
94+ rake publish
95+ - put: src-git
96+ params:
97+ repository: src-git
98+ tag_prefix: ((cookbook-name))-
99+ tag: src-git/cookbooks/((cookbook-name))/version
100+ only_tag: true
101+ annotate: src-git/cookbooks/((cookbook-name))/version
--- /dev/null
+++ b/cookbooks/nagios-grid/fly-vars.local.yml
@@ -0,0 +1,2 @@
1+---
2+cookbook-name: nagios-grid
--- a/cookbooks/nagios-grid/fly-vars.yml
+++ b/cookbooks/nagios-grid/fly-vars.yml
@@ -1,3 +1,2 @@
11 ---
2-cookbook-name: nagios-grid
32 chefdk-version: 1.6.11
--- a/cookbooks/nagios-grid/metadata.rb
+++ b/cookbooks/nagios-grid/metadata.rb
@@ -5,7 +5,7 @@ maintainer_email ''
55 license 'Apache 2.0'
66 description 'Installs/Configures nagios-grid'
77 long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
8-version '0.1.3'
8+version IO.read(File.join(File.dirname(__FILE__), 'version')).chomp
99 source_url 'http://scm.osdn.jp/gitroot/metasearch/grid-chef-repo.git'
1010 issues_url 'https://osdn.jp/projects/metasearch/ticket'
1111
--- a/cookbooks/nagios-grid/recipes/nagios-base.rb
+++ b/cookbooks/nagios-grid/recipes/nagios-base.rb
@@ -2,7 +2,7 @@
22 # Cookbook Name:: nagios-grid
33 # Recipe:: nagios-base
44 #
5-# Copyright 2016, whitestar
5+# Copyright 2016-2018, whitestar
66 #
77 # Licensed under the Apache License, Version 2.0 (the "License");
88 # you may not use this file except in compliance with the License.
@@ -98,7 +98,7 @@ nagios_pkgs.each {|pkg|
9898 }
9999
100100 nagios_action = if node['nagios']['autostart']
101- [:enable, :start]
101+ [:enable]
102102 else
103103 [:disable]
104104 end
@@ -252,3 +252,16 @@ if node['nagios']['check_ganglia_metric']['enabled']
252252 action :install
253253 end
254254 end
255+
256+# workaround
257+# https://bugs.launchpad.net/ubuntu/+source/nagios-plugins/+bug/1516451
258+file '/etc/nagios3/conf.d/localhost_nagios2.cfg' do
259+ content lazy {
260+ conf = Chef::Util::FileEdit.new(File.exist?(path) ? path : '/dev/null')
261+ # `check_all_disks_alt` is defined in etc/nagios3/base/checkcommands-generic.cfg
262+ conf.search_file_replace(/check_all_disks!(.+)!(.+)$/, 'check_all_disks_alt!\1!\2')
263+ conf.send(:editor).lines.join('')
264+ }
265+ only_if { File.exist?(path) }
266+ notifies :reload, "service[#{nagios_service}]" if node['nagios']['autoreload']
267+end
--- a/cookbooks/nagios-grid/templates/default/etc/nagios/nrpe_local.cfg
+++ b/cookbooks/nagios-grid/templates/default/etc/nagios/nrpe_local.cfg
@@ -1,4 +1,4 @@
1-# $Id$
1+# This file was generated by Chef.
22
33 allowed_hosts=<%= node['nagios']['nrpe']['allowed_hosts'] %>
44
--- a/cookbooks/nagios-grid/templates/default/etc/nagios3/base/checkcommands-generic.cfg
+++ b/cookbooks/nagios-grid/templates/default/etc/nagios3/base/checkcommands-generic.cfg
@@ -1,4 +1,11 @@
1-# $Id$
1+# This file was generated by Chef.
2+
3+define command {
4+ command_name check_all_disks_alt
5+ # Note: `check_all_disks` workaround command
6+ # see https://bugs.launchpad.net/ubuntu/+source/nagios-plugins/+bug/1516451
7+ command_line $USER1$/check_disk -w '$ARG1$' -c '$ARG2$' -e --exclude-type=tracefs --exclude-type=fuse.gvfsd-fuse
8+}
29
310 define command {
411 command_name check_file_age
--- a/cookbooks/nagios-grid/templates/default/etc/nagios3/base/hosts-generic.cfg
+++ b/cookbooks/nagios-grid/templates/default/etc/nagios3/base/hosts-generic.cfg
@@ -1,4 +1,4 @@
1-# $Id$
1+# This file was generated by Chef.
22
33 define host {
44 name generic-base-host
--- a/cookbooks/nagios-grid/templates/default/etc/nagios3/base/services-generic.cfg
+++ b/cookbooks/nagios-grid/templates/default/etc/nagios3/base/services-generic.cfg
@@ -1,4 +1,4 @@
1-# $Id$
1+# This file was generated by Chef.
22
33 define service {
44 name generic-base-service
--- a/cookbooks/nagios-grid/templates/default/etc/nagios3/site/checkcommands.cfg
+++ b/cookbooks/nagios-grid/templates/default/etc/nagios3/site/checkcommands.cfg
@@ -1,4 +1,4 @@
1-# $Id$
1+# This file was generated by Chef.
22
33 <% if node['nagios']['check_ganglia_metric']['enabled'] then -%>
44 define command {
--- a/cookbooks/nagios-grid/templates/default/etc/nagios3/site/contacts.cfg
+++ b/cookbooks/nagios-grid/templates/default/etc/nagios3/site/contacts.cfg
@@ -1,4 +1,4 @@
1-# $Id$
1+# This file was generated by Chef.
22
33 <%
44 {
--- a/cookbooks/nagios-grid/templates/default/etc/nagios3/site/hosts.cfg
+++ b/cookbooks/nagios-grid/templates/default/etc/nagios3/site/hosts.cfg
@@ -1,4 +1,4 @@
1-# $Id$
1+# This file was generated by Chef.
22
33 <%
44 {
--- a/cookbooks/nagios-grid/templates/default/etc/nagios3/site/services.cfg
+++ b/cookbooks/nagios-grid/templates/default/etc/nagios3/site/services.cfg
@@ -1,4 +1,4 @@
1-# $Id$
1+# This file was generated by Chef.
22
33 # Service templates
44 <% if node['nagios']['check_ganglia_metric']['enabled'] then -%>
--- a/cookbooks/nagios-grid/templates/default/etc/nagios3/site/timeperiods.cfg
+++ b/cookbooks/nagios-grid/templates/default/etc/nagios3/site/timeperiods.cfg
@@ -1,4 +1,4 @@
1-# $Id$
1+# This file was generated by Chef.
22
33 <%
44 {
--- /dev/null
+++ b/cookbooks/nagios-grid/version
@@ -0,0 +1 @@
1+0.1.4
Show on old repository browser