microwave 0.1004.5 → 0.1004.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.
- data/lib/chef.rb +0 -1
- data/lib/chef/client.rb +0 -19
- data/lib/chef/config.rb +7 -58
- data/lib/chef/cookbook/cookbook_version_loader.rb +0 -14
- data/lib/chef/cookbook_version.rb +1 -133
- data/lib/chef/environment.rb +0 -36
- data/lib/chef/handler/json_file.rb +1 -1
- data/lib/chef/mixin/recipe_definition_dsl_core.rb +18 -34
- data/lib/chef/mixin/shell_out.rb +1 -0
- data/lib/chef/node.rb +0 -29
- data/lib/chef/provider/execute.rb +1 -0
- data/lib/chef/provider/file.rb +1 -14
- data/lib/chef/resource.rb +1 -1
- data/lib/chef/role.rb +13 -68
- data/lib/chef/run_context.rb +1 -15
- data/lib/chef/tasks/chef_repo.rake +0 -1
- data/lib/chef/version.rb +1 -1
- metadata +24 -17
- data/lib/chef/monkey_patches/string.rb +0 -49
- data/lib/chef/resource_definition.rb +0 -67
- data/lib/chef/resource_definition_list.rb +0 -38
- data/lib/chef/util/windows/net_group.rb +0 -101
- data/lib/chef/util/windows/net_use.rb +0 -121
- data/lib/chef/util/windows/net_user.rb +0 -198
- data/lib/chef/util/windows/volume.rb +0 -59
data/lib/chef.rb
CHANGED
data/lib/chef/client.rb
CHANGED
@@ -236,25 +236,6 @@ class Chef
|
|
236
236
|
@node
|
237
237
|
end
|
238
238
|
|
239
|
-
# Sync_cookbooks eagerly loads all files except files and
|
240
|
-
# templates. It returns the cookbook_hash -- the return result
|
241
|
-
# from /environments/#{node.chef_environment}/cookbook_versions,
|
242
|
-
# which we will use for our run_context.
|
243
|
-
#
|
244
|
-
# === Returns
|
245
|
-
# Hash:: The hash of cookbooks with download URLs as given by the server
|
246
|
-
def sync_cookbooks
|
247
|
-
Chef::Log.debug("Synchronizing cookbooks")
|
248
|
-
cookbook_hash = rest.post_rest("environments/#{@node.chef_environment}/cookbook_versions",
|
249
|
-
{:run_list => @expanded_run_list_with_versions})
|
250
|
-
Chef::CookbookVersion.sync_cookbooks(cookbook_hash)
|
251
|
-
|
252
|
-
# register the file cache path in the cookbook path so that CookbookLoader actually picks up the synced cookbooks
|
253
|
-
Chef::Config[:cookbook_path] = File.join(Chef::Config[:file_cache_path], "cookbooks")
|
254
|
-
|
255
|
-
cookbook_hash
|
256
|
-
end
|
257
|
-
|
258
239
|
# Converges the node.
|
259
240
|
#
|
260
241
|
# === Returns
|
data/lib/chef/config.rb
CHANGED
@@ -25,46 +25,10 @@ class Chef
|
|
25
25
|
|
26
26
|
extend Mixlib::Config
|
27
27
|
|
28
|
-
# Manages the chef secret session key
|
29
|
-
# === Returns
|
30
|
-
# <newkey>:: A new or retrieved session key
|
31
|
-
#
|
32
|
-
def self.manage_secret_key
|
33
|
-
newkey = nil
|
34
|
-
if Chef::FileCache.has_key?("chef_server_cookie_id")
|
35
|
-
newkey = Chef::FileCache.load("chef_server_cookie_id")
|
36
|
-
else
|
37
|
-
chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
|
38
|
-
newkey = ""
|
39
|
-
40.times { |i| newkey << chars[rand(chars.size-1)] }
|
40
|
-
Chef::FileCache.store("chef_server_cookie_id", newkey)
|
41
|
-
end
|
42
|
-
newkey
|
43
|
-
end
|
44
|
-
|
45
28
|
def self.inspect
|
46
29
|
configuration.inspect
|
47
30
|
end
|
48
31
|
|
49
|
-
# Override the config dispatch to set the value of multiple server options simultaneously
|
50
|
-
#
|
51
|
-
# === Parameters
|
52
|
-
# url<String>:: String to be set for all of the chef-server-api URL's
|
53
|
-
#
|
54
|
-
config_attr_writer :chef_server_url do |url|
|
55
|
-
configure do |c|
|
56
|
-
[ :registration_url,
|
57
|
-
:template_url,
|
58
|
-
:remotefile_url,
|
59
|
-
:search_url,
|
60
|
-
:chef_server_url,
|
61
|
-
:role_url ].each do |u|
|
62
|
-
c[u] = url
|
63
|
-
end
|
64
|
-
end
|
65
|
-
url
|
66
|
-
end
|
67
|
-
|
68
32
|
# Override the config dispatch to set the value of log_location configuration option
|
69
33
|
#
|
70
34
|
# === Parameters
|
@@ -84,50 +48,35 @@ class Chef
|
|
84
48
|
# Turn on "path sanity" by default. See also: http://wiki.opscode.com/display/chef/User+Environment+PATH+Sanity
|
85
49
|
enforce_path_sanity(true)
|
86
50
|
|
87
|
-
# The number of times the client should retry when registering with the server
|
88
|
-
client_registration_retries 5
|
89
|
-
|
90
51
|
# Where the cookbooks are located. Meaning is somewhat context dependent between
|
91
52
|
# chef-client, and chef-solo.
|
92
|
-
cookbook_path [ "/
|
53
|
+
cookbook_path [ "#{ENV['HOME']}/cookbooks" ] + $:.reject {|x| x.match(/\/cookbooks$/) ? nil : x }
|
93
54
|
|
94
55
|
# Where cookbook files are stored on the server (by content checksum)
|
95
|
-
checksum_path "/
|
56
|
+
checksum_path "#{ENV['HOME']}/.microwave/checksums"
|
96
57
|
|
97
58
|
# Where chef's cache files should be stored
|
98
|
-
file_cache_path "/
|
59
|
+
file_cache_path "#{ENV['HOME']}/.microwave/cache"
|
99
60
|
|
100
61
|
# Where backups of chef-managed files should go
|
101
|
-
file_backup_path "/
|
62
|
+
file_backup_path "#{ENV['HOME']}/.microwave/backup"
|
102
63
|
|
103
|
-
http_retry_count 5
|
104
|
-
http_retry_delay 5
|
105
64
|
interval nil
|
106
65
|
log_level :info
|
107
66
|
log_location STDOUT
|
108
67
|
verbose_logging nil
|
109
68
|
node_name nil
|
110
|
-
node_path "/
|
69
|
+
node_path "#{ENV['HOME']}/nodes"
|
111
70
|
|
112
71
|
pid_file nil
|
113
72
|
|
114
|
-
rest_timeout 300
|
115
73
|
run_command_stderr_timeout 120
|
116
74
|
run_command_stdout_timeout 120
|
117
75
|
solo false
|
118
76
|
splay nil
|
119
77
|
|
120
|
-
# Set these to enable SSL authentication / mutual-authentication
|
121
|
-
# with the server
|
122
|
-
ssl_client_cert nil
|
123
|
-
ssl_client_key nil
|
124
|
-
ssl_verify_mode :verify_none
|
125
|
-
ssl_ca_path nil
|
126
|
-
ssl_ca_file nil
|
127
|
-
|
128
|
-
|
129
78
|
# Where should chef-solo look for role files?
|
130
|
-
role_path "/
|
79
|
+
role_path [ "#{ENV['HOME']}/roles" ]
|
131
80
|
|
132
81
|
# Report Handlers
|
133
82
|
report_handlers []
|
@@ -138,7 +87,7 @@ class Chef
|
|
138
87
|
# Checksum Cache
|
139
88
|
# Uses Moneta on the back-end
|
140
89
|
cache_type "BasicFile"
|
141
|
-
cache_options({ :path => "/
|
90
|
+
cache_options({ :path => "#{ENV['HOME']}/.microwave/cache/checksums", :skip_expires => true })
|
142
91
|
|
143
92
|
# Those lists of regular expressions define what chef considers a
|
144
93
|
# valid user and group name
|
@@ -45,7 +45,6 @@ class Chef
|
|
45
45
|
|
46
46
|
def load_cookbooks
|
47
47
|
load_as(:attribute_filenames, 'attributes', '*.rb')
|
48
|
-
load_as(:definition_filenames, 'definitions', '*.rb')
|
49
48
|
load_as(:recipe_filenames, 'recipes', '*.rb')
|
50
49
|
load_as(:library_filenames, 'libraries', '*.rb')
|
51
50
|
load_recursively_as(:template_filenames, "templates", "*")
|
@@ -58,8 +57,6 @@ class Chef
|
|
58
57
|
|
59
58
|
if File.exists?(File.join(@cookbook_path, "metadata.rb"))
|
60
59
|
@metadata_filenames << File.join(@cookbook_path, "metadata.rb")
|
61
|
-
elsif File.exists?(File.join(@cookbook_path, "metadata.json"))
|
62
|
-
@metadata_filenames << File.join(@cookbook_path, "metadata.json")
|
63
60
|
end
|
64
61
|
|
65
62
|
if empty?
|
@@ -94,8 +91,6 @@ class Chef
|
|
94
91
|
case metadata_file
|
95
92
|
when /\.rb$/
|
96
93
|
apply_ruby_metadata(metadata_file)
|
97
|
-
when /\.json$/
|
98
|
-
apply_json_metadata(metadata_file)
|
99
94
|
else
|
100
95
|
raise RuntimeError, "Invalid metadata file: #{metadata_file} for cookbook: #{cookbook_version}"
|
101
96
|
end
|
@@ -159,15 +154,6 @@ class Chef
|
|
159
154
|
end
|
160
155
|
end
|
161
156
|
|
162
|
-
def apply_json_metadata(file)
|
163
|
-
begin
|
164
|
-
@metadata.from_json(IO.read(file))
|
165
|
-
rescue JSON::ParserError
|
166
|
-
Chef::Log.error("Couldn't parse cookbook metadata JSON for #@cookbook_name in " + file)
|
167
|
-
raise
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
157
|
end
|
172
158
|
end
|
173
159
|
end
|
@@ -22,7 +22,6 @@
|
|
22
22
|
require 'chef/log'
|
23
23
|
require 'chef/client'
|
24
24
|
require 'chef/node'
|
25
|
-
require 'chef/resource_definition_list'
|
26
25
|
require 'chef/recipe'
|
27
26
|
require 'chef/cookbook/file_vendor'
|
28
27
|
require 'chef/checksum'
|
@@ -92,7 +91,7 @@ class Chef
|
|
92
91
|
class CookbookVersion
|
93
92
|
include Comparable
|
94
93
|
|
95
|
-
COOKBOOK_SEGMENTS = [ :resources, :providers, :recipes, :
|
94
|
+
COOKBOOK_SEGMENTS = [ :resources, :providers, :recipes, :libraries, :attributes, :files, :templates, :root_files ]
|
96
95
|
|
97
96
|
attr_accessor :root_dir
|
98
97
|
attr_accessor :definition_filenames
|
@@ -149,25 +148,6 @@ class Chef
|
|
149
148
|
reset_cache_validity
|
150
149
|
end
|
151
150
|
|
152
|
-
# Synchronizes all the cookbooks from the chef-server.
|
153
|
-
#
|
154
|
-
# === Returns
|
155
|
-
# true:: Always returns true
|
156
|
-
def self.sync_cookbooks(cookbook_hash)
|
157
|
-
Chef::Log.info("Loading cookbooks [#{cookbook_hash.keys.sort.join(', ')}]")
|
158
|
-
Chef::Log.debug("Cookbooks detail: #{cookbook_hash.inspect}")
|
159
|
-
|
160
|
-
clear_obsoleted_cookbooks(cookbook_hash)
|
161
|
-
|
162
|
-
# Synchronize each of the node's cookbooks, and add to the
|
163
|
-
# valid_cache_entries hash.
|
164
|
-
cookbook_hash.values.each do |cookbook|
|
165
|
-
sync_cookbook_file_cache(cookbook)
|
166
|
-
end
|
167
|
-
|
168
|
-
true
|
169
|
-
end
|
170
|
-
|
171
151
|
# Iterates over cached cookbooks' files, removing files belonging to
|
172
152
|
# cookbooks that don't appear in +cookbook_hash+
|
173
153
|
def self.clear_obsoleted_cookbooks(cookbook_hash)
|
@@ -181,67 +161,6 @@ class Chef
|
|
181
161
|
end
|
182
162
|
end
|
183
163
|
|
184
|
-
# Update the file caches for a given cache segment. Takes a segment name
|
185
|
-
# and a hash that matches one of the cookbooks/_attribute_files style
|
186
|
-
# remote file listings.
|
187
|
-
#
|
188
|
-
# === Parameters
|
189
|
-
# cookbook<Chef::Cookbook>:: The cookbook to update
|
190
|
-
# valid_cache_entries<Hash>:: Out-param; Added to this hash are the files that
|
191
|
-
# were referred to by this cookbook
|
192
|
-
def self.sync_cookbook_file_cache(cookbook)
|
193
|
-
Chef::Log.debug("Synchronizing cookbook #{cookbook.name}")
|
194
|
-
|
195
|
-
# files and templates are lazily loaded, and will be done later.
|
196
|
-
eager_segments = COOKBOOK_SEGMENTS.dup
|
197
|
-
eager_segments.delete(:files)
|
198
|
-
eager_segments.delete(:templates)
|
199
|
-
|
200
|
-
eager_segments.each do |segment|
|
201
|
-
segment_filenames = Array.new
|
202
|
-
cookbook.manifest[segment].each do |manifest_record|
|
203
|
-
# segment = cookbook segment
|
204
|
-
# remote_list = list of file hashes
|
205
|
-
#
|
206
|
-
# We need the list of known good attribute files, so we can delete any that are
|
207
|
-
# just laying about.
|
208
|
-
|
209
|
-
cache_filename = File.join("cookbooks", cookbook.name, manifest_record['path'])
|
210
|
-
valid_cache_entries[cache_filename] = true
|
211
|
-
|
212
|
-
current_checksum = nil
|
213
|
-
if cache.has_key?(cache_filename)
|
214
|
-
current_checksum = checksum_cookbook_file(cache.load(cache_filename, false))
|
215
|
-
end
|
216
|
-
|
217
|
-
# If the checksums are different between on-disk (current) and on-server
|
218
|
-
# (remote, per manifest), do the update. This will also execute if there
|
219
|
-
# is no current checksum.
|
220
|
-
if current_checksum != manifest_record['checksum']
|
221
|
-
raw_file = chef_server_rest.get_rest(manifest_record[:url], true)
|
222
|
-
|
223
|
-
Chef::Log.info("Storing updated #{cache_filename} in the cache.")
|
224
|
-
cache.move_to(raw_file.path, cache_filename)
|
225
|
-
else
|
226
|
-
Chef::Log.debug("Not storing #{cache_filename}, as the cache is up to date.")
|
227
|
-
end
|
228
|
-
|
229
|
-
# make the segment filenames a full path.
|
230
|
-
full_path_cache_filename = cache.load(cache_filename, false)
|
231
|
-
segment_filenames << full_path_cache_filename
|
232
|
-
end
|
233
|
-
|
234
|
-
# replace segment filenames with a full-path one.
|
235
|
-
if segment.to_sym == :recipes
|
236
|
-
cookbook.recipe_filenames = segment_filenames
|
237
|
-
elsif segment.to_sym == :attributes
|
238
|
-
cookbook.attribute_filenames = segment_filenames
|
239
|
-
else
|
240
|
-
cookbook.segment_filenames(segment).replace(segment_filenames)
|
241
|
-
end
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
164
|
def self.cleanup_file_cache
|
246
165
|
end
|
247
166
|
|
@@ -423,8 +342,6 @@ class Chef
|
|
423
342
|
@recipe_filenames
|
424
343
|
when :libraries
|
425
344
|
@library_filenames
|
426
|
-
when :definitions
|
427
|
-
@definition_filenames
|
428
345
|
when :attributes
|
429
346
|
@attribute_filenames
|
430
347
|
when :files
|
@@ -618,58 +535,10 @@ class Chef
|
|
618
535
|
rendered_manifest
|
619
536
|
end
|
620
537
|
|
621
|
-
def metadata_json_file
|
622
|
-
File.join(root_dir, "metadata.json")
|
623
|
-
end
|
624
|
-
|
625
538
|
def metadata_rb_file
|
626
539
|
File.join(root_dir, "metadata.rb")
|
627
540
|
end
|
628
541
|
|
629
|
-
def reload_metadata!
|
630
|
-
if File.exists?(metadata_json_file)
|
631
|
-
metadata.from_json(IO.read(metadata_json_file))
|
632
|
-
end
|
633
|
-
end
|
634
|
-
|
635
|
-
def destroy
|
636
|
-
chef_server_rest.delete_rest("cookbooks/#{name}/#{version}")
|
637
|
-
self
|
638
|
-
end
|
639
|
-
|
640
|
-
def self.load(name, version="_latest")
|
641
|
-
version = "_latest" if version == "latest"
|
642
|
-
chef_server_rest.get_rest("cookbooks/#{name}/#{version}")
|
643
|
-
end
|
644
|
-
|
645
|
-
def self.list
|
646
|
-
chef_server_rest.get_rest('cookbooks')
|
647
|
-
end
|
648
|
-
|
649
|
-
##
|
650
|
-
# Given a +cookbook_name+, get a list of all versions that exist on the
|
651
|
-
# server.
|
652
|
-
# ===Returns
|
653
|
-
# [String]:: Array of cookbook versions, which are strings like 'x.y.z'
|
654
|
-
# nil:: if the cookbook doesn't exist. an error will also be logged.
|
655
|
-
def self.available_versions(cookbook_name)
|
656
|
-
chef_server_rest.get_rest("cookbooks/#{cookbook_name}")[cookbook_name]["versions"].map do |cb|
|
657
|
-
cb["version"]
|
658
|
-
end
|
659
|
-
rescue Net::HTTPServerException => e
|
660
|
-
if e.to_s =~ /^404/
|
661
|
-
Chef::Log.error("Cannot find a cookbook named #{cookbook_name}")
|
662
|
-
nil
|
663
|
-
else
|
664
|
-
raise
|
665
|
-
end
|
666
|
-
end
|
667
|
-
|
668
|
-
# Get the newest version of all cookbooks
|
669
|
-
def self.latest_cookbooks
|
670
|
-
chef_server_rest.get_rest('cookbooks/_latest')
|
671
|
-
end
|
672
|
-
|
673
542
|
def <=>(o)
|
674
543
|
raise Chef::Exceptions::CookbookVersionNameMismatch if self.name != o.name
|
675
544
|
# FIXME: can we change the interface to the Metadata class such
|
@@ -691,7 +560,6 @@ class Chef
|
|
691
560
|
def generate_manifest
|
692
561
|
manifest = Mash.new({
|
693
562
|
:recipes => Array.new,
|
694
|
-
:definitions => Array.new,
|
695
563
|
:libraries => Array.new,
|
696
564
|
:attributes => Array.new,
|
697
565
|
:files => Array.new,
|
data/lib/chef/environment.rb
CHANGED
@@ -207,42 +207,6 @@ class Chef
|
|
207
207
|
environment
|
208
208
|
end
|
209
209
|
|
210
|
-
def self.list(inflate=false)
|
211
|
-
if inflate
|
212
|
-
# TODO: index the environments and use search to inflate - don't inflate for now :(
|
213
|
-
chef_server_rest.get_rest("environments")
|
214
|
-
else
|
215
|
-
chef_server_rest.get_rest("environments")
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
def self.load(name)
|
220
|
-
chef_server_rest.get_rest("environments/#{name}")
|
221
|
-
end
|
222
|
-
|
223
|
-
def destroy
|
224
|
-
chef_server_rest.delete_rest("environments/#{@name}")
|
225
|
-
end
|
226
|
-
|
227
|
-
def save
|
228
|
-
begin
|
229
|
-
chef_server_rest.put_rest("environments/#{@name}", self)
|
230
|
-
rescue Net::HTTPServerException => e
|
231
|
-
raise e unless e.response.code == "404"
|
232
|
-
chef_server_rest.post_rest("environments", self)
|
233
|
-
end
|
234
|
-
self
|
235
|
-
end
|
236
|
-
|
237
|
-
def create
|
238
|
-
chef_server_rest.post_rest("environments", self)
|
239
|
-
self
|
240
|
-
end
|
241
|
-
|
242
|
-
def self.load_filtered_recipe_list(environment)
|
243
|
-
chef_server_rest.get_rest("environments/#{environment}/recipes")
|
244
|
-
end
|
245
|
-
|
246
210
|
def to_s
|
247
211
|
@name
|
248
212
|
end
|
@@ -34,43 +34,27 @@ class Chef
|
|
34
34
|
include Chef::Mixin::Language
|
35
35
|
|
36
36
|
def method_missing(method_symbol, *args, &block)
|
37
|
-
#
|
38
|
-
|
39
|
-
|
40
|
-
if run_context.definitions.has_key?(method_symbol)
|
41
|
-
# This dupes the high level object, but we still need to dup the params
|
42
|
-
new_def = run_context.definitions[method_symbol].dup
|
43
|
-
new_def.params = new_def.params.dup
|
44
|
-
new_def.node = run_context.node
|
45
|
-
# This sets up the parameter overrides
|
46
|
-
new_def.instance_eval(&block) if block
|
47
|
-
new_recipe = Chef::Recipe.new(cookbook_name, @recipe_name, run_context)
|
48
|
-
new_recipe.params = new_def.params
|
49
|
-
new_recipe.params[:name] = args[0]
|
50
|
-
new_recipe.instance_eval(&new_def.recipe)
|
51
|
-
else
|
52
|
-
# Otherwise, we're rocking the regular resource call route.
|
53
|
-
method_name = method_symbol.to_s
|
54
|
-
rname = convert_to_class_name(method_name)
|
37
|
+
# Otherwise, we're rocking the regular resource call route.
|
38
|
+
method_name = method_symbol.to_s
|
39
|
+
rname = convert_to_class_name(method_name)
|
55
40
|
|
56
|
-
|
57
|
-
|
41
|
+
super unless Chef::Resource.const_defined?(rname)
|
42
|
+
raise ArgumentError, "You must supply a name when declaring a #{method_name} resource" unless args.size > 0
|
58
43
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
44
|
+
# If we have a resource like this one, we want to steal its state
|
45
|
+
args << run_context
|
46
|
+
resource = Chef::Resource.const_get(rname).new(*args)
|
47
|
+
resource.load_prior_resource
|
48
|
+
resource.cookbook_name = cookbook_name
|
49
|
+
resource.recipe_name = @recipe_name
|
50
|
+
resource.params = @params
|
51
|
+
resource.source_line = caller[0]
|
52
|
+
# Determine whether this resource is being created in the context of an enclosing Provider
|
53
|
+
resource.enclosing_provider = self.is_a?(Chef::Provider) ? self : nil
|
54
|
+
resource.instance_eval(&block) if block
|
70
55
|
|
71
|
-
|
72
|
-
|
73
|
-
end
|
56
|
+
run_context.resource_collection.insert(resource)
|
57
|
+
resource
|
74
58
|
end
|
75
59
|
|
76
60
|
end
|