• R/O
  • HTTP
  • SSH
  • HTTPS

grid-chef-repo: Commit

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


Commit MetaInfo

Revisiona4a55b0b529cb2b90cf1374bdf5466209ddde136 (tree)
Time2018-11-10 14:43:52
Authorwhitestar <whitestar@user...>
Commiterwhitestar

Log Message

adds docker-ce-18.09 support.

Change Summary

Incremental Difference

--- a/cookbooks/docker-grid/.rubocop.yml
+++ b/cookbooks/docker-grid/.rubocop.yml
@@ -10,6 +10,10 @@ Lint/UnusedBlockArgument:
1010 Enabled: false
1111 Metrics/AbcSize:
1212 Enabled: false
13+Metrics/CyclomaticComplexity:
14+ Max: 7
15+Metrics/MethodLength:
16+ Max: 17
1317 Style/BlockComments:
1418 Enabled: false
1519 Style/BlockDelimiters:
@@ -35,7 +39,5 @@ Metrics/BlockNesting:
3539 Max: 4
3640 #Style/AccessorMethodName:
3741 # Enabled: false
38-#Metrics/MethodLength:
39-# Max: 15
4042 #Style/ModuleLength:
4143 # Max: 150
--- a/cookbooks/docker-grid/CHANGELOG.md
+++ b/cookbooks/docker-grid/CHANGELOG.md
@@ -1,5 +1,9 @@
11 # docker-grid CHANGELOG
22
3+1.3.3
4+-----
5+- adds docker-ce-18.09 support.
6+
37 1.3.2
48 -----
59 - adds the latest Ubuntu support.
--- a/cookbooks/docker-grid/Rakefile
+++ b/cookbooks/docker-grid/Rakefile
@@ -14,6 +14,7 @@ task :init do
1414 '.foodcritic',
1515 '.rubocop.yml',
1616 'Berksfile',
17+ 'chefignore',
1718 'concourse.yml',
1819 'fly-vars.yml',
1920 'fly-vars.local.yml',
@@ -36,6 +37,7 @@ task :update do
3637
3738 [
3839 'Rakefile',
40+ 'chefignore',
3941 'concourse.yml',
4042 'fly-vars.yml',
4143 'Gemfile',
--- a/cookbooks/docker-grid/attributes/default.rb
+++ b/cookbooks/docker-grid/attributes/default.rb
@@ -17,6 +17,8 @@
1717 # limitations under the License.
1818 #
1919
20+::Chef::Node::Attribute.send(:include, DockerGrid::Helper)
21+
2022 platform = node['platform']
2123
2224 default['docker-grid']['install_flavor'] = 'dockerproject' # or 'os-repository'
@@ -99,9 +101,9 @@ default['docker-grid']['engine']['autopilot'] = {
99101 # os-repository: yum list docker
100102 # http://mirror.centos.org/centos/7.3.1611/extras/x86_64/Packages/
101103 default['docker-grid']['engine']['version_on_centos'] = '17.12.1.ce-1'
102-# dockerproject: 18.06.0~ce~3-0, 18.03.1~ce-0, 17.12.1~ce-0, 1.13.1-0
104+# dockerproject: 5:18.09.0~3-0, 18.06.1~ce~3-0, 18.03.1~ce-0, 17.12.1~ce-0, 1.13.1-0
103105 default['docker-grid']['engine']['version_on_debian'] = '17.12.1~ce-0'
104-# dockerproject: 18.06.0~ce~3-0, 18.03.1~ce-0, 17.12.1~ce-0
106+# dockerproject: 5:18.09.0~3-0, 18.06.1~ce~3-0, 18.03.1~ce-0, 17.12.1~ce-0
105107 # os-repository: http://packages.ubuntu.com/search?keywords=docker.io&searchon=names
106108 default['docker-grid']['engine']['version_on_ubuntu'] = '17.12.1~ce-0'
107109
@@ -110,38 +112,19 @@ case platform
110112 when 'centos', 'redhat'
111113 version_on_centos = node['docker-grid']['engine']['version_on_centos']
112114 if !version_on_centos.nil? && !version_on_centos.empty? && version_on_centos != 'latest'
113- suffix = ''
114- if Gem::Version.create(version_on_centos) < Gem::Version.create('18.06.0.ce-3')
115- suffix = ".#{node['platform']}"
116- end
117- version_on_centos = "#{version_on_centos}.el#{node['platform_version'].to_i}#{suffix}"
115+ version_on_centos = docker_full_ver(node, version_on_centos)
118116 end
119117 when 'debian'
120118 version_on_debian = node['docker-grid']['engine']['version_on_debian']
121- if !version_on_debian.nil? && !version_on_debian.empty? && version_on_debian != 'latest'
122- version_on_debian = \
123- if node['docker-grid']['install_flavor'] == 'dockerproject'
124- if Gem::Version.create(version_on_debian.tr('~', '-')) >= Gem::Version.create('1.12.4-0')
125- "#{version_on_debian}~debian-#{node['lsb']['codename']}"
126- else
127- "#{version_on_debian}~#{node['lsb']['codename']}"
128- end
129- end
119+ if !version_on_debian.nil? && !version_on_debian.empty? && version_on_debian != 'latest' \
120+ && node['docker-grid']['install_flavor'] == 'dockerproject'
121+ version_on_debian = docker_full_ver(node, version_on_debian)
130122 end
131123 when 'ubuntu'
132124 version_on_ubuntu = node['docker-grid']['engine']['version_on_ubuntu']
133- if !version_on_ubuntu.nil? && !version_on_ubuntu.empty? && version_on_ubuntu != 'latest'
134- version_on_ubuntu = \
135- if node['docker-grid']['install_flavor'] == 'dockerproject'
136- if Gem::Version.create(version_on_ubuntu.tr('~', '-')) >= Gem::Version.create('1.12.4-0')
137- "#{version_on_ubuntu}~ubuntu-#{node['lsb']['codename']}"
138- else
139- "#{version_on_ubuntu}~#{node['lsb']['codename']}"
140- end
141- # else
142- # e.g. 1.12.3-0ubuntu4~16.10.2, 1.12.3-0ubuntu4~16.04.2
143- # version_on_ubuntu
144- end
125+ if !version_on_ubuntu.nil? && !version_on_ubuntu.empty? && version_on_ubuntu != 'latest' \
126+ && node['docker-grid']['install_flavor'] == 'dockerproject'
127+ version_on_ubuntu = docker_full_ver(node, version_on_ubuntu)
145128 end
146129 end
147130
--- /dev/null
+++ b/cookbooks/docker-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/*
--- /dev/null
+++ b/cookbooks/docker-grid/libraries/helper.rb
@@ -0,0 +1,54 @@
1+#
2+# Cookbook Name:: docker-grid
3+# Library:: Helper
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+module DockerGrid
21+ # Helper methods
22+ module Helper
23+ def gem_ver(version)
24+ # `.gsub(/^\d:/, '')` deletes an epoch prefix (e.g. '5:')
25+ Gem::Version.create(version.gsub(/^\d:/, '').tr('~', '-'))
26+ end
27+
28+ def docker_full_ver(node, version)
29+ platform = node['platform']
30+
31+ case platform
32+ when 'centos', 'redhat'
33+ suffix = ''
34+ suffix = ".#{platform}" if gem_ver(version) < gem_ver('18.06.0.ce-3')
35+ "#{version}.el#{node['platform_version'].to_i}#{suffix}"
36+ when 'debian', 'ubuntu'
37+ # e.g.
38+ # 5:18.09.0~3-0~ubuntu-xenial # epoch ('5:') and codename suffix added
39+ # 18.06.1~ce~3-0~ubuntu ...
40+ # 17.06.0~ce-0~ubuntu # codename suffix deleted
41+ # 17.03.2~ce-0~ubuntu-xenial ...
42+ # 1.12.3-0ubuntu4~16.10.2, 1.12.3-0ubuntu4~16.04.2
43+ target_ver = gem_ver(version)
44+ if target_ver < gem_ver('1.12.4-0')
45+ "#{version}~#{node['lsb']['codename']}"
46+ elsif target_ver < gem_ver('17.06') || target_ver > gem_ver('18.06.99')
47+ "#{version}~#{platform}-#{node['lsb']['codename']}"
48+ else # 17.06 =< ver =< 18.06
49+ "#{version}~#{platform}"
50+ end
51+ end
52+ end
53+ end
54+end
--- a/cookbooks/docker-grid/recipes/engine.rb
+++ b/cookbooks/docker-grid/recipes/engine.rb
@@ -35,6 +35,11 @@ enable_new_repo = node['docker-grid']['dockerproject']['enable_new_repo']
3535 engine_conf = node['docker-grid']['engine']
3636 docker_ver = engine_conf['version']
3737 docker_ver = '' if docker_ver.nil? || docker_ver == 'latest'
38+if docker_ver.empty?
39+ Chef::Log.warn('This docker-grid::engine installs the latest Docker engine.')
40+else
41+ Chef::Log.info("This docker-grid::engine installs the Docker engine: #{docker_ver}.")
42+end
3843 storage_driver = engine_conf['storage-driver']
3944 userns_remap = engine_conf['userns-remap']
4045
@@ -43,6 +48,7 @@ if engine_conf['skip_setup']
4348 return
4449 end
4550
51+::Chef::Recipe.send(:include, DockerGrid::Helper)
4652 ::Chef::Recipe.send(:include, PlatformUtils::Helper)
4753 ::Chef::Recipe.send(:include, PlatformUtils::VirtUtils)
4854
@@ -74,16 +80,14 @@ if shell_out("cat /etc/mtab | grep -E '\s+/\s+zfs\s+'").exitstatus.zero?
7480 end
7581
7682 if storage_driver == 'overlay2'
77- if !docker_ver.empty? && Gem::Version.create(docker_ver.tr('~', '-')) < Gem::Version.create('1.12')
78- # tr('~', '-') for Ubuntu.
83+ if !docker_ver.empty? && gem_ver(docker_ver) < gem_ver('1.12')
7984 Chef::Application.fatal!('Docker version must be 1.12 or later for overlay2 storage driver.') # and exit.
8085 end
8186 end
8287 load_kernel_module('overlay') if storage_driver =~ /overlay2?/
8388
8489 if !userns_remap.nil? && !userns_remap.empty?
85- if !docker_ver.empty? && Gem::Version.create(docker_ver.tr('~', '-')) < Gem::Version.create('1.10')
86- # tr('~', '-') for Ubuntu.
90+ if !docker_ver.empty? && gem_ver(docker_ver) < gem_ver('1.10')
8791 Chef::Application.fatal!('Docker version must be 1.10 or later for userns-remap.') # and exit.
8892 end
8993
@@ -337,10 +341,14 @@ extra_options = engine_conf['daemon_extra_options']
337341 if platform_family == 'rhel' || platform == 'debian' || (platform == 'ubuntu' && platform_version == '14.04')
338342 # Note: docker_ver.empty? -> the latest version
339343 if docker_ver.empty? \
340- || Gem::Version.create(docker_ver.tr('~', '-')) >= Gem::Version.create('1.12')
344+ || gem_ver(docker_ver) >= gem_ver('1.12')
341345 extra_options = extra_options.gsub(%r{-H\sfd://}, '') # for frozen string.
342346 end
343347 end
348+if docker_ver.empty? \
349+ || gem_ver(docker_ver) > gem_ver('18.06.99')
350+ extra_options = extra_options.gsub(%r{-H\sfd://}, '-H unix://') # for frozen string.
351+end
344352
345353 docker_opts.push(extra_options) if !extra_options.nil? && !extra_options.empty?
346354
--- a/cookbooks/docker-grid/version
+++ b/cookbooks/docker-grid/version
@@ -1 +1 @@
1-1.3.2
1+1.3.3
Show on old repository browser