• R/O
  • HTTP
  • SSH
  • HTTPS

grid-chef-repo: Commit

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


Commit MetaInfo

Revision0fd3fd38757a155c0d8e8d97669723aba4d89d7f (tree)
Time2018-09-22 16:28:23
Authorwhitestar <whitestar@user...>
Commiterwhitestar

Log Message

adds the chef_utils::bulk-install and chef_utils::bulk-remove recipes.

Change Summary

Incremental Difference

--- /dev/null
+++ b/cookbooks/chef_utils/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/chef_utils/CHANGELOG.md
+++ b/cookbooks/chef_utils/CHANGELOG.md
@@ -1,6 +1,10 @@
11 CHANGELOG for chef_utils
22 =========================
33
4+0.9.0
5+-----
6+- adds the `chef_utils::bulk-install` and `chef_utils::bulk-remove` recipes.
7+
48 0.8.5
59 -----
610 - refactoring.
--- /dev/null
+++ b/cookbooks/chef_utils/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/chef_utils/README.md
+++ b/cookbooks/chef_utils/README.md
@@ -28,6 +28,11 @@ This cookbook contains setup recipes for Chef utilities and Knife plugins.
2828 |`['chef_utils']['chef_gem']['options']`|String|chef_gem resource's options property.|`nil`|
2929 |`['chef_utils']['chef_gem_packages']`|Array|These packages are installed by the `chef-gem-packages` recipe.|`[]`|
3030 |`['chef_utils']['bracecomp']['version']`|String|installation version.|`nil`|
31+|`['chef_utils']['bulk-install']['packages']`|Array|installed package names.|`[]`|
32+|`['chef_utils']['bulk-install']['versions']`|Array|installed package versions|`[]`|
33+|`['chef_utils']['bulk-install']['action']`|Symbol|or `:upgrade`|`:install`|
34+|`['chef_utils']['bulk-remove']['packages']`|Array|removed package names|`[]`|
35+|`['chef_utils']['bulk-remove']['action']`|Symbol|or `:purge`|`:remove`|
3136 |`['chef_utils']['chef-client']['version']`|String||`'12.17.44'`|
3237 |`['chef_utils']['chef-client']['checksum']`|String|sha256 checksum of the release artifact.|`nil` (no check)|
3338 |`['chef_utils']['chef-client']['force_install']`|String|(re)install forcely.|`false`|
@@ -58,6 +63,8 @@ This cookbook contains setup recipes for Chef utilities and Knife plugins.
5863 ### recipes
5964 - `chef_utils::berkshelf` - Berkshelf gem installation. this is already included in the Chef DK.
6065 - `chef_utils::bracecomp` - bracecomp gem installation.
66+- `chef_utils::bulk-install` - installs packages in bulk.
67+- `chef_utils::bulk-remove` - removes packages in bulk.
6168 - `chef_utils::chefspec` - chefspec gem installation. this is already included in the Chef DK.
6269 - `chef_utils::chef-gem-packages` - bulk gem installation. packages must be listed in the `['chef_utils']['chef_gem_packages']` attribute (ver. 0.7.0 or later)
6370 - `chef_utils::chef-server-configuration` - chef-server.rb configuration file deployment recipe. (ver. 0.6.0 or later)
@@ -81,7 +88,7 @@ This cookbook contains setup recipes for Chef utilities and Knife plugins.
8188 - Author:: whitestar at osdn.jp
8289
8390 ```text
84-Copyright 2013-2016, whitestar
91+Copyright 2013-2018, whitestar
8592
8693 Licensed under the Apache License, Version 2.0 (the "License");
8794 you may not use this file except in compliance with the License.
--- a/cookbooks/chef_utils/Rakefile
+++ b/cookbooks/chef_utils/Rakefile
@@ -3,12 +3,56 @@ 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+ 'concourse.yml',
18+ 'fly-vars.yml',
19+ 'fly-vars.local.yml',
20+ 'Gemfile',
21+ 'Gemfile.lock',
22+ 'version',
23+ ].each {|conf|
24+ sh "cp ../#{tpl_cookbook}/#{conf} ./" unless File.exist?(conf)
25+ }
26+
27+ ruby [
28+ %(-pne '$_.gsub!(/^cookbook-name: .*$/, "cookbook-name: #{cookbook_name}")'),
29+ '-i fly-vars.local.yml',
30+ ].join(' ')
31+end
32+
33+desc 'Update project'
34+task :update do
35+ next if cookbook_name == tpl_cookbook
36+
37+ [
38+ 'Rakefile',
39+ 'concourse.yml',
40+ 'fly-vars.yml',
41+ 'Gemfile',
42+ 'Gemfile.lock',
43+ ].each {|conf|
44+ sh "cp ../#{tpl_cookbook}/#{conf} ./"
45+ }
46+end
47+
48+desc 'fly set-pipeline'
649 task :'set-pipeline' do
750 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',
51+ "fly -t $CC_TARGET sp -p #{cookbook_name}-cookbook -c concourse.yml",
52+ '-l fly-vars.yml -l fly-vars.local.yml -l ~/sec/credentials-prod.yml',
1053 ].join(' ')
1154 end
55+desc 'rake set-pipeline alias'
1256 task sp: 'set-pipeline'
1357
1458 namespace :style do
--- a/cookbooks/chef_utils/attributes/default.rb
+++ b/cookbooks/chef_utils/attributes/default.rb
@@ -2,7 +2,7 @@
22 # Cookbook Name:: chef_utils
33 # Attributes:: default
44 #
5-# Copyright 2015-2016, whitestar
5+# Copyright 2015-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.
@@ -22,11 +22,23 @@ pf_ver = node['platform_version']
2222 arch = node['kernel']['machine']
2323 arch_alias = arch == 'x86_64' ? 'amd64' : arch
2424
25+default['chef_utils']['bulk-install'] = {
26+ 'packages' => [],
27+ 'versions' => [],
28+ 'action' => :install, # or :upgrade
29+}
30+default['chef_utils']['bulk-remove'] = {
31+ 'packages' => [],
32+ 'action' => :remove, # or :purge
33+}
34+
2535 default['chef_utils']['chef_gem']['clear_sources'] = false
2636 default['chef_utils']['chef_gem']['source'] = nil
2737 default['chef_utils']['chef_gem']['options'] = nil
2838 default['chef_utils']['chef_gem_packages'] = []
39+
2940 default['chef_utils']['bracecomp']['version'] = nil
41+
3042 default['chef_utils']['chef-client']['version'] = '12.21.26'
3143 default['chef_utils']['chef-client']['checksum'] = nil # no check
3244 default['chef_utils']['chef-client']['force_install'] = false
@@ -45,6 +57,7 @@ default['chef_utils']['chef-client']['release_url'] = node.value_for_platform(
4557 )
4658 default['chef_utils']['chef-client']['fallback_omnitruck_install'] = false
4759 default['chef_utils']['chef-client']['omnitruck_installer_url'] = 'https://omnitruck.chef.io/install.sh'
60+
4861 default['chef_utils']['chef-vault']['version'] = '>= 2.6'
4962 default['chef_utils']['chefspec']['version'] = nil
5063 default['chef_utils']['knife-acl']['version'] = nil
--- a/cookbooks/chef_utils/concourse.yml
+++ b/cookbooks/chef_utils/concourse.yml
@@ -1,5 +1,4 @@
11 ---
2-# $ fly -t $CC_TARGET sp -p chef_utils-cookbook -c concourse.yml -l fly-vars.yml -l ~/sec/credentials-prod.yml
32 resources:
43 - name: src-git
54 type: git
--- /dev/null
+++ b/cookbooks/chef_utils/fly-vars.local.yml
@@ -0,0 +1,2 @@
1+---
2+cookbook-name: chef_utils
--- a/cookbooks/chef_utils/fly-vars.yml
+++ b/cookbooks/chef_utils/fly-vars.yml
@@ -1,3 +1,2 @@
11 ---
2-cookbook-name: chef_utils
32 chefdk-version: 1.6.11
--- /dev/null
+++ b/cookbooks/chef_utils/recipes/bulk-install.rb
@@ -0,0 +1,27 @@
1+#
2+# Cookbook Name:: chef_utils
3+# Recipe:: bulk-install
4+#
5+# Copyright 2018 whitestar
6+#
7+# Licensed under the Apache License, Version 2.0 (the "License");
8+# you may not use this file except in compliance with the License.
9+# You may obtain a copy of the License at
10+#
11+# http://www.apache.org/licenses/LICENSE-2.0
12+#
13+# Unless required by applicable law or agreed to in writing, software
14+# distributed under the License is distributed on an "AS IS" BASIS,
15+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+# See the License for the specific language governing permissions and
17+# limitations under the License.
18+#
19+
20+conf = node['chef_utils']['bulk-install']
21+
22+package 'bulk-install_packages' do
23+ package_name conf['packages']
24+ version conf['versions'] unless conf['versions'].empty?
25+ action conf['action']
26+ not_if { conf['packages'].empty? }
27+end
--- /dev/null
+++ b/cookbooks/chef_utils/recipes/bulk-remove.rb
@@ -0,0 +1,26 @@
1+#
2+# Cookbook Name:: chef_utils
3+# Recipe:: bulk-remove
4+#
5+# Copyright 2018 whitestar
6+#
7+# Licensed under the Apache License, Version 2.0 (the "License");
8+# you may not use this file except in compliance with the License.
9+# You may obtain a copy of the License at
10+#
11+# http://www.apache.org/licenses/LICENSE-2.0
12+#
13+# Unless required by applicable law or agreed to in writing, software
14+# distributed under the License is distributed on an "AS IS" BASIS,
15+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+# See the License for the specific language governing permissions and
17+# limitations under the License.
18+#
19+
20+conf = node['chef_utils']['bulk-remove']
21+
22+package 'bulk-remove_packages' do
23+ package_name conf['packages']
24+ action conf['action']
25+ not_if { conf['packages'].empty? }
26+end
--- a/cookbooks/chef_utils/version
+++ b/cookbooks/chef_utils/version
@@ -1 +1 @@
1-0.8.5
1+0.9.0
Show on old repository browser