• R/O
  • HTTP
  • SSH
  • HTTPS

grid-chef-repo: Commit

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


Commit MetaInfo

Révision68c906cc7a4f03b440608924e9a87e0fb90733c6 (tree)
l'heure2017-01-11 23:29:03
Auteurwhitestar <whitestar@gaea...>
Commiterwhitestar

Message de Log

adds the apt_utils::apt recipe.

Change Summary

Modification

--- /dev/null
+++ b/cookbooks/apt_utils/.foodcritic
@@ -0,0 +1 @@
1+~FC001
--- /dev/null
+++ b/cookbooks/apt_utils/.rubocop.yml
@@ -0,0 +1,37 @@
1+AllCops:
2+ Exclude:
3+ - vendor/**/*
4+
5+AlignParameters:
6+ Enabled: false
7+LineLength:
8+ Enabled: false
9+Lint/UnusedBlockArgument:
10+ Enabled: false
11+Metrics/AbcSize:
12+ Enabled: false
13+Style/BlockComments:
14+ Enabled: false
15+Style/BlockDelimiters:
16+ Enabled: false
17+Style/ExtraSpacing:
18+ Enabled: false
19+Style/FileName:
20+ Enabled: false
21+Style/LeadingCommentSpace:
22+ Enabled: false
23+Style/RescueModifier:
24+ Enabled: false
25+Style/SpaceBeforeFirstArg:
26+ Enabled: false
27+Style/TrailingCommaInLiteral:
28+ EnforcedStyleForMultiline: comma
29+Style/WordArray:
30+ Enabled: false
31+
32+#Style/AccessorMethodName:
33+# Enabled: false
34+#Style/MethodLength:
35+# Max: 30
36+#Style/ModuleLength:
37+# Max: 150
--- a/cookbooks/apt_utils/Berksfile
+++ b/cookbooks/apt_utils/Berksfile
@@ -1,5 +1,5 @@
11 #
2-# Copyright 2015 whitestar
2+# Copyright 2015-2017 whitestar
33 #
44 # Licensed under the Apache License, Version 2.0 (the "License");
55 # you may not use this file except in compliance with the License.
@@ -17,8 +17,7 @@
1717 #grid_chef_repo = 'git://git.osdn.jp/gitroot/metasearch/grid-chef-repo.git'
1818
1919 # for ver. 3.x
20-#source 'https://gpm00.grid.example.com:6280'
20+#source 'https://berks-api.io.example.com:6280'
2121 source 'https://supermarket.chef.io'
2222
2323 metadata
24-
--- a/cookbooks/apt_utils/CHANGELOG.md
+++ b/cookbooks/apt_utils/CHANGELOG.md
@@ -1,6 +1,11 @@
11 apt_utils CHANGELOG
22 ===================
33
4+0.2.0
5+-----
6+- adds the `apt_utils::apt` recipe.
7+- updates cookbook dependencies.
8+
49 0.1.4
510 -----
611 - update for Ubuntu 16.10
@@ -11,11 +16,11 @@ apt_utils CHANGELOG
1116
1217 0.1.2
1318 -----
14-- add ['apt_utils']['apt-cacher-ng']['UseWrap'] attribute.
19+- adds the `['apt_utils']['apt-cacher-ng']['UseWrap']` attribute.
1520
1621 0.1.1
1722 -----
18-- add APT proxy configuration recipe.
23+- adds APT proxy configuration recipe.
1924
2025 0.1.0
2126 -----
--- a/cookbooks/apt_utils/README.md
+++ b/cookbooks/apt_utils/README.md
@@ -3,16 +3,31 @@ apt_utils Cookbook
33
44 This cookbook includes apt utility (apt-cacher-ng, apt mirroring site setup and apt source configuration) recipes.
55
6-Requirements
7-------------
6+## Contents
87
9-#### packages
10-- `commons` - local cookbook.
8+- [Requirements](#requirements)
9+ - [packages](#packages)
10+- [Attributes](#attributes)
11+ - [apt_utils::default](#apt_utilsdefault)
12+- [Usage](#usage)
13+ - [Recipes](#recipes)
14+ - [apt_utils::apt](#apt_utilsapt)
15+ - [apt_utils::conf](#apt_utilsconf)
16+ - [apt_utils::apt-cacher-ng](#apt_utilsapt-cacher-ng)
17+ - [apt_utils::mirror](#apt_utilsmirror)
18+ - [apt_utils::source](#apt_utilssource)
19+- [License and Authors](#license-and-authors)
1120
12-Attributes
13-----------
21+## Requirements
1422
15-#### apt_utils::default
23+### packages
24+
25+- `apt`
26+- `platform_utils` >= 0.4.0
27+
28+## Attributes
29+
30+### apt_utils::default
1631
1732 |Key|Type|Description (with examples)|Default|
1833 |:--|:--|:--|:--|
@@ -31,14 +46,21 @@ Attributes
3146 |`['apt_utils']['mirror']['nthreads']`|String|worker threads number.|`'20'`|
3247 |`['apt_utils']['mirror']['_tilde']`|||`'0'`|
3348 |`['apt_utils']['mirror']['country']`|String|mirroring source country.|`'us'`|
34-|`['apt_utils']['mirror']['distributions']['debian']`|Hash|Debian's mirroring apt lines.|refer to attributes/default.rb|
35-|`['apt_utils']['mirror']['distributions']['ubuntu']`|Hash|Ubuntu's mirroring apt lines.|refer to attributes/default.rb|
36-|`['apt_utils']['source']['apt_lines']['ubuntu']`|Array|apt source lines.|refer to attributes/default.rb|
49+|`['apt_utils']['mirror']['distributions']['debian']`|Hash|Debian's mirroring apt lines.|refer to `attributes/default.rb`|
50+|`['apt_utils']['mirror']['distributions']['ubuntu']`|Hash|Ubuntu's mirroring apt lines.|refer to `attributes/default.rb`|
51+|`['apt_utils']['source']['apt_lines']['ubuntu']`|Array|apt source lines.|refer to `attributes/default.rb`|
52+
53+## Usage
54+
55+### Recipes
56+
57+#### apt_utils::apt
58+
59+- includes `apt::default` recipe if the platform family is `debian`.
3760
38-Usage
39------
4061 #### apt_utils::conf
41-- deploy apt configuration files to the /etc/apt/apt.conf.d directory.
62+
63+- deploys apt configuration files to the `/etc/apt/apt.conf.d` directory.
4264
4365 #### apt_utils::apt-cacher-ng
4466
@@ -73,12 +95,12 @@ Usage
7395 }
7496 ```
7597
76-License and Authors
77--------------------
98+## License and Authors
99+
78100 - Author:: whitestar at osdn.jp
79101
80102 ```text
81-Copyright 2013-2016, whitestar
103+Copyright 2013-2017, whitestar
82104
83105 Licensed under the Apache License, Version 2.0 (the "License");
84106 you may not use this file except in compliance with the License.
--- /dev/null
+++ b/cookbooks/apt_utils/Rakefile
@@ -0,0 +1,23 @@
1+require 'rspec/core/rake_task'
2+require 'rubocop/rake_task'
3+require 'foodcritic'
4+
5+namespace :style do
6+ desc 'Run Ruby style checks'
7+ RuboCop::RakeTask.new(:ruby)
8+
9+ desc 'Run Chef style checks'
10+ FoodCritic::Rake::LintTask.new(:chef) do |t|
11+ t.options = {
12+ fail_tags: ['any'],
13+ }
14+ end
15+end
16+
17+desc 'Run all style checks'
18+task style: ['style:chef', 'style:ruby']
19+
20+desc 'Run ChefSpec examples'
21+RSpec::Core::RakeTask.new(:spec)
22+
23+task default: ['style', 'spec']
--- a/cookbooks/apt_utils/attributes/default.rb
+++ b/cookbooks/apt_utils/attributes/default.rb
@@ -2,7 +2,7 @@
22 # Cookbook Name:: apt_utils
33 # Attributes:: default
44 #
5-# Copyright 2013-2016, whitestar
5+# Copyright 2013-2017, 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.
@@ -29,7 +29,7 @@ default['apt_utils']['source']['apt_lines'] = [
2929 'deb http://cdn.debian.net/debian wheezy main contrib non-free',
3030 'deb http://cdn.debian.net/debian wheezy-updates main contrib',
3131 'deb http://cdn.debian.net/debian wheezy-backports main contrib non-free',
32- 'deb http://security.debian.org/ wheezy/updates main contrib non-free'
32+ 'deb http://security.debian.org/ wheezy/updates main contrib non-free',
3333 # mirror example.
3434 #'deb http://ftp.grid.example.com/debian wheezy main contrib non-free',
3535 #'deb http://ftp.grid.example.com/debian wheezy-updates main contrib',
@@ -60,18 +60,18 @@ default['apt_utils']['mirror']['distributions']['debian'] = {
6060 #'wheezy',
6161 #'wheezy-updates',
6262 #'wheezy-backports',
63- #'squeeze'
63+ #'squeeze',
6464 ],
6565 'architectures' => [
6666 'amd64',
67- 'i386'
67+ 'i386',
6868 #'src',
6969 ],
7070 'components' => [
7171 'main',
7272 'contrib',
73- 'non-free'
74- ]
73+ 'non-free',
74+ ],
7575 }
7676 default['apt_utils']['mirror']['distribution']['ubuntu'] = {
7777 # default: empty (inactive)
@@ -90,7 +90,5 @@ default['apt_utils']['mirror']['distribution']['ubuntu'] = {
9090 'universe',
9191 'multiverse',
9292 'restricted',
93- ]
93+ ],
9494 }
95-
96-
--- a/cookbooks/apt_utils/metadata.rb
+++ b/cookbooks/apt_utils/metadata.rb
@@ -1,11 +1,17 @@
1+# $ knife supermarket share apt_utils "Operating Systems & Virtualization"
12 name 'apt_utils'
23 maintainer 'whitestar'
34 maintainer_email ''
45 license 'Apache 2.0'
5-description 'Installs/Configures apt_utils'
6+description 'Installs/Configures APT'
67 long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7-version '0.1.4'
8+version '0.2.0'
9+source_url 'http://scm.osdn.jp/gitroot/metasearch/grid-chef-repo.git'
10+issues_url 'https://osdn.jp/projects/metasearch/ticket'
811
9-# local cookbooks
10-depends 'commons'
12+%w( debian ubuntu ).each do |os|
13+ supports os
14+end
1115
16+depends 'apt'
17+depends 'platform_utils', '>= 0.4.0'
--- a/cookbooks/apt_utils/recipes/apt-cacher-ng.rb
+++ b/cookbooks/apt_utils/recipes/apt-cacher-ng.rb
@@ -2,7 +2,7 @@
22 # Cookbook Name:: apt_utils
33 # Recipe:: apt-cacher-ng
44 #
5-# Copyright 2013, whitestar
5+# Copyright 2013-2017, 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.
@@ -17,19 +17,19 @@
1717 # limitations under the License.
1818 #
1919
20-::Chef::Recipe.send(:include, Commons::PackageUtils)
20+::Chef::Recipe.send(:include, PlatformUtils::PackageUtils)
2121
22-if node[:platform_family] == 'debian' then
22+if node['platform_family'] == 'debian'
2323 pkg = 'apt-cacher-ng'
2424 user_name = pkg
25- resources(:package => pkg) rescue package pkg do
25+ resources(package: pkg) rescue package pkg do
2626 action :install
2727 end
2828
2929 service_name = pkg
30- resources(:service => service_name) rescue service service_name do
30+ resources(service: service_name) rescue service service_name do
3131 action [:enable, :start]
32- supports :status => true, :restart => true, :reload => false
32+ supports status: true, restart: true, reload: false
3333 end
3434
3535 directory node['apt_utils']['apt-cacher-ng']['CacheDir'] do
@@ -38,7 +38,7 @@ if node[:platform_family] == 'debian' then
3838 mode '2755'
3939 recursive true
4040 end
41-
41+
4242 directory node['apt_utils']['apt-cacher-ng']['LogDir'] do
4343 owner user_name
4444 group user_name
@@ -54,4 +54,3 @@ if node[:platform_family] == 'debian' then
5454 notifies :restart, "service[#{service_name}]"
5555 end
5656 end
57-
--- /dev/null
+++ b/cookbooks/apt_utils/recipes/apt.rb
@@ -0,0 +1,25 @@
1+#
2+# Cookbook Name:: apt_utils
3+# Recipe:: apt
4+#
5+# Copyright 2017, 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+if node['platform_family'] == 'debian'
21+ # "If a recipe is included more than once in a recipe, only the first
22+ # inclusion will be processed and any subsequent inclusion will be ignored."
23+ # from http://docs.opscode.com/essentials_cookbook_recipes_in_recipes.html
24+ include_recipe 'apt::default'
25+end
--- a/cookbooks/apt_utils/recipes/conf.rb
+++ b/cookbooks/apt_utils/recipes/conf.rb
@@ -2,7 +2,7 @@
22 # Cookbook Name:: apt_utils
33 # Recipe:: conf
44 #
5-# Copyright 2016, whitestar
5+# Copyright 2016-2017, 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.
@@ -17,15 +17,14 @@
1717 # limitations under the License.
1818 #
1919
20-if node[:platform_family] == 'debian' then
20+if node['platform_family'] == 'debian'
2121 proxy_conf = node['apt_utils']['conf']['proxy']
22- if !proxy_conf['ftp'].nil? || !proxy_conf['http'].nil? || !proxy_conf['https'].nil? then
23- template "/etc/apt/apt.conf.d/#{proxy_conf['sequence']}proxy" do
24- source 'etc/apt/apt.conf.d/proxy'
25- owner 'root'
26- group 'root'
27- mode '0644'
28- end
22+
23+ template "/etc/apt/apt.conf.d/#{proxy_conf['sequence']}proxy" do
24+ source 'etc/apt/apt.conf.d/proxy'
25+ owner 'root'
26+ group 'root'
27+ mode '0644'
28+ only_if { !proxy_conf['ftp'].nil? || !proxy_conf['http'].nil? || !proxy_conf['https'].nil? }
2929 end
3030 end
31-
--- a/cookbooks/apt_utils/recipes/mirror.rb
+++ b/cookbooks/apt_utils/recipes/mirror.rb
@@ -2,7 +2,7 @@
22 # Cookbook Name:: apt_utils
33 # Recipe:: mirror
44 #
5-# Copyright 2013, whitestar
5+# Copyright 2013-2017, 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.
@@ -17,22 +17,22 @@
1717 # limitations under the License.
1818 #
1919
20-::Chef::Recipe.send(:include, Commons::PackageUtils)
20+::Chef::Recipe.send(:include, PlatformUtils::PackageUtils)
2121
2222 pkg = 'apt-mirror' # CentOS: in the EPEL
23-resources(:package => pkg) rescue package pkg do
23+resources(package: pkg) rescue package pkg do
2424 action :install
2525 end
2626
2727 mirror_user = node['apt_utils']['mirror']['user']
2828 base_path = node['apt_utils']['mirror']['base_path']
2929
30-resources(:group => mirror_user) rescue group mirror_user do
30+resources(group: mirror_user) rescue group mirror_user do
3131 system true
3232 action :create
3333 end
3434
35-resources(:user => mirror_user) rescue user mirror_user do
35+resources(user: mirror_user) rescue user mirror_user do
3636 gid mirror_user
3737 system true
3838 home base_path
@@ -48,18 +48,18 @@ bash "#{base_path} - change owner to #{mirror_user}:#{mirror_user} recursively."
4848 end
4949
5050 mirror_list_path = nil
51-httpd_service = get_httpd_pkg_name
51+httpd_service = httpd_pkg_name
5252 httpd_conf_path = nil
5353
54-case node[:platform_family]
54+case node['platform_family']
5555 when 'debian'
5656 mirror_list_path = '/etc/apt/mirror.list'
57- case node[:platform_version].to_i
58- when 8
59- httpd_conf_path = "/etc/#{httpd_service}/conf-available/apt-mirror.conf"
60- else
61- httpd_conf_path = "/etc/#{httpd_service}/conf.d/apt-mirror"
62- end
57+ httpd_conf_path = case node['platform_version'].to_i
58+ when 8
59+ "/etc/#{httpd_service}/conf-available/apt-mirror.conf"
60+ else
61+ "/etc/#{httpd_service}/conf.d/apt-mirror"
62+ end
6363 when 'rhel'
6464 mirror_list_path = '/etc/apt-mirror.list'
6565 httpd_conf_path = "/etc/#{httpd_service}/conf.d/apt-mirror.conf"
@@ -72,8 +72,8 @@ template mirror_list_path do
7272 mode '0644'
7373 end
7474
75-pkg = get_cron_pkg_name
76-resources(:package => pkg) rescue package pkg do
75+pkg = cron_pkg_name
76+resources(package: pkg) rescue package pkg do
7777 action :install
7878 end
7979
@@ -85,13 +85,13 @@ template '/etc/cron.d/apt-mirror' do
8585 end
8686
8787 pkg = httpd_service
88-resources(:package => pkg) rescue package pkg do
88+resources(package: pkg) rescue package pkg do
8989 action :install
9090 end
9191
92-resources(:service => httpd_service) rescue service httpd_service do
92+resources(service: httpd_service) rescue service httpd_service do
9393 action [:enable, :start]
94- supports :status => true, :restart => true, :reload => true
94+ supports status: true, restart: true, reload: true
9595 end
9696
9797 template httpd_conf_path do
@@ -101,4 +101,3 @@ template httpd_conf_path do
101101 mode '0644'
102102 notifies :restart, "service[#{httpd_service}]"
103103 end
104-
--- a/cookbooks/apt_utils/recipes/source.rb
+++ b/cookbooks/apt_utils/recipes/source.rb
@@ -17,12 +17,10 @@
1717 # limitations under the License.
1818 #
1919
20-if node[:platform_family] == 'debian' then
21- template '/etc/apt/sources.list' do
22- source 'etc/apt/sources.list'
23- owner 'root'
24- group 'root'
25- mode '0644'
26- end
20+template '/etc/apt/sources.list' do
21+ source 'etc/apt/sources.list'
22+ owner 'root'
23+ group 'root'
24+ mode '0644'
25+ only_if { node['platform_family'] == 'debian' }
2726 end
28-
--- a/cookbooks/apt_utils/spec/recipes/apt-cacher-ng_spec.rb
+++ b/cookbooks/apt_utils/spec/recipes/apt-cacher-ng_spec.rb
@@ -2,7 +2,7 @@
22 # Cookbook Name:: apt_utils
33 # Recipe Spec:: apt-cacher-ng_spec
44 #
5-# Copyright 2015, whitestar
5+# Copyright 2015-2017, 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.
@@ -56,11 +56,11 @@ describe 'apt_utils::apt-cacher-ng' do
5656 expected.to create_directory('/path/to/cache')
5757 expected.to create_directory('/path/to/log')
5858 end
59-
59+
6060 it 'renders /etc/apt-cacher-ng/acng.conf on debian family.' do
6161 expect(chef_run_on_debian).to \
62- render_file('/etc/apt-cacher-ng/acng.conf').
63- with_content(%r|^CacheDir:\s+/path/to/cache$|)
62+ render_file('/etc/apt-cacher-ng/acng.conf')
63+ .with_content(%r{^CacheDir:\s+/path/to/cache$})
6464 end
6565
6666 it 'notifies apt-cacher-ng service\'s restart after rendering on debian family.' do
@@ -68,4 +68,3 @@ describe 'apt_utils::apt-cacher-ng' do
6868 notify('service[apt-cacher-ng]').to(:restart).delayed
6969 end
7070 end
71-
--- a/cookbooks/apt_utils/spec/recipes/source_spec.rb
+++ b/cookbooks/apt_utils/spec/recipes/source_spec.rb
@@ -21,8 +21,9 @@ require_relative '../spec_helper'
2121
2222 describe 'apt_utils::source' do
2323 let(:chef_run_on_non_debian) {
24- ChefSpec::SoloRunner.new(platform: 'centos', version: '7.0').
25- converge(described_recipe)
24+ ChefSpec::SoloRunner
25+ .new(platform: 'centos', version: '7.0')
26+ .converge(described_recipe)
2627 }
2728
2829 it 'does nothing on non debian family.' do
@@ -40,10 +41,9 @@ describe 'apt_utils::source' do
4041
4142 it 'renders /etc/apt/sources.list on debian family.' do
4243 expected = expect(chef_run_on_debian)
43- expected.to render_file('/etc/apt/sources.list').
44- with_content('deb http://cdn.debian.net/debian jessie main contrib non-free')
45- expected.to render_file('/etc/apt/sources.list').
46- with_content('deb http://cdn.debian.net/debian jessie-updates main contrib')
44+ expected.to render_file('/etc/apt/sources.list')
45+ .with_content('deb http://cdn.debian.net/debian jessie main contrib non-free')
46+ expected.to render_file('/etc/apt/sources.list')
47+ .with_content('deb http://cdn.debian.net/debian jessie-updates main contrib')
4748 end
4849 end
49-
Afficher sur ancien navigateur de dépôt.