chef 0.8.16 → 0.9.0.a3
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/bin/shef +1 -0
- data/distro/common/man/man1/chef-server-webui.1 +106 -0
- data/distro/common/man/man1/chef-server.1 +0 -1
- data/distro/common/man/man1/chef-solr-indexer.1 +55 -0
- data/distro/common/man/man1/chef-solr.1 +55 -0
- data/distro/common/man/man8/chef-client.8 +4 -2
- data/distro/common/man/man8/chef-solo.8 +1 -2
- data/distro/common/man/man8/chef-solr-rebuild.8 +37 -0
- data/distro/common/man/man8/knife.8 +668 -266
- data/distro/common/man/man8/shef.8 +45 -0
- data/distro/common/markdown/README +3 -0
- data/distro/common/markdown/knife.mkd +520 -0
- data/distro/debian/etc/default/chef-client +4 -0
- data/distro/debian/etc/default/chef-server +6 -0
- data/distro/debian/etc/default/chef-server-webui +6 -0
- data/distro/debian/etc/default/chef-solr +4 -0
- data/distro/debian/etc/default/chef-solr-indexer +4 -0
- data/distro/debian/etc/init.d/chef-client +41 -41
- data/distro/debian/etc/init.d/chef-server +10 -10
- data/distro/debian/etc/init.d/chef-server-webui +121 -0
- data/distro/debian/etc/init.d/chef-solr +177 -0
- data/distro/debian/etc/init.d/chef-solr-indexer +176 -0
- data/distro/redhat/etc/init.d/chef-client +76 -48
- data/distro/redhat/etc/init.d/chef-server +85 -51
- data/distro/redhat/etc/init.d/chef-server-webui +85 -51
- data/distro/redhat/etc/init.d/chef-solr +77 -49
- data/distro/redhat/etc/init.d/chef-solr-indexer +77 -48
- data/distro/redhat/etc/logrotate.d/chef-client +8 -0
- data/distro/redhat/etc/logrotate.d/chef-server +8 -0
- data/distro/redhat/etc/logrotate.d/chef-server-webui +8 -0
- data/distro/redhat/etc/logrotate.d/chef-solr +8 -0
- data/distro/redhat/etc/logrotate.d/chef-solr-indexer +8 -0
- data/distro/redhat/etc/sysconfig/chef-client +9 -4
- data/distro/redhat/etc/sysconfig/chef-server +10 -6
- data/distro/redhat/etc/sysconfig/chef-server-webui +10 -6
- data/distro/redhat/etc/sysconfig/chef-solr +3 -4
- data/distro/redhat/etc/sysconfig/chef-solr-indexer +3 -3
- data/lib/chef.rb +16 -5
- data/lib/chef/application/knife.rb +2 -2
- data/lib/chef/application/solo.rb +1 -7
- data/lib/chef/cache/checksum.rb +12 -5
- data/lib/chef/cache/file_cache_by_checksum.rb +52 -0
- data/lib/chef/checksum.rb +115 -0
- data/lib/chef/client.rb +193 -185
- data/lib/chef/config.rb +9 -1
- data/lib/chef/cookbook/cookbook_collection.rb +43 -0
- data/lib/chef/cookbook/file_system_file_vendor.rb +53 -0
- data/lib/chef/cookbook/file_vendor.rb +47 -0
- data/lib/chef/cookbook/metadata.rb +34 -35
- data/lib/chef/cookbook/metadata/version.rb +1 -1
- data/lib/chef/cookbook_loader.rb +70 -45
- data/lib/chef/cookbook_version.rb +760 -0
- data/lib/chef/couchdb.rb +8 -5
- data/lib/chef/data_bag_item.rb +5 -5
- data/lib/chef/exceptions.rb +10 -0
- data/lib/chef/file_access_control.rb +134 -0
- data/lib/chef/handler.rb +62 -0
- data/lib/chef/handler/json_file.rb +47 -0
- data/lib/chef/knife.rb +14 -2
- data/lib/chef/knife/bootstrap.rb +126 -0
- data/lib/chef/knife/cookbook_bulk_delete.rb +1 -1
- data/lib/chef/knife/cookbook_delete.rb +4 -4
- data/lib/chef/knife/cookbook_download.rb +57 -26
- data/lib/chef/knife/cookbook_metadata.rb +2 -2
- data/lib/chef/knife/cookbook_show.rb +30 -11
- data/lib/chef/knife/cookbook_upload.rb +113 -86
- data/lib/chef/knife/ec2_server_create.rb +146 -0
- data/lib/chef/knife/ec2_server_delete.rb +84 -0
- data/lib/chef/knife/ec2_server_list.rb +82 -0
- data/lib/chef/knife/status.rb +51 -0
- data/lib/chef/mixin/language_include_attribute.rb +16 -11
- data/lib/chef/mixin/language_include_recipe.rb +15 -16
- data/lib/chef/mixin/recipe_definition_dsl_core.rb +17 -20
- data/lib/chef/mixin/shell_out.rb +38 -0
- data/lib/chef/mixins.rb +1 -1
- data/lib/chef/node.rb +190 -63
- data/lib/chef/node/attribute.rb +92 -78
- data/lib/chef/platform.rb +24 -4
- data/lib/chef/provider.rb +28 -10
- data/lib/chef/provider/breakpoint.rb +2 -2
- data/lib/chef/provider/cookbook_file.rb +96 -0
- data/lib/chef/provider/cron.rb +2 -2
- data/lib/chef/provider/deploy.rb +12 -10
- data/lib/chef/provider/env.rb +152 -0
- data/lib/chef/provider/env/windows.rb +75 -0
- data/lib/chef/provider/file.rb +10 -14
- data/lib/chef/provider/group.rb +15 -2
- data/lib/chef/provider/group/dscl.rb +17 -25
- data/lib/chef/provider/group/gpasswd.rb +6 -3
- data/lib/chef/provider/group/pw.rb +3 -7
- data/lib/chef/provider/group/windows.rb +79 -0
- data/lib/chef/provider/link.rb +4 -5
- data/lib/chef/provider/mdadm.rb +25 -18
- data/lib/chef/provider/mount/mount.rb +28 -27
- data/lib/chef/provider/package.rb +35 -35
- data/lib/chef/provider/package/dpkg.rb +13 -10
- data/lib/chef/provider/package/easy_install.rb +6 -6
- data/lib/chef/provider/package/freebsd.rb +17 -51
- data/lib/chef/provider/package/rpm.rb +1 -1
- data/lib/chef/provider/package/rubygems.rb +391 -74
- data/lib/chef/provider/package/yum.rb +2 -2
- data/lib/chef/provider/package/zypper.rb +2 -1
- data/lib/chef/provider/remote_directory.rb +60 -83
- data/lib/chef/provider/remote_file.rb +17 -66
- data/lib/chef/provider/script.rb +20 -9
- data/lib/chef/provider/service.rb +23 -30
- data/lib/chef/provider/service/arch.rb +3 -3
- data/lib/chef/provider/service/debian.rb +22 -17
- data/lib/chef/provider/service/freebsd.rb +4 -4
- data/lib/chef/provider/service/init.rb +2 -2
- data/lib/chef/provider/service/redhat.rb +14 -16
- data/lib/chef/provider/service/simple.rb +7 -3
- data/lib/chef/provider/service/solaris.rb +85 -0
- data/lib/chef/provider/service/upstart.rb +12 -7
- data/lib/chef/provider/service/windows.rb +2 -2
- data/lib/chef/provider/template.rb +133 -118
- data/lib/chef/provider/user.rb +34 -17
- data/lib/chef/provider/user/dscl.rb +117 -114
- data/lib/chef/provider/user/windows.rb +124 -0
- data/lib/chef/providers.rb +7 -0
- data/lib/chef/recipe.rb +39 -20
- data/lib/chef/resource.rb +47 -52
- data/lib/chef/resource/apt_package.rb +4 -4
- data/lib/chef/resource/bash.rb +4 -4
- data/lib/chef/resource/cookbook_file.rb +45 -0
- data/lib/chef/resource/cron.rb +3 -3
- data/lib/chef/resource/csh.rb +4 -4
- data/lib/chef/resource/deploy.rb +3 -3
- data/lib/chef/resource/directory.rb +4 -4
- data/lib/chef/resource/dpkg_package.rb +4 -4
- data/lib/chef/resource/easy_install_package.rb +3 -3
- data/lib/chef/resource/env.rb +58 -0
- data/lib/chef/resource/erl_call.rb +3 -3
- data/lib/chef/resource/execute.rb +3 -3
- data/lib/chef/resource/file.rb +3 -3
- data/lib/chef/resource/freebsd_package.rb +3 -3
- data/lib/chef/resource/gem_package.rb +17 -9
- data/lib/chef/resource/git.rb +3 -3
- data/lib/chef/resource/group.rb +3 -3
- data/lib/chef/resource/http_request.rb +4 -4
- data/lib/chef/resource/ifconfig.rb +3 -3
- data/lib/chef/resource/link.rb +3 -3
- data/lib/chef/resource/log.rb +2 -2
- data/lib/chef/resource/macports_package.rb +2 -2
- data/lib/chef/resource/mdadm.rb +3 -3
- data/lib/chef/resource/mount.rb +2 -2
- data/lib/chef/resource/package.rb +4 -4
- data/lib/chef/resource/pacman_package.rb +4 -4
- data/lib/chef/resource/perl.rb +4 -4
- data/lib/chef/resource/portage_package.rb +4 -4
- data/lib/chef/resource/python.rb +4 -4
- data/lib/chef/resource/remote_directory.rb +3 -3
- data/lib/chef/resource/remote_file.rb +26 -3
- data/lib/chef/resource/route.rb +3 -3
- data/lib/chef/resource/ruby.rb +3 -3
- data/lib/chef/resource/ruby_block.rb +3 -2
- data/lib/chef/resource/scm.rb +7 -5
- data/lib/chef/resource/script.rb +4 -4
- data/lib/chef/resource/service.rb +3 -3
- data/lib/chef/resource/subversion.rb +4 -2
- data/lib/chef/resource/template.rb +3 -3
- data/lib/chef/resource/user.rb +3 -3
- data/lib/chef/resource/yum_package.rb +3 -3
- data/lib/chef/resource_collection.rb +9 -5
- data/lib/chef/resources.rb +2 -0
- data/lib/chef/rest.rb +4 -0
- data/lib/chef/role.rb +2 -0
- data/lib/chef/run_context.rb +108 -0
- data/lib/chef/run_list.rb +75 -98
- data/lib/chef/run_list/run_list_expansion.rb +156 -0
- data/lib/chef/run_list/run_list_item.rb +71 -0
- data/lib/chef/runner.rb +58 -61
- data/lib/chef/sandbox.rb +147 -0
- data/lib/chef/shef.rb +4 -3
- data/lib/chef/shef/ext.rb +12 -4
- data/lib/chef/shef/shef_session.rb +27 -23
- data/lib/chef/shell_out.rb +375 -0
- data/lib/chef/util/windows.rb +56 -0
- data/lib/chef/util/windows/net_group.rb +101 -0
- data/lib/chef/util/windows/net_user.rb +198 -0
- data/lib/chef/version.rb +20 -0
- metadata +112 -22
- data/lib/chef/compile.rb +0 -158
- data/lib/chef/cookbook.rb +0 -201
- data/lib/chef/mixin/generate_url.rb +0 -58
data/lib/chef/providers.rb
CHANGED
@@ -17,9 +17,11 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require 'chef/provider/breakpoint'
|
20
|
+
require 'chef/provider/cookbook_file'
|
20
21
|
require 'chef/provider/cron'
|
21
22
|
require 'chef/provider/deploy'
|
22
23
|
require 'chef/provider/directory'
|
24
|
+
require 'chef/provider/env'
|
23
25
|
require 'chef/provider/erl_call'
|
24
26
|
require 'chef/provider/execute'
|
25
27
|
require 'chef/provider/file'
|
@@ -42,6 +44,8 @@ require 'chef/provider/subversion'
|
|
42
44
|
require 'chef/provider/template'
|
43
45
|
require 'chef/provider/user'
|
44
46
|
|
47
|
+
require 'chef/provider/env/windows'
|
48
|
+
|
45
49
|
require 'chef/provider/package/apt'
|
46
50
|
require 'chef/provider/package/dpkg'
|
47
51
|
require 'chef/provider/package/easy_install'
|
@@ -63,16 +67,19 @@ require 'chef/provider/service/redhat'
|
|
63
67
|
require 'chef/provider/service/simple'
|
64
68
|
require 'chef/provider/service/upstart'
|
65
69
|
require 'chef/provider/service/windows'
|
70
|
+
require 'chef/provider/service/solaris'
|
66
71
|
|
67
72
|
require 'chef/provider/user/dscl'
|
68
73
|
require 'chef/provider/user/pw'
|
69
74
|
require 'chef/provider/user/useradd'
|
75
|
+
require 'chef/provider/user/windows'
|
70
76
|
|
71
77
|
require 'chef/provider/group/dscl'
|
72
78
|
require 'chef/provider/group/gpasswd'
|
73
79
|
require 'chef/provider/group/groupadd'
|
74
80
|
require 'chef/provider/group/pw'
|
75
81
|
require 'chef/provider/group/usermod'
|
82
|
+
require 'chef/provider/group/windows'
|
76
83
|
|
77
84
|
require 'chef/provider/mount/mount'
|
78
85
|
|
data/lib/chef/recipe.rb
CHANGED
@@ -22,8 +22,6 @@ require 'chef/mixin/recipe_definition_dsl_core'
|
|
22
22
|
require 'chef/mixin/from_file'
|
23
23
|
require 'chef/mixin/language'
|
24
24
|
require 'chef/mixin/language_include_recipe'
|
25
|
-
require 'chef/resource_collection'
|
26
|
-
require 'chef/cookbook_loader'
|
27
25
|
|
28
26
|
class Chef
|
29
27
|
class Recipe
|
@@ -33,25 +31,46 @@ class Chef
|
|
33
31
|
include Chef::Mixin::LanguageIncludeRecipe
|
34
32
|
include Chef::Mixin::RecipeDefinitionDSLCore
|
35
33
|
|
36
|
-
attr_accessor :cookbook_name, :recipe_name, :recipe, :
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
attr_accessor :cookbook_name, :recipe_name, :recipe, :params, :run_context
|
35
|
+
|
36
|
+
# Parses a potentially fully-qualified recipe name into its
|
37
|
+
# cookbook name and recipe short name.
|
38
|
+
#
|
39
|
+
# For example:
|
40
|
+
# "aws::elastic_ip" returns [:aws, "elastic_ip"]
|
41
|
+
# "aws" returns [:aws, "default"]
|
42
|
+
def self.parse_recipe_name(recipe_name)
|
43
|
+
rmatch = recipe_name.match(/(.+?)::(.+)/)
|
44
|
+
if rmatch
|
45
|
+
[ rmatch[1].to_sym, rmatch[2] ]
|
46
|
+
else
|
47
|
+
[ recipe_name.to_sym, "default" ]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def initialize(cookbook_name, recipe_name, run_context)
|
40
52
|
@cookbook_name = cookbook_name
|
41
53
|
@recipe_name = recipe_name
|
42
|
-
@
|
43
|
-
|
44
|
-
@
|
45
|
-
@cookbook_loader = cookbook_loader || Chef::CookbookLoader.new
|
46
|
-
@params = Hash.new
|
54
|
+
@run_context = run_context
|
55
|
+
# TODO: 5/19/2010 cw/tim: determine whether this can be removed
|
56
|
+
@params = Hash.new
|
47
57
|
end
|
48
58
|
|
59
|
+
# Used in DSL mixins
|
60
|
+
def node
|
61
|
+
run_context.node
|
62
|
+
end
|
63
|
+
|
64
|
+
# what does this do? and what is args? TODO 5-14-2010.
|
65
|
+
#
|
66
|
+
# We believe this is used by the DSL when it's executing in the
|
67
|
+
# context of a recipe in order to look up resources.
|
49
68
|
def resources(*args)
|
50
|
-
|
69
|
+
run_context.resource_collection.find(*args)
|
51
70
|
end
|
52
71
|
|
53
72
|
# Sets a tag, or list of tags, for this node. Syntactic sugar for
|
54
|
-
#
|
73
|
+
# run_context.node[:tags].
|
55
74
|
#
|
56
75
|
# With no arguments, returns the list of tags.
|
57
76
|
#
|
@@ -59,15 +78,15 @@ class Chef
|
|
59
78
|
# tags<Array>:: A list of tags to add - can be a single string
|
60
79
|
#
|
61
80
|
# === Returns
|
62
|
-
# tags<Array>:: The contents of
|
81
|
+
# tags<Array>:: The contents of run_context.node[:tags]
|
63
82
|
def tag(*args)
|
64
83
|
if args.length > 0
|
65
84
|
args.each do |tag|
|
66
|
-
|
85
|
+
run_context.node[:tags] << tag unless run_context.node[:tags].include?(tag)
|
67
86
|
end
|
68
|
-
|
87
|
+
run_context.node[:tags]
|
69
88
|
else
|
70
|
-
|
89
|
+
run_context.node[:tags]
|
71
90
|
end
|
72
91
|
end
|
73
92
|
|
@@ -81,7 +100,7 @@ class Chef
|
|
81
100
|
# false<FalseClass>:: If any of the parameters are missing
|
82
101
|
def tagged?(*args)
|
83
102
|
args.each do |tag|
|
84
|
-
return false unless
|
103
|
+
return false unless run_context.node[:tags].include?(tag)
|
85
104
|
end
|
86
105
|
true
|
87
106
|
end
|
@@ -92,10 +111,10 @@ class Chef
|
|
92
111
|
# tags<Array>:: A list of tags
|
93
112
|
#
|
94
113
|
# === Returns
|
95
|
-
# tags<Array>:: The current list of
|
114
|
+
# tags<Array>:: The current list of run_context.node[:tags]
|
96
115
|
def untag(*args)
|
97
116
|
args.each do |tag|
|
98
|
-
|
117
|
+
run_context.node[:tags].delete(tag)
|
99
118
|
end
|
100
119
|
end
|
101
120
|
|
data/lib/chef/resource.rb
CHANGED
@@ -32,20 +32,18 @@ class Chef
|
|
32
32
|
include Chef::Mixin::Language
|
33
33
|
include Chef::Mixin::ConvertToClassName
|
34
34
|
|
35
|
-
attr_accessor :
|
36
|
-
attr_reader :resource_name, :source_line, :
|
35
|
+
attr_accessor :params, :provider, :updated, :allowed_actions, :run_context, :cookbook_name, :recipe_name, :enclosing_provider
|
36
|
+
attr_reader :resource_name, :source_line, :not_if_args, :only_if_args
|
37
|
+
|
38
|
+
# Each notify entry is a resource/action pair, modeled as an
|
39
|
+
# OpenStruct with a .resource and .action member
|
40
|
+
attr_reader :notifies_immediate, :notifies_delayed
|
37
41
|
|
38
|
-
def initialize(name,
|
42
|
+
def initialize(name, run_context=nil)
|
39
43
|
@name = name
|
40
|
-
|
41
|
-
@collection = collection
|
42
|
-
else
|
43
|
-
@collection = Chef::ResourceCollection.new()
|
44
|
-
end
|
45
|
-
@node = node ? node : Chef::Node.new
|
44
|
+
@run_context = run_context
|
46
45
|
@noop = nil
|
47
46
|
@before = nil
|
48
|
-
@actions = Hash.new
|
49
47
|
@params = Hash.new
|
50
48
|
@provider = nil
|
51
49
|
@allowed_actions = [ :nothing ]
|
@@ -57,12 +55,18 @@ class Chef
|
|
57
55
|
@not_if_args = {}
|
58
56
|
@only_if = nil
|
59
57
|
@only_if_args = {}
|
58
|
+
@notifies_immediate = Array.new
|
59
|
+
@notifies_delayed = Array.new
|
60
60
|
sline = caller(4).shift
|
61
61
|
if sline
|
62
62
|
@source_line = sline.gsub!(/^(.+):(.+):.+$/, '\1 line \2')
|
63
63
|
@source_line = ::File.expand_path(@source_line) if @source_line
|
64
64
|
end
|
65
65
|
end
|
66
|
+
|
67
|
+
def node
|
68
|
+
run_context && run_context.node
|
69
|
+
end
|
66
70
|
|
67
71
|
# If an unknown method is invoked, determine whether the enclosing Provider's
|
68
72
|
# lexical scope can fulfill the request. E.g. This happens when the Resource's
|
@@ -77,7 +81,7 @@ class Chef
|
|
77
81
|
|
78
82
|
def load_prior_resource
|
79
83
|
begin
|
80
|
-
prior_resource =
|
84
|
+
prior_resource = run_context.resource_collection.lookup(self.to_s)
|
81
85
|
Chef::Log.debug("Setting #{self.to_s} to the state of the prior #{self.to_s}")
|
82
86
|
prior_resource.instance_variables.each do |iv|
|
83
87
|
unless iv.to_sym == :@source_line || iv.to_sym == :@action
|
@@ -178,24 +182,15 @@ class Chef
|
|
178
182
|
end
|
179
183
|
end
|
180
184
|
end
|
181
|
-
|
185
|
+
|
182
186
|
def resources(*args)
|
183
|
-
|
187
|
+
run_context.resource_collection.resources(*args)
|
184
188
|
end
|
185
189
|
|
186
190
|
def subscribes(action, resources, timing=:delayed)
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
action_sym = action.to_sym
|
191
|
-
if resource.actions.has_key?(action_sym)
|
192
|
-
resource.actions[action_sym][timing] << self
|
193
|
-
else
|
194
|
-
resource.actions[action_sym] = Hash.new
|
195
|
-
resource.actions[action_sym][:delayed] = Array.new
|
196
|
-
resource.actions[action_sym][:immediate] = Array.new
|
197
|
-
resource.actions[action_sym][timing] << self
|
198
|
-
end
|
191
|
+
resources = [resources].flatten
|
192
|
+
resources.each do |resource|
|
193
|
+
resource.notifies(action, self, timing)
|
199
194
|
end
|
200
195
|
true
|
201
196
|
end
|
@@ -216,7 +211,9 @@ class Chef
|
|
216
211
|
def to_json(*a)
|
217
212
|
instance_vars = Hash.new
|
218
213
|
self.instance_variables.each do |iv|
|
219
|
-
|
214
|
+
unless iv == "@run_context"
|
215
|
+
instance_vars[iv] = self.instance_variable_get(iv)
|
216
|
+
end
|
220
217
|
end
|
221
218
|
results = {
|
222
219
|
'json_class' => self.class.name,
|
@@ -229,7 +226,7 @@ class Chef
|
|
229
226
|
instance_vars = Hash.new
|
230
227
|
self.instance_variables.each do |iv|
|
231
228
|
iv = iv.to_s
|
232
|
-
next if iv == "@
|
229
|
+
next if iv == "@run_context"
|
233
230
|
instance_vars[iv.sub(/^@/,'').to_sym] = self.instance_variable_get(iv)
|
234
231
|
end
|
235
232
|
instance_vars
|
@@ -258,11 +255,15 @@ class Chef
|
|
258
255
|
end
|
259
256
|
|
260
257
|
def run_action(action)
|
261
|
-
provider = Chef::Platform.
|
258
|
+
provider = Chef::Platform.provider_for_resource(self)
|
262
259
|
provider.load_current_resource
|
263
260
|
provider.send("action_#{action}")
|
264
261
|
end
|
265
262
|
|
263
|
+
def updated?
|
264
|
+
updated
|
265
|
+
end
|
266
|
+
|
266
267
|
class << self
|
267
268
|
|
268
269
|
def json_create(o)
|
@@ -300,8 +301,8 @@ class Chef
|
|
300
301
|
# default initialize method that ensures that when initialize is finally
|
301
302
|
# wrapped (see below), super is called in the event that the resource
|
302
303
|
# definer does not implement initialize
|
303
|
-
def initialize(name,
|
304
|
-
super(name,
|
304
|
+
def initialize(name, run_context)
|
305
|
+
super(name, run_context)
|
305
306
|
end
|
306
307
|
|
307
308
|
@actions_to_create = []
|
@@ -326,10 +327,9 @@ class Chef
|
|
326
327
|
old_init = instance_method(:initialize)
|
327
328
|
|
328
329
|
define_method(:initialize) do |name, *optional_args|
|
329
|
-
|
330
|
-
node = optional_args.shift
|
330
|
+
args_run_context = optional_args.shift
|
331
331
|
@resource_name = rname.to_sym
|
332
|
-
old_init.bind(self).call(name,
|
332
|
+
old_init.bind(self).call(name, args_run_context)
|
333
333
|
allowed_actions.push(self.class.actions_to_create).flatten!
|
334
334
|
end
|
335
335
|
end
|
@@ -370,31 +370,26 @@ class Chef
|
|
370
370
|
end
|
371
371
|
end
|
372
372
|
|
373
|
-
def
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
if timing == :immediately
|
378
|
-
timing = :immediate
|
379
|
-
end
|
380
|
-
timing
|
373
|
+
def validate_timing(timing)
|
374
|
+
timing = timing.to_sym
|
375
|
+
raise ArgumentError, "invalid timing: #{timing}; must be one of: :delayed, :immediate, :immediately" unless (timing == :delayed || timing == :immediate || timing == :immediately)
|
376
|
+
timing == :immediately ? :immediate : timing
|
381
377
|
end
|
382
378
|
|
383
379
|
def notifies_helper(action, resources, timing=:delayed)
|
384
|
-
timing =
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
380
|
+
timing = validate_timing(timing)
|
381
|
+
|
382
|
+
resource_array = [resources].flatten
|
383
|
+
resource_array.each do |resource|
|
384
|
+
new_notify = OpenStruct.new(:resource => resource, :action => action)
|
385
|
+
if timing == :delayed
|
386
|
+
notifies_delayed << new_notify
|
390
387
|
else
|
391
|
-
|
392
|
-
@actions[action_sym][:delayed] = Array.new
|
393
|
-
@actions[action_sym][:immediate] = Array.new
|
394
|
-
@actions[action_sym][timing] << resource
|
388
|
+
notifies_immediate << new_notify
|
395
389
|
end
|
396
390
|
end
|
391
|
+
|
397
392
|
true
|
398
393
|
end
|
399
|
-
|
394
|
+
end
|
400
395
|
end
|
@@ -22,13 +22,13 @@ require 'chef/provider/package/apt'
|
|
22
22
|
class Chef
|
23
23
|
class Resource
|
24
24
|
class AptPackage < Chef::Resource::Package
|
25
|
-
|
26
|
-
def initialize(name,
|
27
|
-
super
|
25
|
+
|
26
|
+
def initialize(name, run_context=nil)
|
27
|
+
super
|
28
28
|
@resource_name = :apt_package
|
29
29
|
@provider = Chef::Provider::Package::Apt
|
30
30
|
end
|
31
31
|
|
32
32
|
end
|
33
33
|
end
|
34
|
-
end
|
34
|
+
end
|
data/lib/chef/resource/bash.rb
CHANGED
@@ -21,13 +21,13 @@ require 'chef/resource/script'
|
|
21
21
|
class Chef
|
22
22
|
class Resource
|
23
23
|
class Bash < Chef::Resource::Script
|
24
|
-
|
25
|
-
def initialize(name,
|
26
|
-
super
|
24
|
+
|
25
|
+
def initialize(name, run_context=nil)
|
26
|
+
super
|
27
27
|
@resource_name = :bash
|
28
28
|
@interpreter = "bash"
|
29
29
|
end
|
30
30
|
|
31
31
|
end
|
32
32
|
end
|
33
|
-
end
|
33
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'chef/resource/file'
|
20
|
+
require 'chef/provider/cookbook_file'
|
21
|
+
|
22
|
+
class Chef
|
23
|
+
class Resource
|
24
|
+
class CookbookFile < Chef::Resource::File
|
25
|
+
|
26
|
+
def initialize(name, run_context=nil)
|
27
|
+
super
|
28
|
+
@provider = Chef::Provider::CookbookFile
|
29
|
+
@resource_name = :cookbook_file
|
30
|
+
@action = "create"
|
31
|
+
@source = ::File.basename(name)
|
32
|
+
@cookbook = nil
|
33
|
+
end
|
34
|
+
|
35
|
+
def source(source_filename=nil)
|
36
|
+
set_or_return(:source, source_filename, :kind_of => String)
|
37
|
+
end
|
38
|
+
|
39
|
+
def cookbook(cookbook_name=nil)
|
40
|
+
set_or_return(:cookbook, cookbook_name, :kind_of => String)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/chef/resource/cron.rb
CHANGED
@@ -21,9 +21,9 @@ require 'chef/resource'
|
|
21
21
|
class Chef
|
22
22
|
class Resource
|
23
23
|
class Cron < Chef::Resource
|
24
|
-
|
25
|
-
def initialize(name,
|
26
|
-
super
|
24
|
+
|
25
|
+
def initialize(name, run_context=nil)
|
26
|
+
super
|
27
27
|
@resource_name = :cron
|
28
28
|
@action = :create
|
29
29
|
@allowed_actions.push(:create, :delete)
|
data/lib/chef/resource/csh.rb
CHANGED
@@ -21,13 +21,13 @@ require 'chef/resource/script'
|
|
21
21
|
class Chef
|
22
22
|
class Resource
|
23
23
|
class Csh < Chef::Resource::Script
|
24
|
-
|
25
|
-
def initialize(name,
|
26
|
-
super
|
24
|
+
|
25
|
+
def initialize(name, run_context=nil)
|
26
|
+
super
|
27
27
|
@resource_name = :csh
|
28
28
|
@interpreter = "csh"
|
29
29
|
end
|
30
30
|
|
31
31
|
end
|
32
32
|
end
|
33
|
-
end
|
33
|
+
end
|