chef 10.16.6 → 10.18.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- data/distro/common/html/chef-client.8.html +4 -4
- data/distro/common/html/chef-expander.8.html +4 -4
- data/distro/common/html/chef-expanderctl.8.html +4 -4
- data/distro/common/html/chef-server-webui.8.html +4 -4
- data/distro/common/html/chef-server.8.html +4 -4
- data/distro/common/html/chef-solo.8.html +4 -4
- data/distro/common/html/chef-solr.8.html +4 -4
- data/distro/common/html/knife-bootstrap.1.html +4 -4
- data/distro/common/html/knife-client.1.html +4 -4
- data/distro/common/html/knife-configure.1.html +4 -4
- data/distro/common/html/knife-cookbook-site.1.html +4 -4
- data/distro/common/html/knife-cookbook.1.html +4 -4
- data/distro/common/html/knife-data-bag.1.html +4 -4
- data/distro/common/html/knife-environment.1.html +4 -4
- data/distro/common/html/knife-exec.1.html +4 -4
- data/distro/common/html/knife-index.1.html +4 -4
- data/distro/common/html/knife-node.1.html +4 -4
- data/distro/common/html/knife-role.1.html +4 -4
- data/distro/common/html/knife-search.1.html +4 -4
- data/distro/common/html/knife-ssh.1.html +4 -4
- data/distro/common/html/knife-status.1.html +4 -4
- data/distro/common/html/knife-tag.1.html +4 -4
- data/distro/common/html/knife.1.html +4 -4
- data/distro/common/html/shef.1.html +4 -4
- data/distro/common/man/man1/knife-bootstrap.1 +1 -1
- data/distro/common/man/man1/knife-client.1 +1 -1
- data/distro/common/man/man1/knife-configure.1 +1 -1
- data/distro/common/man/man1/knife-cookbook-site.1 +1 -1
- data/distro/common/man/man1/knife-cookbook.1 +1 -1
- data/distro/common/man/man1/knife-data-bag.1 +1 -1
- data/distro/common/man/man1/knife-environment.1 +1 -1
- data/distro/common/man/man1/knife-exec.1 +1 -1
- data/distro/common/man/man1/knife-index.1 +1 -1
- data/distro/common/man/man1/knife-node.1 +1 -1
- data/distro/common/man/man1/knife-role.1 +1 -1
- data/distro/common/man/man1/knife-search.1 +1 -1
- data/distro/common/man/man1/knife-ssh.1 +1 -1
- data/distro/common/man/man1/knife-status.1 +1 -1
- data/distro/common/man/man1/knife-tag.1 +1 -1
- data/distro/common/man/man1/knife.1 +1 -1
- data/distro/common/man/man1/shef.1 +1 -1
- data/distro/common/man/man8/chef-client.8 +1 -1
- data/distro/common/man/man8/chef-expander.8 +1 -1
- data/distro/common/man/man8/chef-expanderctl.8 +1 -1
- data/distro/common/man/man8/chef-server-webui.8 +1 -1
- data/distro/common/man/man8/chef-server.8 +1 -1
- data/distro/common/man/man8/chef-solo.8 +1 -1
- data/distro/common/man/man8/chef-solr.8 +1 -1
- data/lib/chef/api_client.rb +22 -0
- data/lib/chef/cookbook/chefignore.rb +1 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +1 -3
- data/lib/chef/encrypted_data_bag_item.rb +135 -6
- data/lib/chef/formatters/doc.rb +2 -2
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +1 -0
- data/lib/chef/knife/bootstrap/archlinux-gems.erb +6 -19
- data/lib/chef/knife/bootstrap/centos5-gems.erb +15 -24
- data/lib/chef/knife/bootstrap/chef-full.erb +9 -22
- data/lib/chef/knife/bootstrap/fedora13-gems.erb +5 -19
- data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +4 -16
- data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +7 -24
- data/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb +5 -19
- data/lib/chef/knife/bootstrap.rb +3 -3
- data/lib/chef/knife/client_reregister.rb +5 -4
- data/lib/chef/knife/cookbook_create.rb +178 -28
- data/lib/chef/knife/cookbook_site_install.rb +1 -1
- data/lib/chef/knife/core/bootstrap_context.rb +2 -2
- data/lib/chef/knife/ssh.rb +31 -15
- data/lib/chef/mixin/recipe_definition_dsl_core.rb +1 -1
- data/lib/chef/platform.rb +8 -0
- data/lib/chef/provider/log.rb +1 -1
- data/lib/chef/provider/package/yum-dump.py +20 -0
- data/lib/chef/provider/package/yum.rb +41 -0
- data/lib/chef/resource/log.rb +10 -1
- data/lib/chef/resource.rb +3 -2
- data/lib/chef/rest.rb +10 -5
- data/lib/chef/version.rb +1 -1
- data/spec/data/cookbooks/chefignore +2 -0
- data/spec/functional/knife/ssh_spec.rb +59 -1
- data/spec/stress/win32/security_spec.rb +4 -4
- data/spec/support/matchers/leak.rb +1 -1
- data/spec/unit/api_client_spec.rb +90 -17
- data/spec/unit/cookbook/chefignore_spec.rb +2 -1
- data/spec/unit/encrypted_data_bag_item_spec.rb +177 -6
- data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +20 -0
- data/spec/unit/knife/bootstrap_spec.rb +69 -28
- data/spec/unit/knife/client_reregister_spec.rb +23 -22
- data/spec/unit/knife/cookbook_site_install_spec.rb +12 -2
- data/spec/unit/knife/core/bootstrap_context_spec.rb +7 -0
- data/spec/unit/knife/data_bag_create_spec.rb +5 -0
- data/spec/unit/knife/data_bag_edit_spec.rb +13 -0
- data/spec/unit/knife/data_bag_from_file_spec.rb +15 -1
- data/spec/unit/knife/ssh_spec.rb +93 -1
- data/spec/unit/provider/package/yum_spec.rb +79 -11
- data/spec/unit/resource/log_spec.rb +9 -0
- metadata +854 -850
@@ -73,10 +73,10 @@ class Chef
|
|
73
73
|
email = config[:cookbook_email] || "YOUR_EMAIL"
|
74
74
|
license = ((config[:cookbook_license] != "false") && config[:cookbook_license]) || "none"
|
75
75
|
readme_format = ((config[:readme_format] != "false") && config[:readme_format]) || "md"
|
76
|
-
create_cookbook(cookbook_path,cookbook_name, copyright, license)
|
77
|
-
create_readme(cookbook_path,cookbook_name,readme_format)
|
78
|
-
create_changelog(cookbook_path,cookbook_name)
|
79
|
-
create_metadata(cookbook_path,cookbook_name, copyright, email, license,readme_format)
|
76
|
+
create_cookbook(cookbook_path, cookbook_name, copyright, license)
|
77
|
+
create_readme(cookbook_path, cookbook_name, readme_format)
|
78
|
+
create_changelog(cookbook_path, cookbook_name)
|
79
|
+
create_metadata(cookbook_path, cookbook_name, copyright, email, license, readme_format)
|
80
80
|
end
|
81
81
|
|
82
82
|
def create_cookbook(dir, cookbook_name, copyright, license)
|
@@ -193,7 +193,7 @@ This file is used to list changes made in each version of #{cookbook_name}.
|
|
193
193
|
|
194
194
|
* Initial release of #{cookbook_name}
|
195
195
|
|
196
|
-
- - -
|
196
|
+
- - -
|
197
197
|
Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown.
|
198
198
|
|
199
199
|
The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown.
|
@@ -202,54 +202,203 @@ EOH
|
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
205
|
-
def create_readme(dir, cookbook_name,readme_format)
|
205
|
+
def create_readme(dir, cookbook_name, readme_format)
|
206
206
|
msg("** Creating README for cookbook: #{cookbook_name}")
|
207
207
|
unless File.exists?(File.join(dir, cookbook_name, "README.#{readme_format}"))
|
208
208
|
open(File.join(dir, cookbook_name, "README.#{readme_format}"), "w") do |file|
|
209
209
|
case readme_format
|
210
210
|
when "rdoc"
|
211
211
|
file.puts <<-EOH
|
212
|
-
=
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
212
|
+
= #{cookbook_name} Cookbook
|
213
|
+
TODO: Enter the cookbook description here.
|
214
|
+
|
215
|
+
e.g.
|
216
|
+
This cookbook makes your favorite breakfast sandwhich.
|
217
|
+
|
218
|
+
== Requirements
|
219
|
+
TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc.
|
220
|
+
|
221
|
+
e.g.
|
222
|
+
==== packages
|
223
|
+
- +toaster+ - #{cookbook_name} needs toaster to brown your bagel.
|
224
|
+
|
225
|
+
== Attributes
|
226
|
+
TODO: List you cookbook attributes here.
|
227
|
+
|
228
|
+
e.g.
|
229
|
+
==== #{cookbook_name}::default
|
230
|
+
<table>
|
231
|
+
<tr>
|
232
|
+
<th>Key</th>
|
233
|
+
<th>Type</th>
|
234
|
+
<th>Description</th>
|
235
|
+
<th>Default</th>
|
236
|
+
</tr>
|
237
|
+
<tr>
|
238
|
+
<td><tt>['#{cookbook_name}']['bacon']</tt></td>
|
239
|
+
<td>Boolean</td>
|
240
|
+
<td>whether to include bacon</td>
|
241
|
+
<td><tt>true</tt></td>
|
242
|
+
</tr>
|
243
|
+
</table>
|
244
|
+
|
245
|
+
== Usage
|
246
|
+
==== #{cookbook_name}::default
|
247
|
+
TODO: Write usage instructions for each cookbook.
|
248
|
+
|
249
|
+
e.g.
|
250
|
+
Just include +#{cookbook_name}+ in your node's +run_list+:
|
251
|
+
|
252
|
+
{
|
253
|
+
"name":"my_node",
|
254
|
+
"run_list": [
|
255
|
+
"recipe[#{cookbook_name}]"
|
256
|
+
]
|
257
|
+
}
|
258
|
+
|
259
|
+
== Contributing
|
260
|
+
TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section.
|
261
|
+
|
262
|
+
e.g.
|
263
|
+
1. Fork the repository on Github
|
264
|
+
2. Create a named feature branch (like `add_component_x`)
|
265
|
+
3. Write you change
|
266
|
+
4. Write tests for your change (if applicable)
|
267
|
+
5. Run the tests, ensuring they all pass
|
268
|
+
6. Submit a Pull Request using Github
|
269
|
+
|
270
|
+
== License and Authors
|
271
|
+
Authors: TODO: List authors
|
220
272
|
EOH
|
221
273
|
when "md","mkd","txt"
|
222
274
|
file.puts <<-EOH
|
223
|
-
|
224
|
-
|
275
|
+
#{cookbook_name} Cookbook
|
276
|
+
#{'='*"#{cookbook_name} Cookbook".length}
|
277
|
+
TODO: Enter the cookbook description here.
|
278
|
+
|
279
|
+
e.g.
|
280
|
+
This cookbook makes your favorite breakfast sandwhich.
|
225
281
|
|
226
282
|
Requirements
|
227
|
-
|
283
|
+
------------
|
284
|
+
TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc.
|
285
|
+
|
286
|
+
e.g.
|
287
|
+
#### packages
|
288
|
+
- `toaster` - #{cookbook_name} needs toaster to brown your bagel.
|
228
289
|
|
229
290
|
Attributes
|
230
|
-
|
291
|
+
----------
|
292
|
+
TODO: List you cookbook attributes here.
|
293
|
+
|
294
|
+
e.g.
|
295
|
+
#### #{cookbook_name}::default
|
296
|
+
<table>
|
297
|
+
<tr>
|
298
|
+
<th>Key</th>
|
299
|
+
<th>Type</th>
|
300
|
+
<th>Description</th>
|
301
|
+
<th>Default</th>
|
302
|
+
</tr>
|
303
|
+
<tr>
|
304
|
+
<td><tt>['#{cookbook_name}']['bacon']</tt></td>
|
305
|
+
<td>Boolean</td>
|
306
|
+
<td>whether to include bacon</td>
|
307
|
+
<td><tt>true</tt></td>
|
308
|
+
</tr>
|
309
|
+
</table>
|
231
310
|
|
232
311
|
Usage
|
233
|
-
|
234
|
-
|
312
|
+
-----
|
313
|
+
#### #{cookbook_name}::default
|
314
|
+
TODO: Write usage instructions for each cookbook.
|
315
|
+
|
316
|
+
e.g.
|
317
|
+
Just include `#{cookbook_name}` in your node's `run_list`:
|
318
|
+
|
319
|
+
```json
|
320
|
+
{
|
321
|
+
"name":"my_node",
|
322
|
+
"run_list": [
|
323
|
+
"recipe[#{cookbook_name}]"
|
324
|
+
]
|
325
|
+
}
|
326
|
+
```
|
327
|
+
|
328
|
+
Contributing
|
329
|
+
------------
|
330
|
+
TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section.
|
331
|
+
|
332
|
+
e.g.
|
333
|
+
1. Fork the repository on Github
|
334
|
+
2. Create a named feature branch (like `add_component_x`)
|
335
|
+
3. Write you change
|
336
|
+
4. Write tests for your change (if applicable)
|
337
|
+
5. Run the tests, ensuring they all pass
|
338
|
+
6. Submit a Pull Request using Github
|
339
|
+
|
340
|
+
License and Authors
|
341
|
+
-------------------
|
342
|
+
Authors: TODO: List authors
|
235
343
|
EOH
|
236
344
|
else
|
237
345
|
file.puts <<-EOH
|
238
|
-
|
346
|
+
#{cookbook_name} Cookbook
|
347
|
+
#{'='*"#{cookbook_name} Cookbook".length}
|
348
|
+
TODO: Enter the cookbook description here.
|
349
|
+
|
350
|
+
e.g.
|
351
|
+
This cookbook makes your favorite breakfast sandwhich.
|
239
352
|
|
240
353
|
Requirements
|
354
|
+
TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc.
|
355
|
+
|
356
|
+
e.g.
|
357
|
+
toaster #{cookbook_name} needs toaster to brown your bagel.
|
241
358
|
|
242
359
|
Attributes
|
360
|
+
TODO: List you cookbook attributes here.
|
243
361
|
|
244
|
-
|
362
|
+
#{cookbook_name}
|
363
|
+
Key Type Description Default
|
364
|
+
['#{cookbook_name}']['bacon'] Boolean whether to include bacon true
|
245
365
|
|
366
|
+
Usage
|
367
|
+
#{cookbook_name}
|
368
|
+
TODO: Write usage instructions for each cookbook.
|
369
|
+
|
370
|
+
e.g.
|
371
|
+
Just include `#{cookbook_name}` in your node's `run_list`:
|
372
|
+
|
373
|
+
[code]
|
374
|
+
{
|
375
|
+
"name":"my_node",
|
376
|
+
"run_list": [
|
377
|
+
"recipe[#{cookbook_name}]"
|
378
|
+
]
|
379
|
+
}
|
380
|
+
[/code]
|
381
|
+
|
382
|
+
Contributing
|
383
|
+
TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section.
|
384
|
+
|
385
|
+
e.g.
|
386
|
+
1. Fork the repository on Github
|
387
|
+
2. Create a named feature branch (like `add_component_x`)
|
388
|
+
3. Write you change
|
389
|
+
4. Write tests for your change (if applicable)
|
390
|
+
5. Run the tests, ensuring they all pass
|
391
|
+
6. Submit a Pull Request using Github
|
392
|
+
|
393
|
+
License and Authors
|
394
|
+
Authors: TODO: List authors
|
246
395
|
EOH
|
247
396
|
end
|
248
397
|
end
|
249
398
|
end
|
250
399
|
end
|
251
400
|
|
252
|
-
def create_metadata(dir, cookbook_name, copyright, email, license,readme_format)
|
401
|
+
def create_metadata(dir, cookbook_name, copyright, email, license, readme_format)
|
253
402
|
msg("** Creating metadata for cookbook: #{cookbook_name}")
|
254
403
|
|
255
404
|
license_name = case license
|
@@ -271,12 +420,13 @@ EOH
|
|
271
420
|
long_description = "long_description IO.read(File.join(File.dirname(__FILE__), 'README.#{readme_format}'))"
|
272
421
|
end
|
273
422
|
file.puts <<-EOH
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
423
|
+
name '#{cookbook_name}'
|
424
|
+
maintainer '#{copyright}'
|
425
|
+
maintainer_email '#{email}'
|
426
|
+
license '#{license_name}'
|
427
|
+
description 'Installs/Configures #{cookbook_name}'
|
278
428
|
#{long_description}
|
279
|
-
version
|
429
|
+
version '0.1.0'
|
280
430
|
EOH
|
281
431
|
end
|
282
432
|
end
|
@@ -74,7 +74,7 @@ class Chef
|
|
74
74
|
@cookbook_name = parse_name_args!
|
75
75
|
# Check to ensure we have a valid source of cookbooks before continuing
|
76
76
|
#
|
77
|
-
@install_path = File.expand_path(config[:cookbook_path].first)
|
77
|
+
@install_path = File.expand_path(Array(config[:cookbook_path]).first)
|
78
78
|
ui.info "Installing #@cookbook_name to #{@install_path}"
|
79
79
|
|
80
80
|
@repo = CookbookSCMRepo.new(@install_path, ui, config)
|
@@ -47,11 +47,11 @@ class Chef
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def validation_key
|
50
|
-
IO.read(@chef_config[:validation_key])
|
50
|
+
IO.read(File.expand_path(@chef_config[:validation_key]))
|
51
51
|
end
|
52
52
|
|
53
53
|
def encrypted_data_bag_secret
|
54
|
-
IO.read(@chef_config[:encrypted_data_bag_secret])
|
54
|
+
IO.read(File.expand_path(@chef_config[:encrypted_data_bag_secret]))
|
55
55
|
end
|
56
56
|
|
57
57
|
def config_content
|
data/lib/chef/knife/ssh.rb
CHANGED
@@ -72,13 +72,13 @@ class Chef
|
|
72
72
|
:short => "-p PORT",
|
73
73
|
:long => "--ssh-port PORT",
|
74
74
|
:description => "The ssh port",
|
75
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:ssh_port] = key }
|
75
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:ssh_port] = key.strip }
|
76
76
|
|
77
77
|
option :ssh_gateway,
|
78
78
|
:short => "-G GATEWAY",
|
79
79
|
:long => "--ssh-gateway GATEWAY",
|
80
80
|
:description => "The ssh gateway",
|
81
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:ssh_gateway] = key }
|
81
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:ssh_gateway] = key.strip }
|
82
82
|
|
83
83
|
option :identity_file,
|
84
84
|
:short => "-i IDENTITY_FILE",
|
@@ -114,6 +114,22 @@ class Chef
|
|
114
114
|
@session ||= Net::SSH::Multi.start(:concurrent_connections => config[:concurrency], :on_error => ssh_error_handler)
|
115
115
|
end
|
116
116
|
|
117
|
+
def configure_gateway
|
118
|
+
config[:ssh_gateway] ||= Chef::Config[:knife][:ssh_gateway]
|
119
|
+
if config[:ssh_gateway]
|
120
|
+
gw_host, gw_user = config[:ssh_gateway].split('@').reverse
|
121
|
+
gw_host, gw_port = gw_host.split(':')
|
122
|
+
gw_opts = gw_port ? { :port => gw_port } : {}
|
123
|
+
|
124
|
+
session.via(gw_host, gw_user || config[:ssh_user], gw_opts)
|
125
|
+
end
|
126
|
+
rescue Net::SSH::AuthenticationFailed
|
127
|
+
user = gw_user || config[:ssh_user]
|
128
|
+
prompt = "Enter the password for #{user}@#{gw_host}: "
|
129
|
+
gw_opts.merge!(:password => prompt_for_password(prompt))
|
130
|
+
session.via(gw_host, user, gw_opts)
|
131
|
+
end
|
132
|
+
|
117
133
|
def configure_session
|
118
134
|
list = case config[:manual]
|
119
135
|
when true
|
@@ -145,7 +161,7 @@ class Chef
|
|
145
161
|
ui.fatal("No nodes returned from search!")
|
146
162
|
else
|
147
163
|
ui.fatal("#{@action_nodes.length} #{@action_nodes.length > 1 ? "nodes":"node"} found, " +
|
148
|
-
"but
|
164
|
+
"but does not have the required attribute to establish the connection. " +
|
149
165
|
"Try setting another attribute to open the connection using --attribute.")
|
150
166
|
end
|
151
167
|
exit 10
|
@@ -154,15 +170,6 @@ class Chef
|
|
154
170
|
end
|
155
171
|
|
156
172
|
def session_from_list(list)
|
157
|
-
config[:ssh_gateway] ||= Chef::Config[:knife][:ssh_gateway]
|
158
|
-
if config[:ssh_gateway]
|
159
|
-
gw_host, gw_user = config[:ssh_gateway].split('@').reverse
|
160
|
-
gw_host, gw_port = gw_host.split(':')
|
161
|
-
gw_opts = gw_port ? { :port => gw_port } : {}
|
162
|
-
|
163
|
-
session.via(gw_host, gw_user || config[:ssh_user], gw_opts)
|
164
|
-
end
|
165
|
-
|
166
173
|
list.each do |item|
|
167
174
|
Chef::Log.debug("Adding #{item}")
|
168
175
|
session_opts = {}
|
@@ -221,7 +228,7 @@ class Chef
|
|
221
228
|
end
|
222
229
|
end
|
223
230
|
ch.on_request "exit-status" do |ichannel, data|
|
224
|
-
exit_status = data.read_long
|
231
|
+
exit_status = [exit_status, data.read_long].max
|
225
232
|
end
|
226
233
|
end
|
227
234
|
end
|
@@ -230,7 +237,11 @@ class Chef
|
|
230
237
|
end
|
231
238
|
|
232
239
|
def get_password
|
233
|
-
@password ||=
|
240
|
+
@password ||= prompt_for_password
|
241
|
+
end
|
242
|
+
|
243
|
+
def prompt_for_password(prompt = "Enter your password: ")
|
244
|
+
ui.ask(prompt) { |q| q.echo = false }
|
234
245
|
end
|
235
246
|
|
236
247
|
# Present the prompt and read a single line from the console. It also
|
@@ -412,6 +423,7 @@ class Chef
|
|
412
423
|
configure_attribute
|
413
424
|
configure_user
|
414
425
|
configure_identity_file
|
426
|
+
configure_gateway
|
415
427
|
configure_session
|
416
428
|
|
417
429
|
exit_status =
|
@@ -435,7 +447,11 @@ class Chef
|
|
435
447
|
end
|
436
448
|
|
437
449
|
session.close
|
438
|
-
exit_status
|
450
|
+
if exit_status != 0
|
451
|
+
exit exit_status
|
452
|
+
else
|
453
|
+
exit_status
|
454
|
+
end
|
439
455
|
end
|
440
456
|
|
441
457
|
end
|
@@ -63,11 +63,11 @@ class Chef
|
|
63
63
|
# If we have a resource like this one, we want to steal its state
|
64
64
|
args << run_context
|
65
65
|
resource = resource_class.new(*args)
|
66
|
+
resource.source_line = caller[0]
|
66
67
|
resource.load_prior_resource
|
67
68
|
resource.cookbook_name = cookbook_name
|
68
69
|
resource.recipe_name = @recipe_name
|
69
70
|
resource.params = @params
|
70
|
-
resource.source_line = caller[0]
|
71
71
|
# Determine whether this resource is being created in the context of an enclosing Provider
|
72
72
|
resource.enclosing_provider = self.is_a?(Chef::Provider) ? self : nil
|
73
73
|
# Evaluate resource attribute DSL
|
data/lib/chef/platform.rb
CHANGED
@@ -81,6 +81,14 @@ class Chef
|
|
81
81
|
:mdadm => Chef::Provider::Mdadm
|
82
82
|
}
|
83
83
|
},
|
84
|
+
:raspbian => {
|
85
|
+
:default => {
|
86
|
+
:package => Chef::Provider::Package::Apt,
|
87
|
+
:service => Chef::Provider::Service::Debian,
|
88
|
+
:cron => Chef::Provider::Cron,
|
89
|
+
:mdadm => Chef::Provider::Mdadm
|
90
|
+
}
|
91
|
+
},
|
84
92
|
:linuxmint => {
|
85
93
|
:default => {
|
86
94
|
:package => Chef::Provider::Package::Apt,
|
data/lib/chef/provider/log.rb
CHANGED
@@ -107,6 +107,14 @@ def setup(yb, options):
|
|
107
107
|
elif YUM_MAJOR == 2:
|
108
108
|
yb.conf.setConfigOption('cache', options.cache)
|
109
109
|
|
110
|
+
# Handle repo toggle via id or glob exactly like yum
|
111
|
+
for opt, repos in options.repo_control:
|
112
|
+
for repo in repos:
|
113
|
+
if opt == '--enablerepo':
|
114
|
+
yb.repos.enableRepo(repo)
|
115
|
+
elif opt == '--disablerepo':
|
116
|
+
yb.repos.disableRepo(repo)
|
117
|
+
|
110
118
|
return 0
|
111
119
|
|
112
120
|
def dump_packages(yb, list, output_provides):
|
@@ -239,6 +247,12 @@ def yum_dump(options):
|
|
239
247
|
print >> sys.stderr, "yum-dump Unlock Error: %s" % e
|
240
248
|
return 200
|
241
249
|
|
250
|
+
# Preserve order of enable/disable repo args like yum does
|
251
|
+
def gather_repo_opts(option, opt, value, parser):
|
252
|
+
if getattr(parser.values, option.dest, None) is None:
|
253
|
+
setattr(parser.values, option.dest, [])
|
254
|
+
getattr(parser.values, option.dest).append((opt, value.split(',')))
|
255
|
+
|
242
256
|
def main():
|
243
257
|
usage = "Usage: %prog [options]\n" + \
|
244
258
|
"Output a list of installed, available and re-installable packages via yum"
|
@@ -261,6 +275,12 @@ def main():
|
|
261
275
|
parser.add_option("-a", "--available",
|
262
276
|
action="store_const", const="available", dest="package_list", default="all",
|
263
277
|
help="output only available and re-installable packages")
|
278
|
+
parser.add_option("--enablerepo",
|
279
|
+
action="callback", callback=gather_repo_opts, type="string", dest="repo_control", default=[],
|
280
|
+
help="enable disabled repositories by id or glob")
|
281
|
+
parser.add_option("--disablerepo",
|
282
|
+
action="callback", callback=gather_repo_opts, type="string", dest="repo_control", default=[],
|
283
|
+
help="disable repositories by id or glob")
|
264
284
|
|
265
285
|
(options, args) = parser.parse_args()
|
266
286
|
|
@@ -664,12 +664,16 @@ class Chef
|
|
664
664
|
|
665
665
|
@allow_multi_install = []
|
666
666
|
|
667
|
+
@extra_repo_control = nil
|
668
|
+
|
667
669
|
# these are for subsequent runs if we are on an interval
|
668
670
|
Chef::Client.when_run_starts do
|
669
671
|
YumCache.instance.reload
|
670
672
|
end
|
671
673
|
end
|
672
674
|
|
675
|
+
attr_reader :extra_repo_control
|
676
|
+
|
673
677
|
# Cache management
|
674
678
|
#
|
675
679
|
|
@@ -693,6 +697,10 @@ class Chef
|
|
693
697
|
raise ArgumentError, "Unexpected value in next_refresh: #{@next_refresh}"
|
694
698
|
end
|
695
699
|
|
700
|
+
if @extra_repo_control
|
701
|
+
opts << " #{@extra_repo_control}"
|
702
|
+
end
|
703
|
+
|
696
704
|
one_line = false
|
697
705
|
error = nil
|
698
706
|
|
@@ -848,6 +856,22 @@ class Chef
|
|
848
856
|
@allow_multi_install
|
849
857
|
end
|
850
858
|
|
859
|
+
def enable_extra_repo_control(arg)
|
860
|
+
# Don't touch cache if it's the same repos as the last load
|
861
|
+
unless @extra_repo_control == arg
|
862
|
+
@extra_repo_control = arg
|
863
|
+
reload
|
864
|
+
end
|
865
|
+
end
|
866
|
+
|
867
|
+
def disable_extra_repo_control
|
868
|
+
# Only force reload when set
|
869
|
+
if @extra_repo_control
|
870
|
+
@extra_repo_control = nil
|
871
|
+
reload
|
872
|
+
end
|
873
|
+
end
|
874
|
+
|
851
875
|
private
|
852
876
|
|
853
877
|
def version(package_name, arch=nil, is_available=false, is_installed=false)
|
@@ -995,6 +1019,23 @@ class Chef
|
|
995
1019
|
@yum.reload
|
996
1020
|
end
|
997
1021
|
|
1022
|
+
if @new_resource.options
|
1023
|
+
repo_control = []
|
1024
|
+
@new_resource.options.split.each do |opt|
|
1025
|
+
if opt =~ %r{--(enable|disable)repo=.+}
|
1026
|
+
repo_control << opt
|
1027
|
+
end
|
1028
|
+
end
|
1029
|
+
|
1030
|
+
if repo_control.size > 0
|
1031
|
+
@yum.enable_extra_repo_control(repo_control.join(" "))
|
1032
|
+
else
|
1033
|
+
@yum.disable_extra_repo_control
|
1034
|
+
end
|
1035
|
+
else
|
1036
|
+
@yum.disable_extra_repo_control
|
1037
|
+
end
|
1038
|
+
|
998
1039
|
# At this point package_name could be:
|
999
1040
|
#
|
1000
1041
|
# 1) a package name, eg: "foo"
|
data/lib/chef/resource/log.rb
CHANGED
@@ -20,7 +20,7 @@ class Chef
|
|
20
20
|
class Resource
|
21
21
|
class Log < Chef::Resource
|
22
22
|
|
23
|
-
identity_attr :
|
23
|
+
identity_attr :message
|
24
24
|
|
25
25
|
# Sends a string from a recipe to a log provider
|
26
26
|
#
|
@@ -47,6 +47,15 @@ class Chef
|
|
47
47
|
@resource_name = :log
|
48
48
|
@level = :info
|
49
49
|
@action = :write
|
50
|
+
@message = name
|
51
|
+
end
|
52
|
+
|
53
|
+
def message(arg=nil)
|
54
|
+
set_or_return(
|
55
|
+
:message,
|
56
|
+
arg,
|
57
|
+
:kind_of => String
|
58
|
+
)
|
50
59
|
end
|
51
60
|
|
52
61
|
# <Symbol> Log level, one of :debug, :info, :warn, :error or :fatal
|
data/lib/chef/resource.rb
CHANGED
@@ -262,10 +262,11 @@ F
|
|
262
262
|
|
263
263
|
def load_prior_resource
|
264
264
|
begin
|
265
|
+
Chef::Log.warn("Cloning resource attributes for #{self.to_s} from prior resource (CHEF-3694)")
|
266
|
+
Chef::Log.warn("From: #{self.source_line}") if self.source_line
|
265
267
|
prior_resource = run_context.resource_collection.lookup(self.to_s)
|
266
|
-
Chef::Log.debug("Setting #{self.to_s} to the state of the prior #{self.to_s}")
|
267
268
|
prior_resource.instance_variables.each do |iv|
|
268
|
-
unless iv.to_sym == :@source_line || iv.to_sym == :@action
|
269
|
+
unless iv.to_sym == :@source_line || iv.to_sym == :@action || iv.to_sym == :@not_if || iv.to_sym == :@only_if
|
269
270
|
self.instance_variable_set(iv, prior_resource.instance_variable_get(iv))
|
270
271
|
end
|
271
272
|
end
|
data/lib/chef/rest.rb
CHANGED
@@ -99,11 +99,18 @@ class Chef
|
|
99
99
|
begin
|
100
100
|
response = nc.save(true, true)
|
101
101
|
Chef::Log.debug("Registration response: #{response.inspect}")
|
102
|
-
|
102
|
+
private_key = if response.respond_to?(:[])
|
103
|
+
response["private_key"]
|
104
|
+
else
|
105
|
+
response.private_key
|
106
|
+
end
|
107
|
+
unless private_key
|
108
|
+
raise Chef::Exceptions::CannotWritePrivateKey, "The response from the server did not include a private key!"
|
109
|
+
end
|
103
110
|
# Write out the private key
|
104
111
|
::File.open(destination, "w") {|f|
|
105
112
|
f.chmod(0600)
|
106
|
-
f.print(
|
113
|
+
f.print(private_key)
|
107
114
|
}
|
108
115
|
throw :done
|
109
116
|
rescue IOError
|
@@ -360,7 +367,7 @@ class Chef
|
|
360
367
|
begin
|
361
368
|
http_attempts += 1
|
362
369
|
|
363
|
-
|
370
|
+
yield rest_request
|
364
371
|
|
365
372
|
rescue SocketError, Errno::ETIMEDOUT => e
|
366
373
|
e.message.replace "Error connecting to #{url} - #{e.message}"
|
@@ -452,7 +459,6 @@ class Chef
|
|
452
459
|
Chef::Log.debug("Streaming download from #{url.to_s} to tempfile #{tf.path}")
|
453
460
|
# Stolen from http://www.ruby-forum.com/topic/166423
|
454
461
|
# Kudos to _why!
|
455
|
-
size, total = 0, response.header['Content-Length'].to_i
|
456
462
|
|
457
463
|
inflater = if gzip_disabled?
|
458
464
|
NoopInflater.new
|
@@ -471,7 +477,6 @@ class Chef
|
|
471
477
|
|
472
478
|
response.read_body do |chunk|
|
473
479
|
tf.write(inflater.inflate(chunk))
|
474
|
-
size += chunk.size
|
475
480
|
end
|
476
481
|
tf.close
|
477
482
|
tf
|
data/lib/chef/version.rb
CHANGED