clc-fork-chef-metal 0.12.1.alpha.4 → 0.13.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +29 -6
- data/lib/chef/provider/machine.rb +3 -0
- data/lib/chef/provider/machine_batch.rb +2 -0
- data/lib/chef_metal.rb +5 -1
- data/lib/chef_metal/convergence_strategy/install_sh.rb +3 -1
- data/lib/chef_metal/transport/ssh.rb +57 -6
- data/lib/chef_metal/transport/winrm.rb +5 -8
- data/lib/chef_metal/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92fd9ce1269e598cb791750506afc09fe1ebd514
|
4
|
+
data.tar.gz: 51fbc3e51bb706e79995554ee1f9f433077f2b16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84fc7691daf6f62d12d8f8bed0e621a3c62b2f195efbb6afb9c9efa29d6615290c51894c588bc0005f1ac62e78ebb7aa5d5b10decd2013896401712450e191e1
|
7
|
+
data.tar.gz: f7dfa7d4df6eaecd8635118c9a2afc2e60ae25c5b98b94f1d53a4704d239ea323ff02e3dab61a44b8225fb7eabf99d772548b1d1a24fdc2e439c614cddd44fcc
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -13,6 +13,13 @@ Date | Blog
|
|
13
13
|
3/4/2014 | [Chef Metal 0.2: Overview](http://www.getchef.com/blog/2014/03/04/chef-metal-0-2-release/) - this is a pretty good overview (though dated).
|
14
14
|
12/20/2013 | [Chef Metal Alpha](http://www.getchef.com/blog/2013/12/20/chef-metal-alpha/)
|
15
15
|
|
16
|
+
Documentation
|
17
|
+
-------------
|
18
|
+
* [Configuration](https://github.com/opscode/chef-metal/blob/master/docs/configuration.md#configuring-and-using-metal-drivers)
|
19
|
+
* [Writing Drivers](https://github.com/opscode/chef-metal/blob/master/docs/building_drivers.md#writing-drivers)
|
20
|
+
* [Embedding](https://github.com/opscode/chef-metal/blob/master/docs/embedding.md)
|
21
|
+
* [Providers](https://github.com/opscode/chef-metal/blob/master/docs/providers)
|
22
|
+
|
16
23
|
Try It Out
|
17
24
|
----------
|
18
25
|
|
@@ -218,17 +225,33 @@ with_chef_server "https://chef-server.example.org",
|
|
218
225
|
:signing_key_filename => Chef::Config[:client_key]
|
219
226
|
```
|
220
227
|
|
228
|
+
**Note for Hosted/Enterprise Chef Servers**
|
229
|
+
|
230
|
+
Currently, you will need to add the 'clients' group to the 'admin' group in order for machine provisioning to work:
|
231
|
+
|
232
|
+
```
|
233
|
+
knife edit /groups/admin.json -e <editor>
|
234
|
+
```
|
235
|
+
Then add:
|
236
|
+
```
|
237
|
+
{
|
238
|
+
"users": [
|
239
|
+
"pivotal" # This is an internal superuser for Hosted/Enterprise Chef
|
240
|
+
],
|
241
|
+
"groups": [
|
242
|
+
"clients" # This is what you need to add
|
243
|
+
]
|
244
|
+
}
|
245
|
+
```
|
246
|
+
|
247
|
+
This can also be done through the Chef Server web UI (Administration tab > Groups > select admins Group > Add 'clients'
|
248
|
+
|
249
|
+
|
221
250
|
Kitchen
|
222
251
|
-------
|
223
252
|
|
224
253
|
Chef Metal also works with Test Kitchen, allowing you to test entire clusters, not just machines! The repository for the kitchen-metal gem is https://github.com/doubt72/kitchen-metal.
|
225
254
|
|
226
|
-
Documentation
|
227
|
-
-------------
|
228
|
-
* [Configuration](https://github.com/opscode/chef-metal/blob/master/docs/configuration.md#configuring-and-using-metal-drivers)
|
229
|
-
* [Writing Drivers](https://github.com/opscode/chef-metal/blob/master/docs/building_drivers.md#writing-drivers)
|
230
|
-
* [Embedding](https://github.com/opscode/chef-metal/blob/master/docs/embedding.md)
|
231
|
-
|
232
255
|
Bugs and The Plan
|
233
256
|
-----------------
|
234
257
|
|
@@ -20,6 +20,9 @@ class Chef::Provider::Machine < Chef::Provider::LWRPBase
|
|
20
20
|
if current_driver && current_driver.driver_url != new_driver.driver_url
|
21
21
|
raise "Cannot move '#{machine_spec.name}' from #{current_driver.driver_url} to #{new_driver.driver_url}: machine moving is not supported. Destroy and recreate."
|
22
22
|
end
|
23
|
+
if !new_driver
|
24
|
+
raise "Driver not specified for machine #{machine_spec.name}"
|
25
|
+
end
|
23
26
|
new_driver.allocate_machine(action_handler, machine_spec, new_machine_options)
|
24
27
|
machine_spec.save(action_handler)
|
25
28
|
end
|
data/lib/chef_metal.rb
CHANGED
@@ -71,9 +71,13 @@ module ChefMetal
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def self.connect_to_machine(machine_spec, config = Cheffish.profiled_config)
|
74
|
+
chef_server = Cheffish.default_chef_server(config)
|
75
|
+
if machine_spec.is_a?(String)
|
76
|
+
machine_spec = ChefMachineSpec.get(machine_spec, chef_server)
|
77
|
+
end
|
74
78
|
driver = driver_for_url(machine_spec.driver_url, config)
|
75
79
|
if driver
|
76
|
-
machine_options = { :convergence_options => { :chef_server =>
|
80
|
+
machine_options = { :convergence_options => { :chef_server => chef_server } }
|
77
81
|
machine_options = Cheffish::MergedConfig.new(config[:machine_options], machine_options) if config[:machine_options]
|
78
82
|
driver.connect_to_machine(machine_spec, machine_options)
|
79
83
|
else
|
@@ -14,11 +14,13 @@ module ChefMetal
|
|
14
14
|
super(convergence_options, config)
|
15
15
|
@install_sh_url = convergence_options[:install_sh_url] || 'http://www.opscode.com/chef/install.sh'
|
16
16
|
@install_sh_path = convergence_options[:install_sh_path] || '/tmp/chef-install.sh'
|
17
|
+
@bootstrap_env = convergence_options[:bootstrap_proxy] ? "http_proxy=#{convergence_options[:bootstrap_proxy]}" : ""
|
17
18
|
@chef_client_timeout = convergence_options.has_key?(:chef_client_timeout) ? convergence_options[:chef_client_timeout] : 120*60 # Default: 2 hours
|
18
19
|
end
|
19
20
|
|
20
21
|
attr_reader :install_sh_url
|
21
22
|
attr_reader :install_sh_path
|
23
|
+
attr_reader :bootstrap_env
|
22
24
|
|
23
25
|
def setup_convergence(action_handler, machine)
|
24
26
|
super
|
@@ -28,7 +30,7 @@ module ChefMetal
|
|
28
30
|
# TODO ssh verification of install.sh before running arbtrary code would be nice?
|
29
31
|
@@install_sh_cache[install_sh_url] ||= Net::HTTP.get(URI(install_sh_url))
|
30
32
|
machine.write_file(action_handler, install_sh_path, @@install_sh_cache[install_sh_url], :ensure_dir => true)
|
31
|
-
machine.execute(action_handler, "bash #{install_sh_path}")
|
33
|
+
machine.execute(action_handler, "bash -c '#{bootstrap_env} bash #{install_sh_path}'")
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'chef_metal/transport'
|
2
|
+
require 'chef/log'
|
2
3
|
require 'uri'
|
3
4
|
require 'socket'
|
4
5
|
require 'timeout'
|
@@ -108,14 +109,20 @@ module ChefMetal
|
|
108
109
|
|
109
110
|
def make_url_available_to_remote(local_url)
|
110
111
|
uri = URI(local_url)
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
112
|
+
if is_local_machine(uri.host)
|
113
|
+
port, host = forward_port(uri.port, uri.host, uri.port, 'localhost')
|
114
|
+
if !port
|
115
|
+
# Try harder if the port is already taken
|
116
|
+
port, host = forward_port(uri.port, uri.host, 0, 'localhost')
|
117
|
+
if !port
|
118
|
+
raise "Error forwarding port: could not forward #{uri.port} or 0"
|
119
|
+
end
|
116
120
|
end
|
121
|
+
uri.host = host
|
122
|
+
uri.port = port
|
117
123
|
end
|
118
|
-
local_url
|
124
|
+
Chef::Log.info("Port forwarded: local URL #{local_url} is available to #{self.host} as #{uri.to_s} for the duration of this SSH connection.")
|
125
|
+
uri.to_s
|
119
126
|
end
|
120
127
|
|
121
128
|
def disconnect
|
@@ -232,6 +239,50 @@ module ChefMetal
|
|
232
239
|
raise InitialConnectTimeout.new($!)
|
233
240
|
end
|
234
241
|
end
|
242
|
+
|
243
|
+
def is_local_machine(host)
|
244
|
+
local_addrs = Socket.ip_address_list
|
245
|
+
host_addrs = Addrinfo.getaddrinfo(host, nil)
|
246
|
+
local_addrs.any? do |local_addr|
|
247
|
+
host_addrs.any? do |host_addr|
|
248
|
+
local_addr.ip_address == host_addr.ip_address
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
# Forwards a port over the connection, and returns the
|
254
|
+
def forward_port(local_port, local_host, remote_port, remote_host)
|
255
|
+
# This bit is from the documentation.
|
256
|
+
if session.forward.respond_to?(:active_remote_destinations)
|
257
|
+
got_remote_port, remote_host = session.forward.active_remote_destinations[[local_port, local_host]]
|
258
|
+
if !got_remote_port
|
259
|
+
Chef::Log.debug("Forwarding local server #{local_host}:#{local_port} to #{username}@#{self.host}")
|
260
|
+
|
261
|
+
session.forward.remote(local_port, local_host, remote_port, remote_host) do |actual_remote_port|
|
262
|
+
got_remote_port = actual_remote_port || :error
|
263
|
+
:no_exception # I'll take care of it myself, thanks
|
264
|
+
end
|
265
|
+
# Kick SSH until we get a response
|
266
|
+
session.loop { !got_remote_port }
|
267
|
+
if got_remote_port == :error
|
268
|
+
return nil
|
269
|
+
end
|
270
|
+
end
|
271
|
+
[ got_remote_port, remote_host ]
|
272
|
+
else
|
273
|
+
@forwarded_ports ||= {}
|
274
|
+
remote_port, remote_host = @forwarded_ports[[local_port, local_host]]
|
275
|
+
if !remote_port
|
276
|
+
Chef::Log.debug("Forwarding local server #{local_host}:#{local_port} to #{username}@#{self.host}")
|
277
|
+
old_active_remotes = session.forward.active_remotes
|
278
|
+
session.forward.remote(local_port, local_host, local_port)
|
279
|
+
session.loop { !(session.forward.active_remotes.length > old_active_remotes.length) }
|
280
|
+
remote_port, remote_host = (session.forward.active_remotes - old_active_remotes).first
|
281
|
+
@forwarded_ports[[local_port, local_host]] = [ remote_port, remote_host ]
|
282
|
+
end
|
283
|
+
[ remote_port, remote_host ]
|
284
|
+
end
|
285
|
+
end
|
235
286
|
end
|
236
287
|
end
|
237
288
|
end
|
@@ -80,14 +80,11 @@ $file.Close
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def make_url_available_to_remote(local_url)
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
# session.forward.remote(uri.port, uri.host, uri.port)
|
89
|
-
# end
|
90
|
-
# end
|
83
|
+
uri = URI(local_url)
|
84
|
+
host = Socket.getaddrinfo(uri.host, uri.scheme, nil, :STREAM)[0][3]
|
85
|
+
if host == '127.0.0.1' || host == '::1'
|
86
|
+
raise 'Unable to converge locally via winrm. Local converge is currently only supported with SSH. You may only converge with winrm against a chef-server.'
|
87
|
+
end
|
91
88
|
local_url
|
92
89
|
end
|
93
90
|
|
data/lib/chef_metal/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clc-fork-chef-metal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.alpha.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Keiser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef
|