chef-provisioning-docker 0.5.2 → 0.6
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/README.md +20 -8
- data/lib/chef/provisioning/docker_driver/chef_zero_http_proxy.rb +50 -47
- data/lib/chef/provisioning/docker_driver/docker_container_machine.rb +2 -1
- data/lib/chef/provisioning/docker_driver/docker_transport.rb +7 -0
- data/lib/chef/provisioning/docker_driver/driver.rb +1 -0
- data/lib/chef/provisioning/docker_driver/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ec4b5e583d16fa9f00cc14e0504dd3d9e8d392f
|
4
|
+
data.tar.gz: 2af59e90c819b9f9cb2a3a57f82be6c9cd64e299
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f0f8a74d6b873cf3e69147dba79ebe8d6c112f53d3cde7b20dbff8511672b259ccea10dece62cedcb41da24c33fe6b0ff37481f810269bf48acd714865d2cbe
|
7
|
+
data.tar.gz: 36a5c76b1528709222cf23305f0a289db028e82304a2ee538f12ef1a19380d97f6fc56a0733803e9748cccd09637363bd34a6a2dc7aa51b1730fb1967e60933e
|
data/README.md
CHANGED
@@ -14,37 +14,49 @@ This will run Chef-zero and use the description stored in docker_ubuntu_image.rb
|
|
14
14
|
|
15
15
|
Using this , you can then define a machine similar to the following example:
|
16
16
|
|
17
|
-
```ruby
|
17
|
+
```ruby
|
18
18
|
require 'chef/provisioning/docker_driver'
|
19
19
|
|
20
20
|
machine 'wario' do
|
21
21
|
recipe 'openssh::default'
|
22
|
-
|
22
|
+
|
23
23
|
machine_options :docker_options => {
|
24
24
|
:base_image => {
|
25
25
|
:name => 'ubuntu',
|
26
26
|
:repository => 'ubuntu',
|
27
27
|
:tag => '14.04'
|
28
28
|
},
|
29
|
-
:command => '/usr/sbin/sshd -p 8022 -D',
|
29
|
+
:command => '/usr/sbin/sshd -p 8022 -D',
|
30
30
|
|
31
31
|
#ENV (Environment Variables)
|
32
32
|
#Set any env var in the container by using one or more -e flags, even overriding those already defined by the developer with a Dockerfile ENV
|
33
33
|
:env => {
|
34
34
|
"deep" => 'purple',
|
35
35
|
"led" => 'zeppelin'
|
36
|
-
}
|
37
|
-
|
36
|
+
},
|
37
|
+
|
38
38
|
# Ports can be one of two forms:
|
39
39
|
# src_port (string or integer) is a pass-through, i.e 8022 or "9933"
|
40
40
|
# src:dst (string) is a map from src to dst, i.e "8022:8023" maps 8022 externally to 8023 in the container
|
41
41
|
|
42
42
|
# Example (multiple):
|
43
|
-
:ports => [8022, "8023:9000", "9500"]
|
43
|
+
:ports => [8022, "8023:9000", "9500"],
|
44
44
|
|
45
45
|
# Examples (single):
|
46
|
-
:ports => 1234
|
47
|
-
:ports => "2345:6789"
|
46
|
+
:ports => 1234,
|
47
|
+
:ports => "2345:6789",
|
48
|
+
|
49
|
+
# Volumes can be one of three forms:
|
50
|
+
# src_volume (string) is volume to add to container, i.e. creates new volume inside container at "/tmp"
|
51
|
+
# src:dst (string) mounts host's directory src to container's dst, i.e "/tmp:/tmp1" mounts host's directory /tmp to container's /tmp1
|
52
|
+
# src:dst:mode (string) mounts host's directory src to container's dst with the specified mount option, i.e "/:/rootfs:ro" mounts read-only host's root (/) folder to container's /rootfs
|
53
|
+
# See more details on Docker volumes at https://github.com/docker/docker/blob/master/docs/sources/userguide/dockervolumes.md .
|
54
|
+
|
55
|
+
# Example (single):
|
56
|
+
:volumes => "/tmp",
|
57
|
+
|
58
|
+
# Example (multiple):
|
59
|
+
:volumes => ["/tmp:/tmp", "/:/rootfs:ro"],
|
48
60
|
|
49
61
|
# if you need to keep stdin open (i.e docker run -i)
|
50
62
|
# :keep_stdin_open => true
|
@@ -16,77 +16,80 @@ class ChefZeroHttpProxy
|
|
16
16
|
|
17
17
|
# Start our server to handle connections (will raise things on errors)
|
18
18
|
@socket = TCPServer.new @local_address, @local_port
|
19
|
-
|
19
|
+
|
20
20
|
# Handle every request in another thread
|
21
21
|
loop do
|
22
22
|
s = @socket.accept
|
23
23
|
Thread.new s, &method(:handle_request)
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
ensure
|
27
27
|
@socket.close if @socket
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def handle_request(to_client)
|
32
|
-
|
32
|
+
begin
|
33
|
+
request_line = to_client.readline
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
verb = request_line[/^\w+/]
|
36
|
+
url = request_line[/^\w+\s+(\S+)/, 1]
|
37
|
+
version = request_line[/HTTP\/(1\.\d)\s*$/, 1]
|
38
|
+
uri = URI::parse url
|
38
39
|
|
39
|
-
|
40
|
-
|
40
|
+
# Show what got requested
|
41
|
+
Chef::Log.debug("[C->S]: #{verb} -> #{url}")
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
querystr = if uri.query
|
44
|
+
"#{uri.path}?#{uri.query}"
|
45
|
+
else
|
46
|
+
uri.path
|
47
|
+
end
|
47
48
|
|
48
|
-
|
49
|
+
to_server = TCPSocket.new(@remote_address, @remote_port)
|
49
50
|
|
50
|
-
|
51
|
+
to_server.write("#{verb} #{querystr} HTTP/#{version}\r\n")
|
51
52
|
|
52
|
-
|
53
|
+
content_len = 0
|
53
54
|
|
54
|
-
|
55
|
-
|
55
|
+
loop do
|
56
|
+
line = to_client.readline
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
58
|
+
if line =~ /^Content-Length:\s+(\d+)\s*$/
|
59
|
+
content_len = $1.to_i
|
60
|
+
end
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
# Strip proxy headers
|
63
|
+
if line =~ /^proxy/i
|
64
|
+
next
|
65
|
+
elsif line.strip.empty?
|
66
|
+
to_server.write("Connection: close\r\n\r\n")
|
66
67
|
|
67
|
-
|
68
|
-
|
69
|
-
|
68
|
+
if content_len >= 0
|
69
|
+
to_server.write(to_client.read(content_len))
|
70
|
+
Chef::Log.debug("[C->S]: Wrote #{content_len} bytes")
|
71
|
+
end
|
72
|
+
|
73
|
+
break
|
74
|
+
else
|
75
|
+
to_server.write(line)
|
70
76
|
end
|
77
|
+
end
|
71
78
|
|
72
|
-
|
73
|
-
|
74
|
-
|
79
|
+
buff = ''
|
80
|
+
while to_server.read(8192, buff)
|
81
|
+
to_client.write(buff)
|
75
82
|
end
|
76
|
-
end
|
77
83
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
to_client.write(buff)
|
82
|
-
break if buff.size < 8192
|
83
|
-
end
|
84
|
+
rescue
|
85
|
+
Chef::Log.error $!
|
86
|
+
raise
|
84
87
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
+
ensure
|
89
|
+
# Close the sockets
|
90
|
+
to_client.close
|
91
|
+
to_server.close
|
92
|
+
end
|
88
93
|
end
|
89
|
-
|
94
|
+
|
90
95
|
end
|
91
|
-
|
92
|
-
|
@@ -14,6 +14,7 @@ module DockerDriver
|
|
14
14
|
@env = opts[:env]
|
15
15
|
@command = opts[:command]
|
16
16
|
@ports = opts[:ports]
|
17
|
+
@volumes = opts[:volumes]
|
17
18
|
@keep_stdin_open = opts[:keep_stdin_open]
|
18
19
|
@container_name = machine_spec.location['container_name']
|
19
20
|
@transport = transport
|
@@ -27,7 +28,7 @@ module DockerDriver
|
|
27
28
|
super action_handler
|
28
29
|
if @command
|
29
30
|
Chef::Log.debug("DockerContainerMachine converge complete, executing #{@command} in #{@container_name}")
|
30
|
-
@transport.execute(@command, :env => @env ,:detached => true, :read_only => true, :ports => @ports, :keep_stdin_open => @keep_stdin_open)
|
31
|
+
@transport.execute(@command, :env => @env ,:detached => true, :read_only => true, :ports => @ports, :volumes => @volumes, :keep_stdin_open => @keep_stdin_open)
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
@@ -227,6 +227,7 @@ module DockerDriver
|
|
227
227
|
:command => docker_options[:command],
|
228
228
|
:env => docker_options[:env],
|
229
229
|
:ports => [].push(docker_options[:ports]).flatten,
|
230
|
+
:volumes => [].push(docker_options[:volumes]).flatten.compact,
|
230
231
|
:keep_stdin_open => docker_options[:keep_stdin_open]
|
231
232
|
)
|
232
233
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-provisioning-docker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.6'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Duffield
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef
|
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
131
|
version: '0'
|
132
132
|
requirements: []
|
133
133
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.
|
134
|
+
rubygems_version: 2.4.5
|
135
135
|
signing_key:
|
136
136
|
specification_version: 4
|
137
137
|
summary: Provisioner for creating Docker containers in Chef Provisioning.
|