kitchen-docker 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -2
- data/README.md +51 -38
- data/lib/kitchen/driver/docker.rb +37 -1
- data/lib/kitchen/driver/docker_version.rb +1 -1
- data/test/integration/capabilities/serverspec/capabilities_drop_spec.rb +1 -3
- data/test/integration/capabilities/serverspec/spec_helper.rb +3 -0
- data/test/integration/default/serverspec/default_spec.rb +1 -4
- data/test/integration/default/serverspec/spec_helper.rb +4 -0
- metadata +6 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b939e9c2b0904be1588251727d88e41cdf7860c5
|
|
4
|
+
data.tar.gz: feeb4a93431ac53e63787d78b1430223e5340b30
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ce018dcd2008f84c802cb9050b05c84d239bcc903b53cdcee34791d40f4b4af3c39569df906b42a6b55a935850bd6c9e7562133ea201d6c58e2bcee0ede084b6
|
|
7
|
+
data.tar.gz: e6b5607abd8c8243d80aba28c04303e33d391cf3e09732d036634957cfc139cfa92248f26c158e4a39836ad4747c36fe73a9f124446d6eb205fef9f46c67dba8
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## 2.2.0
|
|
2
|
+
|
|
3
|
+
* Use a temporary file for each suite instance Docker container
|
|
4
|
+
Dockerfile, instead of passing their contents via STDIN. This allows for
|
|
5
|
+
the use of commands like ADD and COPY. **Users must now use Docker >= 1.5.0**
|
|
6
|
+
|
|
7
|
+
* Passwordless suite instance Docker container login (SSH), using a
|
|
8
|
+
generated key pair.
|
|
9
|
+
|
|
10
|
+
* Support for sharing a host device with suite instance Docker containers.
|
|
11
|
+
|
|
12
|
+
* README YAML highlighting.
|
|
13
|
+
|
|
14
|
+
## 2.1.0
|
|
15
|
+
|
|
16
|
+
* Use `NUL` instead of `/dev/null` on Windows for output redirection
|
|
17
|
+
|
|
1
18
|
## 2.0.0
|
|
2
19
|
|
|
3
20
|
* Use Docker `top` and `port` instead of `inspect`
|
|
@@ -22,9 +39,9 @@
|
|
|
22
39
|
|
|
23
40
|
* `publish_all` option to publish all ports to the host interface
|
|
24
41
|
|
|
25
|
-
* `instance_name` option to name the
|
|
42
|
+
* `instance_name` option to name the Docker container
|
|
26
43
|
|
|
27
|
-
* `links` option to link suite instance
|
|
44
|
+
* `links` option to link suite instance Docker containers
|
|
28
45
|
|
|
29
46
|
* `socket` option will now default to ENV `DOCKER_HOST` if set
|
|
30
47
|
|
data/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Please read the Test Kitchen [docs][test_kitchen_docs] for more details.
|
|
|
12
12
|
|
|
13
13
|
Example `.kitchen.local.yml`:
|
|
14
14
|
|
|
15
|
-
```
|
|
15
|
+
```yaml
|
|
16
16
|
---
|
|
17
17
|
driver:
|
|
18
18
|
name: docker
|
|
@@ -36,7 +36,7 @@ platforms.
|
|
|
36
36
|
|
|
37
37
|
Examples:
|
|
38
38
|
|
|
39
|
-
```
|
|
39
|
+
```yaml
|
|
40
40
|
---
|
|
41
41
|
platforms:
|
|
42
42
|
- name: ubuntu-12.04
|
|
@@ -45,7 +45,7 @@ platforms:
|
|
|
45
45
|
|
|
46
46
|
This will effectively generate a configuration similar to:
|
|
47
47
|
|
|
48
|
-
```
|
|
48
|
+
```yaml
|
|
49
49
|
---
|
|
50
50
|
platforms:
|
|
51
51
|
- name: ubuntu-12.04
|
|
@@ -68,11 +68,11 @@ The default value is `docker`.
|
|
|
68
68
|
|
|
69
69
|
Examples:
|
|
70
70
|
|
|
71
|
-
```
|
|
71
|
+
```yaml
|
|
72
72
|
binary: docker.io
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
```
|
|
75
|
+
```yaml
|
|
76
76
|
binary: /opt/docker
|
|
77
77
|
```
|
|
78
78
|
|
|
@@ -86,17 +86,17 @@ to suite containers.
|
|
|
86
86
|
|
|
87
87
|
Examples:
|
|
88
88
|
|
|
89
|
-
```
|
|
89
|
+
```yaml
|
|
90
90
|
socket: unix:///tmp/docker.sock
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
-
```
|
|
93
|
+
```yaml
|
|
94
94
|
socket: tcp://docker.example.com:4242
|
|
95
95
|
```
|
|
96
96
|
|
|
97
97
|
If you use [Boot2Docker](https://github.com/boot2docker/boot2docker), set your `DOCKER_HOST` environment variable properly (e.g. `export DOCKER_HOST=tcp://192.168.59.103:2375`) or you have to use the following:
|
|
98
98
|
|
|
99
|
-
```
|
|
99
|
+
```yaml
|
|
100
100
|
socket: tcp://192.168.59.103:2375
|
|
101
101
|
```
|
|
102
102
|
|
|
@@ -150,17 +150,17 @@ Custom command(s) to be run when provisioning the base for the suite containers.
|
|
|
150
150
|
|
|
151
151
|
Examples:
|
|
152
152
|
|
|
153
|
-
```
|
|
153
|
+
```yaml
|
|
154
154
|
provision_command: curl -L https://www.opscode.com/chef/install.sh | bash
|
|
155
155
|
```
|
|
156
156
|
|
|
157
|
-
```
|
|
157
|
+
```yaml
|
|
158
158
|
provision_command:
|
|
159
159
|
- apt-get install dnsutils
|
|
160
160
|
- apt-get install telnet
|
|
161
161
|
```
|
|
162
162
|
|
|
163
|
-
```
|
|
163
|
+
```yaml
|
|
164
164
|
driver_config:
|
|
165
165
|
provision_command: curl -L https://www.opscode.com/chef/install.sh | bash
|
|
166
166
|
require_chef_omnibus: false
|
|
@@ -192,11 +192,11 @@ The default value is `false`.
|
|
|
192
192
|
|
|
193
193
|
Sets the command used to run the suite container.
|
|
194
194
|
|
|
195
|
-
The default value is `/usr/sbin/sshd -D -o UseDNS=no -o UsePAM=no -o PasswordAuthentication=yes`.
|
|
195
|
+
The default value is `/usr/sbin/sshd -D -o UseDNS=no -o UsePAM=no -o PasswordAuthentication=yes -o UsePrivilegeSeparation=no -o PidFile=/tmp/sshd.pid`.
|
|
196
196
|
|
|
197
197
|
Examples:
|
|
198
198
|
|
|
199
|
-
```
|
|
199
|
+
```yaml
|
|
200
200
|
run_command: /sbin/init
|
|
201
201
|
```
|
|
202
202
|
|
|
@@ -216,11 +216,11 @@ Adds a data volume(s) to the suite container.
|
|
|
216
216
|
|
|
217
217
|
Examples:
|
|
218
218
|
|
|
219
|
-
```
|
|
219
|
+
```yaml
|
|
220
220
|
volume: /ftp
|
|
221
221
|
```
|
|
222
222
|
|
|
223
|
-
```
|
|
223
|
+
```yaml
|
|
224
224
|
volume:
|
|
225
225
|
- /ftp
|
|
226
226
|
- /srv
|
|
@@ -232,11 +232,11 @@ Mount volumes managed by other containers.
|
|
|
232
232
|
|
|
233
233
|
Examples:
|
|
234
234
|
|
|
235
|
-
```
|
|
235
|
+
```yaml
|
|
236
236
|
volumes_from: repos
|
|
237
237
|
```
|
|
238
238
|
|
|
239
|
-
```
|
|
239
|
+
```yaml
|
|
240
240
|
volumes_from:
|
|
241
241
|
- repos
|
|
242
242
|
- logging
|
|
@@ -250,11 +250,11 @@ Dockers defaults.
|
|
|
250
250
|
|
|
251
251
|
Examples:
|
|
252
252
|
|
|
253
|
-
```
|
|
253
|
+
```yaml
|
|
254
254
|
dns: 8.8.8.8
|
|
255
255
|
```
|
|
256
256
|
|
|
257
|
-
```
|
|
257
|
+
```yaml
|
|
258
258
|
dns:
|
|
259
259
|
- 8.8.8.8
|
|
260
260
|
- 8.8.4.4
|
|
@@ -265,7 +265,7 @@ Sets an http proxy for the suite container using the `http_proxy` environment va
|
|
|
265
265
|
|
|
266
266
|
Examples:
|
|
267
267
|
|
|
268
|
-
```
|
|
268
|
+
```yaml
|
|
269
269
|
http_proxy: http://proxy.host.com:8080
|
|
270
270
|
```
|
|
271
271
|
### https\_proxy
|
|
@@ -274,7 +274,7 @@ Sets an https proxy for the suite container using the `https_proxy` environment
|
|
|
274
274
|
|
|
275
275
|
Examples:
|
|
276
276
|
|
|
277
|
-
```
|
|
277
|
+
```yaml
|
|
278
278
|
https_proxy: http://proxy.host.com:8080
|
|
279
279
|
```
|
|
280
280
|
### forward
|
|
@@ -284,11 +284,11 @@ the host (public) port in the mappings, if not, Docker chooses for you.
|
|
|
284
284
|
|
|
285
285
|
Examples:
|
|
286
286
|
|
|
287
|
-
```
|
|
287
|
+
```yaml
|
|
288
288
|
forward: 80
|
|
289
289
|
```
|
|
290
290
|
|
|
291
|
-
```
|
|
291
|
+
```yaml
|
|
292
292
|
forward:
|
|
293
293
|
- 22:2222
|
|
294
294
|
- 80:8080
|
|
@@ -300,7 +300,7 @@ Set the suite container hostname. Otherwise use Dockers default.
|
|
|
300
300
|
|
|
301
301
|
Examples:
|
|
302
302
|
|
|
303
|
-
```
|
|
303
|
+
```yaml
|
|
304
304
|
hostname: foobar.local
|
|
305
305
|
```
|
|
306
306
|
|
|
@@ -313,7 +313,7 @@ The default value is `false`.
|
|
|
313
313
|
|
|
314
314
|
Examples:
|
|
315
315
|
|
|
316
|
-
```
|
|
316
|
+
```yaml
|
|
317
317
|
privileged: true
|
|
318
318
|
```
|
|
319
319
|
|
|
@@ -323,11 +323,11 @@ Adds a capability to the running container.
|
|
|
323
323
|
|
|
324
324
|
Examples:
|
|
325
325
|
|
|
326
|
-
|
|
326
|
+
```yaml
|
|
327
327
|
cap_add:
|
|
328
328
|
- SYS_PTRACE
|
|
329
329
|
|
|
330
|
-
|
|
330
|
+
```
|
|
331
331
|
|
|
332
332
|
### cap\_drop
|
|
333
333
|
|
|
@@ -335,11 +335,10 @@ Drops a capability from the running container.
|
|
|
335
335
|
|
|
336
336
|
Examples:
|
|
337
337
|
|
|
338
|
-
|
|
338
|
+
```yaml
|
|
339
339
|
cap_drop:
|
|
340
340
|
- CHOWN
|
|
341
|
-
|
|
342
|
-
````
|
|
341
|
+
```
|
|
343
342
|
|
|
344
343
|
### security\_opt
|
|
345
344
|
|
|
@@ -349,7 +348,7 @@ profiles to grant access to specific resources.
|
|
|
349
348
|
|
|
350
349
|
Examples:
|
|
351
350
|
|
|
352
|
-
```
|
|
351
|
+
```yaml
|
|
353
352
|
security_opt:
|
|
354
353
|
- apparmor:my_profile
|
|
355
354
|
```
|
|
@@ -360,7 +359,7 @@ Use a custom Dockerfile, instead of having Kitchen-Docker build one for you.
|
|
|
360
359
|
|
|
361
360
|
Examples:
|
|
362
361
|
|
|
363
|
-
```
|
|
362
|
+
```yaml
|
|
364
363
|
dockerfile: test/Dockerfile
|
|
365
364
|
```
|
|
366
365
|
|
|
@@ -370,7 +369,7 @@ Set the name of container to link to other container(s).
|
|
|
370
369
|
|
|
371
370
|
Examples:
|
|
372
371
|
|
|
373
|
-
```
|
|
372
|
+
```yaml
|
|
374
373
|
instance_name: web
|
|
375
374
|
```
|
|
376
375
|
|
|
@@ -380,13 +379,11 @@ Set ```instance_name```(and alias) of other container(s) that connect from the s
|
|
|
380
379
|
|
|
381
380
|
Examples:
|
|
382
381
|
|
|
383
|
-
```
|
|
382
|
+
```yaml
|
|
384
383
|
links: db:db
|
|
385
384
|
```
|
|
386
385
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
```
|
|
386
|
+
```yaml
|
|
390
387
|
links:
|
|
391
388
|
- db:db
|
|
392
389
|
- kvs:kvs
|
|
@@ -401,10 +398,26 @@ The default value is `false`.
|
|
|
401
398
|
|
|
402
399
|
Examples:
|
|
403
400
|
|
|
404
|
-
```
|
|
401
|
+
```yaml
|
|
405
402
|
publish_all: true
|
|
406
403
|
```
|
|
407
404
|
|
|
405
|
+
### devices
|
|
406
|
+
|
|
407
|
+
Share a host device with the container. Host device must be an absolute path.
|
|
408
|
+
|
|
409
|
+
Examples:
|
|
410
|
+
|
|
411
|
+
```
|
|
412
|
+
devices: /dev/vboxdrv
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
```
|
|
416
|
+
devices:
|
|
417
|
+
- /dev/vboxdrv
|
|
418
|
+
- /dev/vboxnetctl
|
|
419
|
+
```
|
|
420
|
+
|
|
408
421
|
## Development
|
|
409
422
|
|
|
410
423
|
* Source hosted at [GitHub][repo]
|
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
|
|
17
17
|
require 'kitchen'
|
|
18
18
|
require 'json'
|
|
19
|
+
require 'securerandom'
|
|
19
20
|
require 'uri'
|
|
21
|
+
require 'net/ssh'
|
|
20
22
|
require File.join(File.dirname(__FILE__), 'docker', 'erb')
|
|
21
23
|
|
|
22
24
|
module Kitchen
|
|
@@ -47,6 +49,8 @@ module Kitchen
|
|
|
47
49
|
default_config :tls_key, nil
|
|
48
50
|
default_config :publish_all, false
|
|
49
51
|
default_config :wait_for_sshd, true
|
|
52
|
+
default_config :private_key, File.join(Dir.pwd, '.kitchen', 'docker_id_rsa')
|
|
53
|
+
default_config :public_key, File.join(Dir.pwd, '.kitchen', 'docker_id_rsa.pub')
|
|
50
54
|
|
|
51
55
|
default_config :use_sudo do |driver|
|
|
52
56
|
!driver.remote_socket?
|
|
@@ -91,6 +95,8 @@ module Kitchen
|
|
|
91
95
|
end
|
|
92
96
|
|
|
93
97
|
def create(state)
|
|
98
|
+
generate_keys
|
|
99
|
+
state[:ssh_key] = config[:private_key]
|
|
94
100
|
state[:image_id] = build_image(state) unless state[:image_id]
|
|
95
101
|
state[:container_id] = run_container(state) unless state[:container_id]
|
|
96
102
|
state[:hostname] = remote_socket? ? socket_uri.host : 'localhost'
|
|
@@ -126,6 +132,22 @@ module Kitchen
|
|
|
126
132
|
run_command("#{docker} #{cmd}", options.merge(:quiet => !logger.debug?))
|
|
127
133
|
end
|
|
128
134
|
|
|
135
|
+
def generate_keys
|
|
136
|
+
if !File.exist?(config[:public_key]) || !File.exist?(config[:private_key])
|
|
137
|
+
private_key = OpenSSL::PKey::RSA.new(2048)
|
|
138
|
+
blobbed_key = Base64.encode64(private_key.to_blob).gsub("\n", '')
|
|
139
|
+
public_key = "ssh-rsa #{blobbed_key} kitchen_docker_key"
|
|
140
|
+
File.open(config[:private_key], 'w') do |file|
|
|
141
|
+
file.write(private_key)
|
|
142
|
+
file.chmod(0600)
|
|
143
|
+
end
|
|
144
|
+
File.open(config[:public_key], 'w') do |file|
|
|
145
|
+
file.write(public_key)
|
|
146
|
+
file.chmod(0600)
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
129
151
|
def build_dockerfile
|
|
130
152
|
from = "FROM #{config[:image]}"
|
|
131
153
|
platform = case config[:platform]
|
|
@@ -172,8 +194,11 @@ module Kitchen
|
|
|
172
194
|
raise ActionFailed,
|
|
173
195
|
"Unknown platform '#{config[:platform]}'"
|
|
174
196
|
end
|
|
197
|
+
|
|
175
198
|
username = config[:username]
|
|
176
199
|
password = config[:password]
|
|
200
|
+
public_key = IO.read(config[:public_key])
|
|
201
|
+
|
|
177
202
|
base = <<-eos
|
|
178
203
|
RUN if ! getent passwd #{username}; then useradd -d /home/#{username} -m -s /bin/bash #{username}; fi
|
|
179
204
|
RUN echo #{username}:#{password} | chpasswd
|
|
@@ -181,6 +206,12 @@ module Kitchen
|
|
|
181
206
|
RUN mkdir -p /etc/sudoers.d
|
|
182
207
|
RUN echo '#{username} ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/#{username}
|
|
183
208
|
RUN chmod 0440 /etc/sudoers.d/#{username}
|
|
209
|
+
RUN [ ! -d /home/#{username}/.ssh ] && mkdir /home/#{username}/.ssh
|
|
210
|
+
RUN chown -R #{username} /home/#{username}/.ssh
|
|
211
|
+
RUN chmod 0700 /home/#{username}/.ssh
|
|
212
|
+
RUN echo '#{public_key}' >> /home/#{username}/.ssh/authorized_keys
|
|
213
|
+
RUN chown #{username} /home/#{username}/.ssh/authorized_keys
|
|
214
|
+
RUN chmod 0600 /home/#{username}/.ssh/authorized_keys
|
|
184
215
|
eos
|
|
185
216
|
custom = ''
|
|
186
217
|
Array(config[:provision_command]).each do |cmd|
|
|
@@ -212,7 +243,11 @@ module Kitchen
|
|
|
212
243
|
def build_image(state)
|
|
213
244
|
cmd = "build"
|
|
214
245
|
cmd << " --no-cache" unless config[:use_cache]
|
|
215
|
-
output =
|
|
246
|
+
output = Tempfile.create('Dockerfile-kitchen-', Dir.pwd) do |file|
|
|
247
|
+
file.write(dockerfile)
|
|
248
|
+
file.close
|
|
249
|
+
docker_command("#{cmd} -f #{file.path} .")
|
|
250
|
+
end
|
|
216
251
|
parse_image_id(output)
|
|
217
252
|
end
|
|
218
253
|
|
|
@@ -233,6 +268,7 @@ module Kitchen
|
|
|
233
268
|
Array(config[:volume]).each {|volume| cmd << " -v #{volume}"}
|
|
234
269
|
Array(config[:volumes_from]).each {|container| cmd << " --volumes-from #{container}"}
|
|
235
270
|
Array(config[:links]).each {|link| cmd << " --link #{link}"}
|
|
271
|
+
Array(config[:devices]).each {|device| cmd << " --device #{device}"}
|
|
236
272
|
cmd << " --name #{config[:instance_name]}" if config[:instance_name]
|
|
237
273
|
cmd << " -P" if config[:publish_all]
|
|
238
274
|
cmd << " -h #{config[:hostname]}" if config[:hostname]
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kitchen-docker
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sean Porter
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-07-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: test-kitchen
|
|
@@ -117,7 +117,9 @@ files:
|
|
|
117
117
|
- lib/kitchen/driver/docker_version.rb
|
|
118
118
|
- test/Dockerfile
|
|
119
119
|
- test/integration/capabilities/serverspec/capabilities_drop_spec.rb
|
|
120
|
+
- test/integration/capabilities/serverspec/spec_helper.rb
|
|
120
121
|
- test/integration/default/serverspec/default_spec.rb
|
|
122
|
+
- test/integration/default/serverspec/spec_helper.rb
|
|
121
123
|
homepage: https://github.com/portertech/kitchen-docker
|
|
122
124
|
licenses:
|
|
123
125
|
- Apache 2.0
|
|
@@ -145,4 +147,6 @@ summary: A Docker Driver for Test Kitchen
|
|
|
145
147
|
test_files:
|
|
146
148
|
- test/Dockerfile
|
|
147
149
|
- test/integration/capabilities/serverspec/capabilities_drop_spec.rb
|
|
150
|
+
- test/integration/capabilities/serverspec/spec_helper.rb
|
|
148
151
|
- test/integration/default/serverspec/default_spec.rb
|
|
152
|
+
- test/integration/default/serverspec/spec_helper.rb
|