Grid環境構築用のChefリポジトリです。
リビジョン | a4a55b0b529cb2b90cf1374bdf5466209ddde136 (tree) |
---|---|
日時 | 2018-11-10 14:43:52 |
作者 | whitestar <whitestar@user...> |
コミッター | whitestar |
adds docker-ce-18.09 support.
@@ -10,6 +10,10 @@ Lint/UnusedBlockArgument: | ||
10 | 10 | Enabled: false |
11 | 11 | Metrics/AbcSize: |
12 | 12 | Enabled: false |
13 | +Metrics/CyclomaticComplexity: | |
14 | + Max: 7 | |
15 | +Metrics/MethodLength: | |
16 | + Max: 17 | |
13 | 17 | Style/BlockComments: |
14 | 18 | Enabled: false |
15 | 19 | Style/BlockDelimiters: |
@@ -35,7 +39,5 @@ Metrics/BlockNesting: | ||
35 | 39 | Max: 4 |
36 | 40 | #Style/AccessorMethodName: |
37 | 41 | # Enabled: false |
38 | -#Metrics/MethodLength: | |
39 | -# Max: 15 | |
40 | 42 | #Style/ModuleLength: |
41 | 43 | # Max: 150 |
@@ -1,5 +1,9 @@ | ||
1 | 1 | # docker-grid CHANGELOG |
2 | 2 | |
3 | +1.3.3 | |
4 | +----- | |
5 | +- adds docker-ce-18.09 support. | |
6 | + | |
3 | 7 | 1.3.2 |
4 | 8 | ----- |
5 | 9 | - adds the latest Ubuntu support. |
@@ -14,6 +14,7 @@ task :init do | ||
14 | 14 | '.foodcritic', |
15 | 15 | '.rubocop.yml', |
16 | 16 | 'Berksfile', |
17 | + 'chefignore', | |
17 | 18 | 'concourse.yml', |
18 | 19 | 'fly-vars.yml', |
19 | 20 | 'fly-vars.local.yml', |
@@ -36,6 +37,7 @@ task :update do | ||
36 | 37 | |
37 | 38 | [ |
38 | 39 | 'Rakefile', |
40 | + 'chefignore', | |
39 | 41 | 'concourse.yml', |
40 | 42 | 'fly-vars.yml', |
41 | 43 | 'Gemfile', |
@@ -17,6 +17,8 @@ | ||
17 | 17 | # limitations under the License. |
18 | 18 | # |
19 | 19 | |
20 | +::Chef::Node::Attribute.send(:include, DockerGrid::Helper) | |
21 | + | |
20 | 22 | platform = node['platform'] |
21 | 23 | |
22 | 24 | default['docker-grid']['install_flavor'] = 'dockerproject' # or 'os-repository' |
@@ -99,9 +101,9 @@ default['docker-grid']['engine']['autopilot'] = { | ||
99 | 101 | # os-repository: yum list docker |
100 | 102 | # http://mirror.centos.org/centos/7.3.1611/extras/x86_64/Packages/ |
101 | 103 | 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 | |
103 | 105 | 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 | |
105 | 107 | # os-repository: http://packages.ubuntu.com/search?keywords=docker.io&searchon=names |
106 | 108 | default['docker-grid']['engine']['version_on_ubuntu'] = '17.12.1~ce-0' |
107 | 109 |
@@ -110,38 +112,19 @@ case platform | ||
110 | 112 | when 'centos', 'redhat' |
111 | 113 | version_on_centos = node['docker-grid']['engine']['version_on_centos'] |
112 | 114 | 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) | |
118 | 116 | end |
119 | 117 | when 'debian' |
120 | 118 | 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) | |
130 | 122 | end |
131 | 123 | when 'ubuntu' |
132 | 124 | 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) | |
145 | 128 | end |
146 | 129 | end |
147 | 130 |
@@ -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/* |
@@ -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 |
@@ -35,6 +35,11 @@ enable_new_repo = node['docker-grid']['dockerproject']['enable_new_repo'] | ||
35 | 35 | engine_conf = node['docker-grid']['engine'] |
36 | 36 | docker_ver = engine_conf['version'] |
37 | 37 | 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 | |
38 | 43 | storage_driver = engine_conf['storage-driver'] |
39 | 44 | userns_remap = engine_conf['userns-remap'] |
40 | 45 |
@@ -43,6 +48,7 @@ if engine_conf['skip_setup'] | ||
43 | 48 | return |
44 | 49 | end |
45 | 50 | |
51 | +::Chef::Recipe.send(:include, DockerGrid::Helper) | |
46 | 52 | ::Chef::Recipe.send(:include, PlatformUtils::Helper) |
47 | 53 | ::Chef::Recipe.send(:include, PlatformUtils::VirtUtils) |
48 | 54 |
@@ -74,16 +80,14 @@ if shell_out("cat /etc/mtab | grep -E '\s+/\s+zfs\s+'").exitstatus.zero? | ||
74 | 80 | end |
75 | 81 | |
76 | 82 | 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') | |
79 | 84 | Chef::Application.fatal!('Docker version must be 1.12 or later for overlay2 storage driver.') # and exit. |
80 | 85 | end |
81 | 86 | end |
82 | 87 | load_kernel_module('overlay') if storage_driver =~ /overlay2?/ |
83 | 88 | |
84 | 89 | 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') | |
87 | 91 | Chef::Application.fatal!('Docker version must be 1.10 or later for userns-remap.') # and exit. |
88 | 92 | end |
89 | 93 |
@@ -337,10 +341,14 @@ extra_options = engine_conf['daemon_extra_options'] | ||
337 | 341 | if platform_family == 'rhel' || platform == 'debian' || (platform == 'ubuntu' && platform_version == '14.04') |
338 | 342 | # Note: docker_ver.empty? -> the latest version |
339 | 343 | 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') | |
341 | 345 | extra_options = extra_options.gsub(%r{-H\sfd://}, '') # for frozen string. |
342 | 346 | end |
343 | 347 | 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 | |
344 | 352 | |
345 | 353 | docker_opts.push(extra_options) if !extra_options.nil? && !extra_options.empty? |
346 | 354 |
@@ -1 +1 @@ | ||
1 | -1.3.2 | |
1 | +1.3.3 |