kitchen-dokken 1.1.1 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +3 -0
- data/lib/kitchen/driver/dokken.rb +46 -36
- data/lib/kitchen/driver/dokken_version.rb +1 -1
- data/lib/kitchen/helpers.rb +127 -0
- data/lib/kitchen/provisioner/dokken.rb +8 -10
- data/lib/kitchen/transport/dokken.rb +62 -71
- metadata +8 -13
- data/lib/kitchen/driver/dokken/helpers.rb +0 -75
- data/lib/kitchen/transport/dokken/helpers.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7c5b7b7002c7d29ca102d308c4181c17b6784a23
|
4
|
+
data.tar.gz: 2fd2ed37b36d7e06fc2052457ea7c55794c0a361
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a7a73124810ce381907b0be9d087a5de2a1fcad14c9d7f995f475d622bfd0a2c38ce82fb0b47bdee4ccef37ec487356d84e9e5fcf5fd7bcd1aaa4c47484d7c6
|
7
|
+
data.tar.gz: d9a383aae0f51ab4c6c860c63716a93eec01635a2209e890a6d277919a523c7a9600351a19082cb31774f08dc975c61712a65f0fc5204fc330ef358d4f949e0e
|
data/CHANGELOG.md
ADDED
@@ -19,9 +19,9 @@ require 'digest'
|
|
19
19
|
require 'kitchen'
|
20
20
|
require 'tmpdir'
|
21
21
|
require 'docker'
|
22
|
-
require_relative '
|
22
|
+
require_relative '../helpers'
|
23
23
|
|
24
|
-
include Dokken::
|
24
|
+
include Dokken::Helpers
|
25
25
|
|
26
26
|
# FIXME: - make true
|
27
27
|
Excon.defaults[:ssl_verify_peer] = false
|
@@ -35,8 +35,8 @@ module Kitchen
|
|
35
35
|
default_config :pid_one_command, 'sh -c "trap exit 0 SIGTERM; while :; do sleep 1; done"'
|
36
36
|
default_config :image_prefix, nil
|
37
37
|
default_config :chef_image, 'chef/chef'
|
38
|
-
default_config :chef_version, '
|
39
|
-
default_config :data_image, '
|
38
|
+
default_config :chef_version, 'current'
|
39
|
+
default_config :data_image, 'dokken/kitchen-cache:latest'
|
40
40
|
default_config :docker_host_url, default_docker_host
|
41
41
|
default_config :dns, nil
|
42
42
|
default_config :dns_search, nil
|
@@ -64,8 +64,12 @@ module Kitchen
|
|
64
64
|
create_chef_container state
|
65
65
|
|
66
66
|
# data
|
67
|
-
|
68
|
-
|
67
|
+
dokken_create_sandbox
|
68
|
+
|
69
|
+
if remote_docker_host?
|
70
|
+
make_data_image
|
71
|
+
start_data_container state
|
72
|
+
end
|
69
73
|
|
70
74
|
# work image
|
71
75
|
build_work_image state
|
@@ -78,8 +82,11 @@ module Kitchen
|
|
78
82
|
end
|
79
83
|
|
80
84
|
def destroy(_state)
|
81
|
-
|
82
|
-
|
85
|
+
if remote_docker_host?
|
86
|
+
stop_data_container
|
87
|
+
delete_data_container
|
88
|
+
end
|
89
|
+
|
83
90
|
stop_runner_container
|
84
91
|
delete_runner_container
|
85
92
|
delete_work_image
|
@@ -87,6 +94,11 @@ module Kitchen
|
|
87
94
|
|
88
95
|
private
|
89
96
|
|
97
|
+
def remote_docker_host?
|
98
|
+
return true if config[:docker_host_url] =~ /^tcp:/
|
99
|
+
false
|
100
|
+
end
|
101
|
+
|
90
102
|
def api_retries
|
91
103
|
config[:api_retries]
|
92
104
|
end
|
@@ -110,22 +122,18 @@ module Kitchen
|
|
110
122
|
end
|
111
123
|
|
112
124
|
def build_work_image(state)
|
113
|
-
|
114
|
-
|
125
|
+
info('Building work image..')
|
115
126
|
return if ::Docker::Image.exist?(work_image, {}, docker_connection)
|
116
127
|
|
117
128
|
begin
|
118
129
|
@intermediate_image = ::Docker::Image.build(
|
119
130
|
work_image_dockerfile,
|
120
131
|
{
|
121
|
-
|
122
|
-
# 'forcerm' => true,
|
123
|
-
# 'q' => true,
|
124
|
-
't' => work_image
|
132
|
+
't' => work_image,
|
125
133
|
},
|
126
134
|
docker_connection
|
127
135
|
)
|
128
|
-
rescue
|
136
|
+
rescue
|
129
137
|
raise "work_image build failed: #{e}"
|
130
138
|
end
|
131
139
|
|
@@ -146,11 +154,6 @@ module Kitchen
|
|
146
154
|
state[:image_prefix] = image_prefix
|
147
155
|
end
|
148
156
|
|
149
|
-
def instance_name
|
150
|
-
prefix = (Digest::SHA2.hexdigest FileUtils.pwd)[0,10]
|
151
|
-
"#{prefix}-#{instance.name}"
|
152
|
-
end
|
153
|
-
|
154
157
|
def delete_chef_container
|
155
158
|
debug "driver - deleting container #{chef_container_name}"
|
156
159
|
delete_container chef_container_name
|
@@ -189,6 +192,13 @@ module Kitchen
|
|
189
192
|
instance_name
|
190
193
|
end
|
191
194
|
|
195
|
+
def dokken_binds
|
196
|
+
ret = []
|
197
|
+
ret << "#{dokken_sandbox_path}:/opt/kitchen" unless dokken_sandbox_path.nil?
|
198
|
+
ret << config[:binds] unless config[:binds].nil?
|
199
|
+
ret
|
200
|
+
end
|
201
|
+
|
192
202
|
def start_runner_container(state)
|
193
203
|
debug "driver - starting #{runner_container_name}"
|
194
204
|
runner_container = run_container(
|
@@ -199,16 +209,19 @@ module Kitchen
|
|
199
209
|
'ExposedPorts' => exposed_ports({}, config[:forward]),
|
200
210
|
'HostConfig' => {
|
201
211
|
'Privileged' => config[:privileged],
|
202
|
-
'VolumesFrom' => [
|
203
|
-
|
212
|
+
'VolumesFrom' => [
|
213
|
+
chef_container_name,
|
214
|
+
# data_container_name
|
215
|
+
],
|
216
|
+
'Binds' => dokken_binds,
|
204
217
|
'Dns' => config[:dns],
|
205
|
-
'DnsSearch'=> config[:dns_search],
|
218
|
+
'DnsSearch' => config[:dns_search],
|
206
219
|
'Links' => Array(config[:links]),
|
207
220
|
'CapAdd' => Array(config[:cap_add]),
|
208
221
|
'CapDrop' => Array(config[:cap_drop]),
|
209
222
|
'SecurityOpt' => Array(config[:security_opt]),
|
210
223
|
'NetworkMode' => config[:network_mode],
|
211
|
-
'PortBindings' => port_forwards({}, config[:forward])
|
224
|
+
'PortBindings' => port_forwards({}, config[:forward]),
|
212
225
|
}
|
213
226
|
)
|
214
227
|
state[:runner_container] = runner_container.json
|
@@ -221,23 +234,19 @@ module Kitchen
|
|
221
234
|
'Image' => "#{repo(data_image)}:#{tag(data_image)}",
|
222
235
|
'HostConfig' => {
|
223
236
|
'PortBindings' => port_forwards({}, '22'),
|
224
|
-
'PublishAllPorts' => true
|
237
|
+
'PublishAllPorts' => true,
|
225
238
|
}
|
226
239
|
)
|
227
|
-
# require 'pry' ; binding.pry
|
228
240
|
state[:data_container] = data_container.json
|
229
241
|
end
|
230
242
|
|
231
243
|
def make_data_image
|
232
|
-
debug
|
233
|
-
|
234
|
-
# -- or --
|
235
|
-
# debug 'driver - calling create_data_image'
|
236
|
-
# create_data_image
|
244
|
+
debug 'driver - calling create_data_image'
|
245
|
+
create_data_image
|
237
246
|
end
|
238
247
|
|
239
248
|
def create_chef_container(state)
|
240
|
-
|
249
|
+
::Docker::Container.get(chef_container_name, {}, docker_connection)
|
241
250
|
rescue ::Docker::Error::NotFoundError
|
242
251
|
begin
|
243
252
|
debug "driver - creating volume container #{chef_container_name} from #{chef_image}"
|
@@ -265,7 +274,7 @@ module Kitchen
|
|
265
274
|
def delete_image(name)
|
266
275
|
with_retries { @image = ::Docker::Image.get(name, {}, docker_connection) }
|
267
276
|
with_retries { @image.remove(force: true) }
|
268
|
-
rescue ::Docker::Error
|
277
|
+
rescue ::Docker::Error
|
269
278
|
puts "Image #{name} not found. Nothing to delete."
|
270
279
|
end
|
271
280
|
|
@@ -305,7 +314,7 @@ module Kitchen
|
|
305
314
|
def stop_container(name)
|
306
315
|
with_retries { @container = ::Docker::Container.get(name, {}, docker_connection) }
|
307
316
|
with_retries do
|
308
|
-
@container.stop(force:
|
317
|
+
@container.stop(force: false)
|
309
318
|
wait_running_state(name, false)
|
310
319
|
end
|
311
320
|
rescue ::Docker::Error::NotFoundError
|
@@ -344,6 +353,7 @@ module Kitchen
|
|
344
353
|
end
|
345
354
|
|
346
355
|
def chef_version
|
356
|
+
return 'current' if config[:chef_version] == 'latest'
|
347
357
|
config[:chef_version]
|
348
358
|
end
|
349
359
|
|
@@ -361,7 +371,7 @@ module Kitchen
|
|
361
371
|
|
362
372
|
def exposed_ports(config, rules)
|
363
373
|
Array(rules).each do |prt_string|
|
364
|
-
guest,
|
374
|
+
guest, _host = prt_string.to_s.split(':').reverse
|
365
375
|
config["#{guest}/tcp"] = {}
|
366
376
|
end
|
367
377
|
config
|
@@ -371,7 +381,7 @@ module Kitchen
|
|
371
381
|
Array(rules).each do |prt_string|
|
372
382
|
guest, host = prt_string.to_s.split(':').reverse
|
373
383
|
config["#{guest}/tcp"] = [{
|
374
|
-
HostPort: host || ''
|
384
|
+
HostPort: host || '',
|
375
385
|
}]
|
376
386
|
end
|
377
387
|
config
|
@@ -0,0 +1,127 @@
|
|
1
|
+
module Dokken
|
2
|
+
module Helpers
|
3
|
+
def insecure_ssh_public_key
|
4
|
+
<<-EOF
|
5
|
+
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCoJwyW7qNhw+NTuOjC4+RVpESl+JBXebXzB7JqxRgKAbymq6B39azEAiNx5NzHkWcQmOyQNhFpKFSAufegcXRS4ctS1LcElEoXe9brDAqKEBSkmnXYfZXMNIG0Enw4+5W/rZxHFCAlsUSAHYtYZEs+3CgbIWuHhZ95C8UC6nGLWHNZOjcbsYZFrnFfO0qg0ene2w8LKhxqj5X0MRSdCIn1IwyxIbl5NND5Yk1Hx8JKsJtTiNTdxssiMgmM5bvTbYQUSf8pbGrRI30VQKBgQ8/UkidZbaTfvzWXYpwcDUERSbzEYCvkUytTemZIv6uhpPxqkfjl6KEOOml/iGqquPEr test-kitchen-rsa
|
6
|
+
EOF
|
7
|
+
end
|
8
|
+
|
9
|
+
def insecure_ssh_private_key
|
10
|
+
<<-EOF
|
11
|
+
-----BEGIN RSA PRIVATE KEY-----
|
12
|
+
MIIEpAIBAAKCAQEAqCcMlu6jYcPjU7jowuPkVaREpfiQV3m18weyasUYCgG8pqug
|
13
|
+
d/WsxAIjceTcx5FnEJjskDYRaShUgLn3oHF0UuHLUtS3BJRKF3vW6wwKihAUpJp1
|
14
|
+
2H2VzDSBtBJ8OPuVv62cRxQgJbFEgB2LWGRLPtwoGyFrh4WfeQvFAupxi1hzWTo3
|
15
|
+
G7GGRa5xXztKoNHp3tsPCyocao+V9DEUnQiJ9SMMsSG5eTTQ+WJNR8fCSrCbU4jU
|
16
|
+
3cbLIjIJjOW7022EFEn/KWxq0SN9FUCgYEPP1JInWW2k3781l2KcHA1BEUm8xGAr
|
17
|
+
5FMrU3pmSL+roaT8apH45eihDjppf4hqqrjxKwIDAQABAoIBAEj7Cb/IOykHd/ay
|
18
|
+
XnOXrVZuQU03oI4WyR19zbYBbPmK33IHM1JdUmqP8wpPpnMHbJALj0DX9p6JXoOw
|
19
|
+
MwVzuGTwkuqUYAqgwbeHjDPfugNKD2uRjmwztXw3ncOl8jxZFRloJFfFKF6znWNt
|
20
|
+
bzkh7naN3upHiv/6wsgqj4tAbZ9oRC1crO6bsNr3P6YooiG5RRNpHepiyXphyhN6
|
21
|
+
We1p5ZOQ/pUSE0Ca4wTlUhJHTUPMz7VFs/8CH0loRIsGPBROarPkoLVF+/UNyX8e
|
22
|
+
+BGMhoUtQH2XvjEzWUl5jKJOnvKRIV+0j/upWXsPQKF5glVPmPrTVUAxThfu6rAa
|
23
|
+
4Z3JveECgYEA0Pz3Hl0SlPR79r2qofh1ZNa8zvQDL+iLopULwDiil5qlUxJ+DgOl
|
24
|
+
1kWXLhjdg/NfoTBHvBjdJu274YJgaGQOfCy5747YDVsakKOm4bI9+Jr2agshPyE6
|
25
|
+
f1RNmGL8K8fNtpGq4G14o+pSQOPNrEfcFKgm3sosZWJAWaA64hmtiXcCgYEAzfp6
|
26
|
+
FbodfUypAV5Zd6PCO2eJMjLdvGaNuH/Umo80WNV7XZ6iJ6MUeQe+YwxFJigjC3ii
|
27
|
+
ifLUj3kL7+wu7sEtkzS3zNd34KfhQ5fLADttfFgjjfm7IxlDD4ABaUgjwZM2gfXi
|
28
|
+
xCwRhwwNgilF6qABJ1CLt8JSqKubkqvO1P1gQu0CgYEA0GA6AcNpYK344Eey1/bF
|
29
|
+
DntyHKN+fglPGReldM7Dh4gBabgZid2nP+N5XtQaIpPKeQyLqgfckhEecTau68dA
|
30
|
+
Dh4Gcs6pq394GFmkbotrcPMJ2SgpySlXi1fCWrvvlbON8IiDqWxdiop74wmArFOm
|
31
|
+
I86ZmzBYXeo+IV869vAFcPcCgYBrvvyh5OuMIc++YYZXaRgvTueblLQc22CDBItI
|
32
|
+
FmUBmxqfTF3ycgJBlWVoFoENhq1eUMplctrx+hXeeSPLzM10VX1X79ZLdEYHv513
|
33
|
+
D58kDk7684mKwKotr34NfqkFl2ZJ8T+f8pVwmUNvtPtX0j8IO7/6bfIjPTFyNeFJ
|
34
|
+
1QjHuQKBgQC/LE05M4eeWXihZ7c7fyWHLyddcPdH48LRF9UH9yjKF84jXRT91uMv
|
35
|
+
XuIb2Qt4MLHABySsk653LDw/jTIGV26c068nZryq5OUPxk67Xgod54jKgOwjgjZS
|
36
|
+
X8N2N9ZNnORJqK374yGj1jWUU66mQhPvn49QpG8P2HEoh2RQjNvyHA==
|
37
|
+
-----END RSA PRIVATE KEY-----
|
38
|
+
EOF
|
39
|
+
end
|
40
|
+
|
41
|
+
def data_dockerfile
|
42
|
+
<<-EOF
|
43
|
+
FROM centos:7
|
44
|
+
MAINTAINER Sean OMeara \"sean@sean.io\"
|
45
|
+
|
46
|
+
ENV LANG en_US.UTF-8
|
47
|
+
|
48
|
+
RUN yum -y install tar rsync openssh-server passwd git
|
49
|
+
RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''
|
50
|
+
|
51
|
+
RUN mkdir -p /root/.ssh/
|
52
|
+
COPY authorized_keys /root/.ssh/authorized_keys
|
53
|
+
|
54
|
+
EXPOSE 22
|
55
|
+
CMD [ "/usr/sbin/sshd", "-D", "-p", "22", "-o", "UseDNS=no", "-o", "UsePrivilegeSeparation=no", "-o", "MaxAuthTries=60" ]
|
56
|
+
|
57
|
+
VOLUME /opt/kitchen
|
58
|
+
VOLUME /opt/verifier
|
59
|
+
EOF
|
60
|
+
end
|
61
|
+
|
62
|
+
def create_data_image
|
63
|
+
return if ::Docker::Image.exist?(data_image)
|
64
|
+
|
65
|
+
tmpdir = Dir.tmpdir
|
66
|
+
FileUtils.mkdir_p "#{tmpdir}/dokken"
|
67
|
+
File.write("#{tmpdir}/dokken/Dockerfile", data_dockerfile)
|
68
|
+
File.write("#{tmpdir}/dokken/authorized_keys", insecure_ssh_public_key)
|
69
|
+
|
70
|
+
i = ::Docker::Image.build_from_dir(
|
71
|
+
"#{tmpdir}/dokken",
|
72
|
+
'nocache' => true,
|
73
|
+
'rm' => true
|
74
|
+
)
|
75
|
+
i.tag('repo' => repo(data_image), 'tag' => tag(data_image), 'force' => true)
|
76
|
+
end
|
77
|
+
|
78
|
+
def default_docker_host
|
79
|
+
if ENV['DOCKER_HOST']
|
80
|
+
ENV['DOCKER_HOST']
|
81
|
+
elsif File.exist?('/var/run/docker.sock')
|
82
|
+
'unix:///var/run/docker.sock'
|
83
|
+
# TODO: Docker for Windows also operates over a named pipe at
|
84
|
+
# //./pipe/docker_engine that can be used if named pipe support is
|
85
|
+
# added to the docker-api gem.
|
86
|
+
else
|
87
|
+
'tcp://127.0.0.1:2375'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def dokken_create_sandbox
|
92
|
+
info("Creating local sandbox in #{dokken_sandbox_path}")
|
93
|
+
FileUtils.mkdir_p(dokken_sandbox_path)
|
94
|
+
File.chmod(0755, dokken_sandbox_path)
|
95
|
+
end
|
96
|
+
|
97
|
+
def dokken_sandbox_path
|
98
|
+
"#{Dir.home}/.dokken/sandbox/#{instance_name}"
|
99
|
+
end
|
100
|
+
|
101
|
+
def instance_name
|
102
|
+
prefix = (Digest::SHA2.hexdigest FileUtils.pwd)[0, 10]
|
103
|
+
"#{prefix}-#{instance.name}"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
module Kitchen
|
109
|
+
module Provisioner
|
110
|
+
class Base
|
111
|
+
def create_sandbox
|
112
|
+
info("Creating local sandbox in #{sandbox_path}")
|
113
|
+
FileUtils.mkdir_p(sandbox_path)
|
114
|
+
File.chmod(0755, sandbox_path)
|
115
|
+
end
|
116
|
+
|
117
|
+
def sandbox_path
|
118
|
+
"#{Dir.home}/.dokken/sandbox/#{instance_name}"
|
119
|
+
end
|
120
|
+
|
121
|
+
def instance_name
|
122
|
+
prefix = (Digest::SHA2.hexdigest FileUtils.pwd)[0, 10]
|
123
|
+
"#{prefix}-#{instance.name}"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
#
|
3
|
-
# Author:: Sean OMeara (<sean@
|
3
|
+
# Author:: Sean OMeara (<sean@sean.io>)
|
4
4
|
#
|
5
5
|
# Copyright (C) 2015, Sean OMeara
|
6
6
|
#
|
@@ -18,10 +18,13 @@
|
|
18
18
|
|
19
19
|
require 'kitchen'
|
20
20
|
require 'kitchen/provisioner/chef_zero'
|
21
|
+
require_relative '../helpers'
|
22
|
+
|
23
|
+
include Dokken::Helpers
|
21
24
|
|
22
25
|
module Kitchen
|
23
26
|
module Provisioner
|
24
|
-
# @author Sean OMeara <sean@
|
27
|
+
# @author Sean OMeara <sean@sean.io>
|
25
28
|
class Dokken < Kitchen::Provisioner::ChefZero
|
26
29
|
kitchen_provisioner_api_version 2
|
27
30
|
|
@@ -32,23 +35,18 @@ module Kitchen
|
|
32
35
|
# (see Base#call)
|
33
36
|
def call(state)
|
34
37
|
create_sandbox
|
35
|
-
sandbox_dirs = Dir.glob(File.join(sandbox_path, '*'))
|
36
|
-
|
37
38
|
instance.transport.connection(state) do |conn|
|
38
|
-
info("Transferring files to #{instance.to_str}")
|
39
|
-
conn.upload(sandbox_dirs, config[:root_path])
|
40
|
-
debug('Transfer complete')
|
41
39
|
conn.execute(run_command)
|
42
40
|
end
|
43
41
|
rescue Kitchen::Transport::TransportFailed => ex
|
44
42
|
raise ActionFailed, ex.message
|
45
|
-
|
46
|
-
cleanup_sandbox
|
43
|
+
# ensure
|
44
|
+
# cleanup_sandbox
|
47
45
|
end
|
48
46
|
|
49
47
|
private
|
50
48
|
|
51
|
-
#
|
49
|
+
# patching Kitchen::Provisioner::ChefZero#run_command
|
52
50
|
def run_command
|
53
51
|
cmd = '/opt/chef/embedded/bin/chef-client'
|
54
52
|
cmd << ' -z'
|
@@ -19,9 +19,9 @@ require 'kitchen'
|
|
19
19
|
require 'net/scp'
|
20
20
|
require 'tmpdir'
|
21
21
|
require 'digest/sha1'
|
22
|
-
require_relative '
|
22
|
+
require_relative '../helpers'
|
23
23
|
|
24
|
-
include Dokken::
|
24
|
+
include Dokken::Helpers
|
25
25
|
|
26
26
|
module Kitchen
|
27
27
|
module Transport
|
@@ -35,7 +35,7 @@ module Kitchen
|
|
35
35
|
#
|
36
36
|
# @author Sean OMeara <sean@chef.io>
|
37
37
|
class Dokken < Kitchen::Transport::Base
|
38
|
-
kitchen_transport_api_version
|
38
|
+
kitchen_transport_api_version 2
|
39
39
|
|
40
40
|
plugin_version Kitchen::VERSION
|
41
41
|
|
@@ -43,7 +43,7 @@ module Kitchen
|
|
43
43
|
default_config :read_timeout, 3600
|
44
44
|
default_config :write_timeout, 3600
|
45
45
|
default_config :host_ip_override do |transport|
|
46
|
-
transport.docker_for_mac_or_win? ?
|
46
|
+
transport.docker_for_mac_or_win? ? 'localhost' : false
|
47
47
|
end
|
48
48
|
|
49
49
|
# (see Base#connection)
|
@@ -72,72 +72,61 @@ module Kitchen
|
|
72
72
|
@exit_code = o[2]
|
73
73
|
end
|
74
74
|
|
75
|
-
if @exit_code != 0
|
76
|
-
raise Transport::DockerExecFailed,
|
77
|
-
"Docker Exec (#{@exit_code}) for command: [#{command}]"
|
78
|
-
end
|
79
|
-
|
80
|
-
# Disabling this for now.. the Docker ZFS driver won't let us
|
81
|
-
# commit running containers.
|
82
|
-
#
|
83
|
-
# with_retries { @old_image = ::Docker::Image.get(work_image, {}, docker_connection) }
|
84
|
-
# with_retries { @new_image = @runner.commit }
|
85
|
-
# with_retries { @new_image.tag('repo' => work_image, 'tag' => 'latest', 'force' => 'true') }
|
86
|
-
# with_retries { @old_image.remove }
|
75
|
+
raise Transport::DockerExecFailed, "Docker Exec (#{@exit_code}) for command: [#{command}]" if @exit_code != 0
|
87
76
|
end
|
88
77
|
|
89
|
-
def upload(locals, remote)
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
end
|
78
|
+
# def upload(locals, remote)
|
79
|
+
# port = options[:data_container][:NetworkSettings][:Ports][:"22/tcp"][0][:HostPort]
|
80
|
+
|
81
|
+
# if options[:host_ip_override]
|
82
|
+
# # Allow connecting to any ip/hostname to support sibling containers
|
83
|
+
# ip = options[:host_ip_override]
|
84
|
+
# elsif options[:docker_host_url] =~ /unix:/
|
85
|
+
# if options[:data_container][:NetworkSettings][:Ports][:"22/tcp"][0][:HostIp] == '0.0.0.0'
|
86
|
+
# ip = options[:data_container][:NetworkSettings][:IPAddress]
|
87
|
+
# port = '22'
|
88
|
+
# else
|
89
|
+
# # we should read the proper mapped ip, since this allows us to upload the files
|
90
|
+
# ip = options[:data_container][:NetworkSettings][:Ports][:"22/tcp"][0][:HostIp]
|
91
|
+
# end
|
92
|
+
# elsif options[:docker_host_url] =~ /tcp:/
|
93
|
+
# ip = options[:docker_host_url].split('tcp://')[1].split(':')[0]
|
94
|
+
# else
|
95
|
+
# raise Kitchen::UserError, 'docker_host_url must be tcp:// or unix://'
|
96
|
+
# end
|
97
|
+
|
98
|
+
# tmpdir = Dir.tmpdir
|
99
|
+
# FileUtils.mkdir_p "#{tmpdir}/dokken"
|
100
|
+
# File.write("#{tmpdir}/dokken/id_rsa", insecure_ssh_private_key)
|
101
|
+
# FileUtils.chmod(0600, "#{tmpdir}/dokken/id_rsa")
|
102
|
+
|
103
|
+
# begin
|
104
|
+
# rsync_cmd = '/usr/bin/rsync -a -e'
|
105
|
+
# rsync_cmd << ' \''
|
106
|
+
# rsync_cmd << 'ssh -2'
|
107
|
+
# rsync_cmd << " -i #{tmpdir}/dokken/id_rsa"
|
108
|
+
# rsync_cmd << ' -o CheckHostIP=no'
|
109
|
+
# rsync_cmd << ' -o Compression=no'
|
110
|
+
# rsync_cmd << ' -o PasswordAuthentication=no'
|
111
|
+
# rsync_cmd << ' -o StrictHostKeyChecking=no'
|
112
|
+
# rsync_cmd << ' -o UserKnownHostsFile=/dev/null'
|
113
|
+
# rsync_cmd << ' -o LogLevel=ERROR'
|
114
|
+
# rsync_cmd << " -p #{port}"
|
115
|
+
# rsync_cmd << '\''
|
116
|
+
# rsync_cmd << " #{locals.join(' ')} root@#{ip}:#{remote}"
|
117
|
+
# `#{rsync_cmd}`
|
118
|
+
# rescue Errno::ENOENT
|
119
|
+
# debug 'Rsync is not installed. Falling back to SCP.'
|
120
|
+
# locals.each do |local|
|
121
|
+
# Net::SCP.upload!(ip,
|
122
|
+
# 'root',
|
123
|
+
# local,
|
124
|
+
# remote,
|
125
|
+
# recursive: true,
|
126
|
+
# ssh: { port: port, keys: ["#{tmpdir}/dokken/id_rsa"] })
|
127
|
+
# end
|
128
|
+
# end
|
129
|
+
# end
|
141
130
|
|
142
131
|
def login_command
|
143
132
|
@runner = options[:instance_name].to_s
|
@@ -180,7 +169,10 @@ module Kitchen
|
|
180
169
|
#
|
181
170
|
# @return [TrueClass,FalseClass]
|
182
171
|
def docker_for_mac_or_win?
|
183
|
-
|
172
|
+
# require 'pry' ; binding.pry
|
173
|
+
::Docker.info(::Docker::Connection.new(config[:docker_host_url], {}))['Name'] == 'moby'
|
174
|
+
rescue
|
175
|
+
false
|
184
176
|
end
|
185
177
|
|
186
178
|
private
|
@@ -191,7 +183,7 @@ module Kitchen
|
|
191
183
|
# @param data [Hash] merged configuration and mutable state data
|
192
184
|
# @return [Hash] hash of connection options
|
193
185
|
# @api private
|
194
|
-
def connection_options(data)
|
186
|
+
def connection_options(data)
|
195
187
|
opts = {}
|
196
188
|
opts[:host_ip_override] = config[:host_ip_override]
|
197
189
|
opts[:docker_host_url] = config[:docker_host_url]
|
@@ -213,7 +205,6 @@ module Kitchen
|
|
213
205
|
@connection.close
|
214
206
|
end
|
215
207
|
|
216
|
-
@connection_options = options
|
217
208
|
@connection = Kitchen::Transport::Dokken::Connection.new(options, &block)
|
218
209
|
end
|
219
210
|
|
metadata
CHANGED
@@ -1,35 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-dokken
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean OMeara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-kitchen
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.13'
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '3.0'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '1.13'
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '3.0'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: docker-api
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -51,13 +45,13 @@ executables: []
|
|
51
45
|
extensions: []
|
52
46
|
extra_rdoc_files: []
|
53
47
|
files:
|
48
|
+
- CHANGELOG.md
|
54
49
|
- LICENSE
|
55
50
|
- lib/kitchen/driver/dokken.rb
|
56
|
-
- lib/kitchen/driver/dokken/helpers.rb
|
57
51
|
- lib/kitchen/driver/dokken_version.rb
|
52
|
+
- lib/kitchen/helpers.rb
|
58
53
|
- lib/kitchen/provisioner/dokken.rb
|
59
54
|
- lib/kitchen/transport/dokken.rb
|
60
|
-
- lib/kitchen/transport/dokken/helpers.rb
|
61
55
|
homepage: https://github.com/someara/kitchen-dokken
|
62
56
|
licenses:
|
63
57
|
- Apache-2.0
|
@@ -77,7 +71,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
71
|
- !ruby/object:Gem::Version
|
78
72
|
version: '0'
|
79
73
|
requirements: []
|
80
|
-
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 2.6.8
|
81
76
|
signing_key:
|
82
77
|
specification_version: 4
|
83
78
|
summary: A Test Kitchen Driver that talks to the Docker Remote API and uses Volumes
|
@@ -1,75 +0,0 @@
|
|
1
|
-
module Dokken
|
2
|
-
module Driver
|
3
|
-
module Helpers
|
4
|
-
def insecure_ssh_public_key
|
5
|
-
<<-EOF
|
6
|
-
ssh-dss AAAAB3NzaC1kc3MAAACBANmw8lqXnnGoQ0LusVNr/716mQhEgxb8RYQbg+HP0w//XXVZki2iSC7/LhQEdYgUZaBYJKpBNQ3FSIvyfM5RksicEF10jv/QQ+gsQKHf/jyWTLSiiaSJiwhDrkNW94V/T2pczXlK2j5UiyGKA6UDmSeiS6Ve969nqLJLb77xWOlXAAAAFQCsaq9PvaFa+SXUfWYV9JrDskPtywAAAIBmTuJyTAqdy+xPiI7AFI+BCuWpjrczBs/aw3R5ArNaRf3/PBUumpAUCePJ6UPcw5vU74AloCYvcUnwU8IbZ/Oj6A5NGTo6HvIajP2Y8E17cjsMTXzTPbuT1SqkrlVcsQtJpHU/+WBGoUJeWg66/CjUp/Nx2YK+6QJzoALBLyJW+AAAAIEAyi7XX3Ev12AXgpwRPPbfVltJ9H5Hpll34gc2ORhmCSL6RE42BpAXuzI7lbGun2dXFsCdDm0DQz3h4JHtTHePd6xXqyPpUda4ktLVtEWMm0XIQNE8P5zP0gcfqVe4prOYeBLwrvAkyeNY5wosgzGHrQ+/hFwW3s8liEjZaFDhCWY= test-kitchen
|
7
|
-
EOF
|
8
|
-
end
|
9
|
-
|
10
|
-
def insecure_ssh_private_key
|
11
|
-
<<-EOF
|
12
|
-
-----BEGIN DSA PRIVATE KEY-----
|
13
|
-
MIIBuwIBAAKBgQDZsPJal55xqENC7rFTa/+9epkIRIMW/EWEG4Phz9MP/111WZIt
|
14
|
-
okgu/y4UBHWIFGWgWCSqQTUNxUiL8nzOUZLInBBddI7/0EPoLECh3/48lky0oomk
|
15
|
-
iYsIQ65DVveFf09qXM15Sto+VIshigOlA5knokulXvevZ6iyS2++8VjpVwIVAKxq
|
16
|
-
r0+9oVr5JdR9ZhX0msOyQ+3LAoGAZk7ickwKncvsT4iOwBSPgQrlqY63MwbP2sN0
|
17
|
-
eQKzWkX9/zwVLpqQFAnjyelD3MOb1O+AJaAmL3FJ8FPCG2fzo+gOTRk6Oh7yGoz9
|
18
|
-
mPBNe3I7DE180z27k9UqpK5VXLELSaR1P/lgRqFCXloOuvwo1KfzcdmCvukCc6AC
|
19
|
-
wS8iVvgCgYEAyi7XX3Ev12AXgpwRPPbfVltJ9H5Hpll34gc2ORhmCSL6RE42BpAX
|
20
|
-
uzI7lbGun2dXFsCdDm0DQz3h4JHtTHePd6xXqyPpUda4ktLVtEWMm0XIQNE8P5zP
|
21
|
-
0gcfqVe4prOYeBLwrvAkyeNY5wosgzGHrQ+/hFwW3s8liEjZaFDhCWYCFASgG6eP
|
22
|
-
vVnsIrCx2rI5/KEQZ+oG
|
23
|
-
-----END DSA PRIVATE KEY-----
|
24
|
-
EOF
|
25
|
-
end
|
26
|
-
|
27
|
-
def data_dockerfile
|
28
|
-
<<-EOF
|
29
|
-
FROM centos:7
|
30
|
-
MAINTAINER Sean OMeara \"sean@sean.io\"
|
31
|
-
|
32
|
-
ENV LANG en_US.UTF-8
|
33
|
-
|
34
|
-
RUN yum -y install tar rsync openssh-server passwd git
|
35
|
-
RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''
|
36
|
-
RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ''
|
37
|
-
|
38
|
-
RUN mkdir -p /root/.ssh/
|
39
|
-
COPY authorized_keys /root/.ssh/authorized_keys
|
40
|
-
|
41
|
-
EXPOSE 22
|
42
|
-
CMD [ "/usr/sbin/sshd", "-D", "-p", "22", "-o", "UseDNS=no", "-o", "UsePrivilegeSeparation=no" ]
|
43
|
-
|
44
|
-
VOLUME /opt/kitchen
|
45
|
-
VOLUME /opt/verifier
|
46
|
-
EOF
|
47
|
-
end
|
48
|
-
|
49
|
-
def create_data_image
|
50
|
-
return if ::Docker::Image.exist?(data_image)
|
51
|
-
|
52
|
-
tmpdir = Dir.tmpdir
|
53
|
-
FileUtils.mkdir_p "#{tmpdir}/dokken"
|
54
|
-
File.write("#{tmpdir}/dokken/Dockerfile", data_dockerfile)
|
55
|
-
File.write("#{tmpdir}/dokken/authorized_keys", insecure_ssh_public_key)
|
56
|
-
|
57
|
-
i = ::Docker::Image.build_from_dir("#{tmpdir}/dokken", 'nocache' => true, 'rm' => true)
|
58
|
-
i.tag('repo' => repo(data_image), 'tag' => tag(data_image), 'force' => true)
|
59
|
-
end
|
60
|
-
|
61
|
-
def default_docker_host
|
62
|
-
if ENV['DOCKER_HOST']
|
63
|
-
ENV['DOCKER_HOST']
|
64
|
-
elsif File.exist?('/var/run/docker.sock')
|
65
|
-
'unix:///var/run/docker.sock'
|
66
|
-
# TODO: Docker for Windows also operates over a named pipe at
|
67
|
-
# //./pipe/docker_engine that can be used if named pipe support is
|
68
|
-
# added to the docker-api gem.
|
69
|
-
else
|
70
|
-
'tcp://127.0.0.1:2375'
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Dokken
|
2
|
-
module Transport
|
3
|
-
module Helpers
|
4
|
-
def insecure_ssh_private_key
|
5
|
-
<<-EOF
|
6
|
-
-----BEGIN DSA PRIVATE KEY-----
|
7
|
-
MIIBuwIBAAKBgQDZsPJal55xqENC7rFTa/+9epkIRIMW/EWEG4Phz9MP/111WZIt
|
8
|
-
okgu/y4UBHWIFGWgWCSqQTUNxUiL8nzOUZLInBBddI7/0EPoLECh3/48lky0oomk
|
9
|
-
iYsIQ65DVveFf09qXM15Sto+VIshigOlA5knokulXvevZ6iyS2++8VjpVwIVAKxq
|
10
|
-
r0+9oVr5JdR9ZhX0msOyQ+3LAoGAZk7ickwKncvsT4iOwBSPgQrlqY63MwbP2sN0
|
11
|
-
eQKzWkX9/zwVLpqQFAnjyelD3MOb1O+AJaAmL3FJ8FPCG2fzo+gOTRk6Oh7yGoz9
|
12
|
-
mPBNe3I7DE180z27k9UqpK5VXLELSaR1P/lgRqFCXloOuvwo1KfzcdmCvukCc6AC
|
13
|
-
wS8iVvgCgYEAyi7XX3Ev12AXgpwRPPbfVltJ9H5Hpll34gc2ORhmCSL6RE42BpAX
|
14
|
-
uzI7lbGun2dXFsCdDm0DQz3h4JHtTHePd6xXqyPpUda4ktLVtEWMm0XIQNE8P5zP
|
15
|
-
0gcfqVe4prOYeBLwrvAkyeNY5wosgzGHrQ+/hFwW3s8liEjZaFDhCWYCFASgG6eP
|
16
|
-
vVnsIrCx2rI5/KEQZ+oG
|
17
|
-
-----END DSA PRIVATE KEY-----
|
18
|
-
EOF
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|