chef 0.8.6 → 0.8.8

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of chef might be problematic. Click here for more details.

data/lib/chef.rb CHANGED
@@ -27,7 +27,7 @@ require 'chef/config'
27
27
  Dir[File.join(File.dirname(__FILE__), 'chef/mixin/**/*.rb')].sort.each { |lib| require lib }
28
28
 
29
29
  class Chef
30
- VERSION = '0.8.6'
30
+ VERSION = '0.8.8'
31
31
  end
32
32
 
33
33
  # Adds a Dir.glob to Ruby 1.8.5, for compat
@@ -77,6 +77,12 @@ class Chef::Application::Client < Chef::Application
77
77
  :description => "Daemonize the process",
78
78
  :proc => lambda { |p| true }
79
79
 
80
+ option :pid_file,
81
+ :short => "-P PID_FILE",
82
+ :long => "--pid PIDFILE",
83
+ :description => "Set the PID file location, defaults to /tmp/chef-client.pid",
84
+ :proc => nil
85
+
80
86
  option :interval,
81
87
  :short => "-i SECONDS",
82
88
  :long => "--interval SECONDS",
@@ -72,6 +72,9 @@ class Chef
72
72
 
73
73
  File.open(ca_cert_file, "w") { |f| f.write ca_cert.to_pem }
74
74
  File.open(ca_keypair_file, File::WRONLY|File::EXCL|File::CREAT, 0600) { |f| f.write keypair.to_pem }
75
+ if (Chef::Config[:signing_ca_user] && Chef::Config[:signing_ca_group])
76
+ FileUtils.chown(Chef::Config[:signing_ca_user], Chef::Config[:signing_ca_group], ca_keypair_file)
77
+ end
75
78
  end
76
79
  self
77
80
  end
@@ -146,6 +149,9 @@ class Chef
146
149
  File.open(key_file, File::WRONLY|File::EXCL|File::CREAT, 0600) do |f|
147
150
  f.print(api_client.private_key)
148
151
  end
152
+ if (Chef::Config[:signing_ca_user] && Chef::Config[:signing_ca_group])
153
+ FileUtils.chown(Chef::Config[:signing_ca_user], Chef::Config[:signing_ca_group], key_file)
154
+ end
149
155
  end
150
156
  end
151
157
 
data/lib/chef/config.rb CHANGED
@@ -183,6 +183,8 @@ class Chef
183
183
  # In truth, these don't even have to change
184
184
  signing_ca_cert "/var/chef/ca/cert.pem"
185
185
  signing_ca_key "/var/chef/ca/key.pem"
186
+ signing_ca_user nil
187
+ signing_ca_group nil
186
188
  signing_ca_country "US"
187
189
  signing_ca_state "Washington"
188
190
  signing_ca_location "Seattle"
@@ -37,6 +37,13 @@ class Chef
37
37
  :description => "The attribute to use for opening the connection - default is fqdn",
38
38
  :default => "fqdn"
39
39
 
40
+ option :manual,
41
+ :short => "-m",
42
+ :long => "--manual-list",
43
+ :boolean => true,
44
+ :description => "QUERY is a space separated list of servers",
45
+ :default => false
46
+
40
47
  def session
41
48
  @session ||= Net::SSH::Multi.start(:concurrent_connections => config[:concurrency])
42
49
  end
@@ -47,13 +54,27 @@ class Chef
47
54
  end
48
55
 
49
56
  def configure_session
50
- q = Chef::Search::Query.new
51
- q.search(:node, @name_args[0]) do |item|
52
- data = format_for_display(item)
53
- Chef::Log.debug("Adding #{data[config[:attribute]]}")
54
- session.use data[config[:attribute]]
55
- @longest = data[config[:attribute]].length if data[config[:attribute]].length > @longest
57
+ list = case config[:manual]
58
+ when true
59
+ @name_args[0].split(" ")
60
+ when false
61
+ r = Array.new
62
+ q = Chef::Search::Query.new
63
+ q.search(:node, @name_args[0]) do |item|
64
+ r << format_for_display(item)[config[:attribute]]
65
+ end
66
+ r
67
+ end
68
+ session_from_list(list)
69
+ end
70
+
71
+ def session_from_list(list)
72
+ list.each do |item|
73
+ Chef::Log.debug("Adding #{item}")
74
+ session.use item
75
+ @longest = item.length if item.length > @longest
56
76
  end
77
+ session
57
78
  end
58
79
 
59
80
  def fixup_sudo(command)
@@ -147,6 +168,19 @@ class Chef
147
168
  end
148
169
  end
149
170
 
171
+ def screen
172
+ tf = Tempfile.new("knife-ssh-screen")
173
+ tf.puts("caption always '%w'")
174
+ tf.puts("hardstatus alwayslastline 'knife ssh #{@name_args[0]}'")
175
+ window = 0
176
+ session.servers_for.collect { |s| s.host }.each do |server|
177
+ tf.puts("screen -t \"#{server}\" #{window} ssh #{server}")
178
+ window += 1
179
+ end
180
+ tf.close
181
+ exec("screen -c #{tf.path}")
182
+ end
183
+
150
184
  def run
151
185
  @longest = 0
152
186
 
@@ -156,8 +190,11 @@ class Chef
156
190
 
157
191
  configure_session
158
192
 
159
- if @name_args[1] == "interactive"
193
+ case @name_args[1]
194
+ when "interactive"
160
195
  interactive
196
+ when "screen"
197
+ screen
161
198
  else
162
199
  ssh_command(@name_args[1..-1].join(" "))
163
200
  end
@@ -73,9 +73,13 @@ class Chef
73
73
  raise NotFound, "Cannot find a suitable directory"
74
74
  end
75
75
 
76
+ file_list = Array.new
76
77
  Dir[::File.join(directory, '**', '*')].sort.reverse.select do |file|
77
- file[/^#{directory}\/(.+)$/, 1] unless ::File.directory?(file)
78
+ unless ::File.directory?(file)
79
+ file_list << file[/^#{directory}\/(.+)$/, 1]
80
+ end
78
81
  end
82
+ file_list
79
83
  end
80
84
 
81
85
  def generate_client_file_list
@@ -178,7 +178,10 @@ class Chef
178
178
  stdout.each do |line|
179
179
  # rsyslog stop/waiting
180
180
  # service goal/state
181
- line =~ /\w+ (\w+)\/(\w+)/
181
+ # OR
182
+ # rsyslog (stop) waiting
183
+ # service (goal) state
184
+ line =~ /\w+ \(?(\w+)\)?[\/ ](\w+)/
182
185
  data = Regexp.last_match
183
186
  return data[2]
184
187
  end
@@ -23,7 +23,6 @@ class Chef
23
23
  boundary = '----RubyMultipartClient' + rand(1000000).to_s + 'ZZZZZ'
24
24
  parts = []
25
25
  content_file = nil
26
- content_body = nil
27
26
 
28
27
  timestamp = Time.now.utc.iso8601
29
28
  secret_key = OpenSSL::PKey::RSA.new(File.read(secret_key_filename))
@@ -40,10 +39,9 @@ class Chef
40
39
  parts << StreamPart.new(value, File.size(filepath))
41
40
  parts << StringPart.new("\r\n")
42
41
  else
43
- content_body = value.to_s
44
42
  parts << StringPart.new( "--" + boundary + "\r\n" +
45
43
  "Content-Disposition: form-data; name=\"" + key.to_s + "\"\r\n\r\n")
46
- parts << StringPart.new(content_body + "\r\n")
44
+ parts << StringPart.new(value.to_s + "\r\n")
47
45
  end
48
46
  end
49
47
  parts << StringPart.new("--" + boundary + "--\r\n")
@@ -57,6 +55,15 @@ class Chef
57
55
 
58
56
  Chef::Log.logger.debug("Signing: method: #{http_verb}, path: #{url.path}, file: #{content_file}, User-id: #{user_id}, Timestamp: #{timestamp}")
59
57
 
58
+ # We use the body for signing the request if the file parameter
59
+ # wasn't a valid file or wasn't included. Extract the body (with
60
+ # multi-part delimiters intact) to sign the request.
61
+ # TODO: tim: 2009-12-28: It'd be nice to remove this special case, and
62
+ # always hash the entire request body. In the file case it would just be
63
+ # expanded multipart text - the entire body of the POST.
64
+ content_body = parts.inject("") { |result,part| result + part.read(0, part.size) }
65
+ content_file.rewind if content_file # we consumed the file for the above operation, so rewind it.
66
+
60
67
  signing_options = {
61
68
  :http_method=>http_verb,
62
69
  :path=>url.path,
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 8
8
- - 6
9
- version: 0.8.6
8
+ - 8
9
+ version: 0.8.8
10
10
  platform: ruby
11
11
  authors:
12
12
  - Adam Jacob
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-04 00:00:00 -08:00
17
+ date: 2010-03-17 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -138,7 +138,7 @@ dependencies:
138
138
  type: :runtime
139
139
  version_requirements: *id009
140
140
  - !ruby/object:Gem::Dependency
141
- name: amqp
141
+ name: moneta
142
142
  prerelease: false
143
143
  requirement: &id010 !ruby/object:Gem::Requirement
144
144
  requirements:
@@ -149,18 +149,6 @@ dependencies:
149
149
  version: "0"
150
150
  type: :runtime
151
151
  version_requirements: *id010
152
- - !ruby/object:Gem::Dependency
153
- name: moneta
154
- prerelease: false
155
- requirement: &id011 !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- segments:
160
- - 0
161
- version: "0"
162
- type: :runtime
163
- version_requirements: *id011
164
152
  description: A systems integration framework, built to bring the benefits of configuration management to your entire infrastructure.
165
153
  email: adam@opscode.com
166
154
  executables: