chef 0.9.18 → 0.10.0.beta.0
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/README.rdoc +0 -3
- data/distro/arch/etc/rc.d/chef-server +0 -4
- data/distro/arch/etc/rc.d/chef-server-webui +0 -4
- data/distro/arch/etc/rc.d/chef-solr +0 -4
- data/distro/arch/etc/rc.d/chef-solr-indexer +0 -4
- data/lib/chef.rb +3 -3
- data/lib/chef/api_client.rb +1 -1
- data/lib/chef/application.rb +11 -1
- data/lib/chef/application/client.rb +18 -22
- data/lib/chef/application/knife.rb +28 -29
- data/lib/chef/application/solo.rb +14 -12
- data/lib/chef/client.rb +112 -54
- data/lib/chef/config.rb +4 -0
- data/lib/chef/cookbook/chefignore.rb +66 -0
- data/lib/chef/cookbook/cookbook_collection.rb +6 -5
- data/lib/chef/cookbook/cookbook_version_loader.rb +151 -0
- data/lib/chef/cookbook/file_system_file_vendor.rb +10 -8
- data/lib/chef/cookbook/metadata.rb +200 -108
- data/lib/chef/cookbook_loader.rb +39 -163
- data/lib/chef/cookbook_uploader.rb +100 -78
- data/lib/chef/cookbook_version.rb +92 -47
- data/lib/chef/cookbook_version_selector.rb +163 -0
- data/lib/chef/couchdb.rb +9 -1
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/data_bag_item.rb +1 -1
- data/lib/chef/encrypted_data_bag_item.rb +126 -0
- data/lib/chef/environment.rb +386 -0
- data/lib/chef/exceptions.rb +82 -1
- data/lib/chef/index_queue/amqp_client.rb +15 -12
- data/lib/chef/index_queue/indexable.rb +38 -4
- data/lib/chef/json_compat.rb +3 -3
- data/lib/chef/knife.rb +97 -202
- data/lib/chef/knife/bootstrap.rb +27 -61
- data/lib/chef/knife/bootstrap/archlinux-gems.erb +4 -2
- data/lib/chef/knife/bootstrap/centos5-gems.erb +6 -15
- data/lib/chef/knife/bootstrap/fedora13-gems.erb +3 -4
- data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +2 -2
- data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +6 -5
- data/lib/chef/knife/client_bulk_delete.rb +6 -3
- data/lib/chef/knife/client_create.rb +13 -10
- data/lib/chef/knife/client_delete.rb +10 -7
- data/lib/chef/knife/client_edit.rb +9 -6
- data/lib/chef/knife/client_list.rb +8 -5
- data/lib/chef/knife/client_reregister.rb +9 -6
- data/lib/chef/knife/client_show.rb +9 -6
- data/lib/chef/knife/configure.rb +15 -19
- data/lib/chef/knife/configure_client.rb +4 -4
- data/lib/chef/knife/cookbook_bulk_delete.rb +11 -8
- data/lib/chef/knife/cookbook_create.rb +120 -55
- data/lib/chef/knife/cookbook_delete.rb +18 -12
- data/lib/chef/knife/cookbook_download.rb +10 -6
- data/lib/chef/knife/cookbook_list.rb +15 -6
- data/lib/chef/knife/cookbook_metadata.rb +41 -21
- data/lib/chef/knife/cookbook_metadata_from_file.rb +4 -0
- data/lib/chef/knife/cookbook_show.rb +16 -5
- data/lib/chef/knife/cookbook_site_download.rb +2 -2
- data/lib/chef/knife/cookbook_site_share.rb +18 -13
- data/lib/chef/knife/cookbook_site_unshare.rb +7 -4
- data/lib/chef/knife/cookbook_site_vendor.rb +21 -18
- data/lib/chef/knife/cookbook_test.rb +14 -14
- data/lib/chef/knife/cookbook_upload.rb +91 -40
- data/lib/chef/knife/data_bag_create.rb +41 -6
- data/lib/chef/knife/data_bag_delete.rb +5 -3
- data/lib/chef/knife/data_bag_edit.rb +55 -11
- data/lib/chef/knife/data_bag_from_file.rb +47 -7
- data/lib/chef/knife/data_bag_list.rb +4 -1
- data/lib/chef/knife/data_bag_show.rb +44 -4
- data/lib/chef/knife/environment_create.rb +53 -0
- data/lib/chef/knife/environment_delete.rb +45 -0
- data/lib/chef/knife/environment_edit.rb +45 -0
- data/lib/chef/knife/environment_from_file.rb +39 -0
- data/lib/chef/knife/environment_list.rb +42 -0
- data/lib/chef/knife/environment_show.rb +46 -0
- data/lib/chef/knife/exec.rb +1 -1
- data/lib/chef/knife/index_rebuild.rb +8 -9
- data/lib/chef/knife/node_bulk_delete.rb +9 -6
- data/lib/chef/knife/node_create.rb +9 -6
- data/lib/chef/knife/node_delete.rb +10 -7
- data/lib/chef/knife/node_edit.rb +129 -10
- data/lib/chef/knife/node_from_file.rb +10 -7
- data/lib/chef/knife/node_list.rb +11 -6
- data/lib/chef/knife/node_run_list_add.rb +10 -7
- data/lib/chef/knife/node_run_list_remove.rb +9 -6
- data/lib/chef/knife/node_show.rb +15 -7
- data/lib/chef/knife/recipe_list.rb +4 -3
- data/lib/chef/knife/role_bulk_delete.rb +9 -6
- data/lib/chef/knife/role_create.rb +9 -6
- data/lib/chef/knife/role_delete.rb +10 -7
- data/lib/chef/knife/role_edit.rb +11 -8
- data/lib/chef/knife/role_from_file.rb +10 -7
- data/lib/chef/knife/role_list.rb +8 -5
- data/lib/chef/knife/role_show.rb +11 -8
- data/lib/chef/knife/search.rb +33 -10
- data/lib/chef/knife/ssh.rb +33 -61
- data/lib/chef/knife/status.rb +7 -4
- data/lib/chef/knife/subcommand_loader.rb +101 -0
- data/lib/chef/knife/tag_create.rb +31 -0
- data/lib/chef/knife/tag_delete.rb +31 -0
- data/lib/chef/knife/tag_list.rb +29 -0
- data/lib/chef/knife/ui.rb +229 -0
- data/lib/chef/knife/windows_bootstrap.rb +8 -5
- data/lib/chef/log.rb +5 -59
- data/lib/chef/mash.rb +211 -0
- data/lib/chef/mixins.rb +1 -2
- data/lib/chef/nil_argument.rb +3 -0
- data/lib/chef/node.rb +96 -34
- data/lib/chef/platform.rb +27 -0
- data/lib/chef/provider/cookbook_file.rb +21 -20
- data/lib/chef/provider/deploy/revision.rb +3 -0
- data/lib/chef/provider/file.rb +20 -11
- data/lib/chef/provider/git.rb +26 -26
- data/lib/chef/provider/group/aix.rb +70 -0
- data/lib/chef/provider/group/groupadd.rb +7 -4
- data/lib/chef/provider/group/usermod.rb +1 -1
- data/lib/chef/provider/package.rb +28 -28
- data/lib/chef/provider/package/dpkg.rb +1 -1
- data/lib/chef/provider/package/portage.rb +50 -39
- data/lib/chef/provider/package/rubygems.rb +1 -1
- data/lib/chef/provider/package/zypper.rb +3 -20
- data/lib/chef/provider/remote_directory.rb +0 -2
- data/lib/chef/provider/remote_file.rb +2 -3
- data/lib/chef/provider/service/arch.rb +28 -35
- data/lib/chef/provider/service/simple.rb +1 -1
- data/lib/chef/provider/subversion.rb +22 -22
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/recipe.rb +10 -12
- data/lib/chef/resource.rb +49 -42
- data/lib/chef/resource/gem_package.rb +7 -3
- data/lib/chef/resource/git.rb +5 -5
- data/lib/chef/resource/package.rb +7 -7
- data/lib/chef/resource/scm.rb +2 -1
- data/lib/chef/resource/solaris_package.rb +0 -1
- data/lib/chef/resource/yum_package.rb +0 -1
- data/lib/chef/rest.rb +7 -16
- data/lib/chef/rest/rest_request.rb +0 -16
- data/lib/chef/role.rb +67 -13
- data/lib/chef/run_context.rb +37 -21
- data/lib/chef/run_list.rb +30 -15
- data/lib/chef/run_list/run_list_expansion.rb +41 -20
- data/lib/chef/run_list/run_list_item.rb +20 -6
- data/lib/chef/run_list/versioned_recipe_list.rb +68 -0
- data/lib/chef/runner.rb +7 -15
- data/lib/chef/search/query.rb +12 -7
- data/lib/chef/shef.rb +6 -7
- data/lib/chef/shef/shef_session.rb +40 -35
- data/lib/chef/shell_out.rb +22 -201
- data/lib/chef/shell_out/unix.rb +224 -0
- data/lib/chef/shell_out/windows.rb +95 -0
- data/lib/chef/solr_query.rb +187 -0
- data/lib/chef/solr_query/lucene.treetop +145 -0
- data/lib/chef/solr_query/lucene_nodes.rb +285 -0
- data/lib/chef/solr_query/query_transform.rb +65 -0
- data/lib/chef/solr_query/solr_http_request.rb +118 -0
- data/lib/chef/version.rb +4 -2
- data/lib/chef/version_class.rb +70 -0
- data/lib/chef/version_constraint.rb +116 -0
- metadata +68 -37
- data/lib/chef/cookbook/metadata/version.rb +0 -87
- data/lib/chef/knife/bluebox_images_list.rb +0 -54
- data/lib/chef/knife/bluebox_server_create.rb +0 -157
- data/lib/chef/knife/bluebox_server_delete.rb +0 -63
- data/lib/chef/knife/bluebox_server_list.rb +0 -59
- data/lib/chef/knife/ec2_instance_data.rb +0 -46
- data/lib/chef/knife/ec2_server_create.rb +0 -218
- data/lib/chef/knife/ec2_server_delete.rb +0 -87
- data/lib/chef/knife/ec2_server_list.rb +0 -89
- data/lib/chef/knife/rackspace_server_create.rb +0 -184
- data/lib/chef/knife/rackspace_server_delete.rb +0 -57
- data/lib/chef/knife/rackspace_server_list.rb +0 -59
- data/lib/chef/knife/slicehost_images_list.rb +0 -53
- data/lib/chef/knife/slicehost_server_create.rb +0 -103
- data/lib/chef/knife/slicehost_server_delete.rb +0 -61
- data/lib/chef/knife/slicehost_server_list.rb +0 -64
- data/lib/chef/knife/terremark_server_create.rb +0 -152
- data/lib/chef/knife/terremark_server_delete.rb +0 -87
- data/lib/chef/knife/terremark_server_list.rb +0 -77
- data/lib/chef/mixin/find_preferred_file.rb +0 -92
|
@@ -49,7 +49,7 @@ class Chef
|
|
|
49
49
|
@current_resource.running false
|
|
50
50
|
nil
|
|
51
51
|
end
|
|
52
|
-
|
|
52
|
+
elsif
|
|
53
53
|
Chef::Log.debug "#{@new_resource}: falling back to process table inspection"
|
|
54
54
|
if ps_cmd.nil? or ps_cmd.empty?
|
|
55
55
|
raise Chef::Exceptions::Service, "#{@new_resource}: could not determine how to inspect the process table, please set this nodes 'command.ps' attribute"
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
# you may not use this file except in compliance with the License.
|
|
8
8
|
# You may obtain a copy of the License at
|
|
9
|
-
#
|
|
9
|
+
#
|
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
#
|
|
11
|
+
#
|
|
12
12
|
# Unless required by applicable law or agreed to in writing, software
|
|
13
13
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
14
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
@@ -25,9 +25,9 @@ require 'fileutils'
|
|
|
25
25
|
class Chef
|
|
26
26
|
class Provider
|
|
27
27
|
class Subversion < Chef::Provider
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
include Chef::Mixin::Command
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
def load_current_resource
|
|
32
32
|
@current_resource = Chef::Resource::Subversion.new(@new_resource.name)
|
|
33
33
|
|
|
@@ -37,7 +37,7 @@ class Chef
|
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
def action_checkout
|
|
42
42
|
assert_target_directory_valid!
|
|
43
43
|
if target_dir_non_existant_or_empty?
|
|
@@ -47,7 +47,7 @@ class Chef
|
|
|
47
47
|
Chef::Log.info "Taking no action, checkout destination #{@new_resource.destination} already exists or is a non-empty directory"
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
def action_export
|
|
52
52
|
assert_target_directory_valid!
|
|
53
53
|
if target_dir_non_existant_or_empty?
|
|
@@ -57,13 +57,13 @@ class Chef
|
|
|
57
57
|
Chef::Log.info "Taking no action, export destination #{@new_resource.destination} already exists or is a non-empty directory"
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
def action_force_export
|
|
62
62
|
assert_target_directory_valid!
|
|
63
63
|
run_command(run_options(:command => export_command))
|
|
64
64
|
@new_resource.updated_by_last_action(true)
|
|
65
65
|
end
|
|
66
|
-
|
|
66
|
+
|
|
67
67
|
def action_sync
|
|
68
68
|
assert_target_directory_valid!
|
|
69
69
|
if ::File.exist?(::File.join(@new_resource.destination, ".svn"))
|
|
@@ -79,18 +79,18 @@ class Chef
|
|
|
79
79
|
@new_resource.updated_by_last_action(true)
|
|
80
80
|
end
|
|
81
81
|
end
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
def sync_command
|
|
84
84
|
Chef::Log.info "Updating working copy #{@new_resource.destination} to revision #{@new_resource.revision}"
|
|
85
85
|
scm :update, @new_resource.svn_arguments, verbose, authentication, "-r#{revision_int}", @new_resource.destination
|
|
86
86
|
end
|
|
87
|
-
|
|
87
|
+
|
|
88
88
|
def checkout_command
|
|
89
89
|
Chef::Log.info "checking out #{@new_resource.repository} at revision #{@new_resource.revision} to #{@new_resource.destination}"
|
|
90
|
-
scm :checkout, @new_resource.svn_arguments, verbose, authentication,
|
|
90
|
+
scm :checkout, @new_resource.svn_arguments, verbose, authentication,
|
|
91
91
|
"-r#{revision_int}", @new_resource.repository, @new_resource.destination
|
|
92
92
|
end
|
|
93
|
-
|
|
93
|
+
|
|
94
94
|
def export_command
|
|
95
95
|
Chef::Log.info "exporting #{@new_resource.repository} at revision #{@new_resource.revision} to #{@new_resource.destination}"
|
|
96
96
|
args = ["--force"]
|
|
@@ -98,7 +98,7 @@ class Chef
|
|
|
98
98
|
"-r#{revision_int}" << @new_resource.repository << @new_resource.destination
|
|
99
99
|
scm :export, *args
|
|
100
100
|
end
|
|
101
|
-
|
|
101
|
+
|
|
102
102
|
# If the specified revision isn't an integer ("HEAD" for example), look
|
|
103
103
|
# up the revision id by asking the server
|
|
104
104
|
# If the specified revision is an integer, trust it.
|
|
@@ -114,14 +114,14 @@ class Chef
|
|
|
114
114
|
end
|
|
115
115
|
end
|
|
116
116
|
end
|
|
117
|
-
|
|
117
|
+
|
|
118
118
|
alias :revision_slug :revision_int
|
|
119
|
-
|
|
119
|
+
|
|
120
120
|
def find_current_revision
|
|
121
121
|
return nil unless ::File.exist?(::File.join(@new_resource.destination, ".svn"))
|
|
122
122
|
command = scm(:info)
|
|
123
123
|
status, svn_info, error_message = output_of_command(command, run_options(:cwd => cwd))
|
|
124
|
-
|
|
124
|
+
|
|
125
125
|
unless [0,1].include?(status.exitstatus)
|
|
126
126
|
handle_command_failures(status, "STDOUT: #{svn_info}\nSTDERR: #{error_message}")
|
|
127
127
|
end
|
|
@@ -137,17 +137,17 @@ class Chef
|
|
|
137
137
|
run_opts[:group] = @new_resource.group if @new_resource.group
|
|
138
138
|
run_opts
|
|
139
139
|
end
|
|
140
|
-
|
|
140
|
+
|
|
141
141
|
private
|
|
142
|
-
|
|
142
|
+
|
|
143
143
|
def cwd
|
|
144
144
|
@new_resource.destination
|
|
145
145
|
end
|
|
146
|
-
|
|
146
|
+
|
|
147
147
|
def verbose
|
|
148
148
|
"-q"
|
|
149
149
|
end
|
|
150
|
-
|
|
150
|
+
|
|
151
151
|
def extract_revision_info(svn_info)
|
|
152
152
|
begin
|
|
153
153
|
repo_attrs = YAML.load(svn_info)
|
|
@@ -160,7 +160,7 @@ class Chef
|
|
|
160
160
|
Chef::Log.debug "Resolved revision #{@new_resource.revision} to #{rev}"
|
|
161
161
|
rev
|
|
162
162
|
end
|
|
163
|
-
|
|
163
|
+
|
|
164
164
|
# If a username is configured for the SCM, return the command-line
|
|
165
165
|
# switches for that. Note that we don't need to return the password
|
|
166
166
|
# switch, since Capistrano will check for that prompt in the output
|
|
@@ -171,7 +171,7 @@ class Chef
|
|
|
171
171
|
result << "--password #{@new_resource.svn_password} "
|
|
172
172
|
result
|
|
173
173
|
end
|
|
174
|
-
|
|
174
|
+
|
|
175
175
|
def scm(*args)
|
|
176
176
|
['svn', *args].compact.join(" ")
|
|
177
177
|
end
|
data/lib/chef/providers.rb
CHANGED
|
@@ -78,6 +78,7 @@ require 'chef/provider/user/pw'
|
|
|
78
78
|
require 'chef/provider/user/useradd'
|
|
79
79
|
require 'chef/provider/user/windows'
|
|
80
80
|
|
|
81
|
+
require 'chef/provider/group/aix'
|
|
81
82
|
require 'chef/provider/group/dscl'
|
|
82
83
|
require 'chef/provider/group/gpasswd'
|
|
83
84
|
require 'chef/provider/group/groupadd'
|
data/lib/chef/recipe.rb
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
8
|
# you may not use this file except in compliance with the License.
|
|
9
9
|
# You may obtain a copy of the License at
|
|
10
|
-
#
|
|
10
|
+
#
|
|
11
11
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
#
|
|
12
|
+
#
|
|
13
13
|
# Unless required by applicable law or agreed to in writing, software
|
|
14
14
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
15
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
@@ -29,13 +29,13 @@ class Chef
|
|
|
29
29
|
# == Chef::Recipe
|
|
30
30
|
# A Recipe object is the context in which Chef recipes are evaluated.
|
|
31
31
|
class Recipe
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
include Chef::Mixin::FromFile
|
|
34
34
|
include Chef::Mixin::Language
|
|
35
35
|
include Chef::Mixin::LanguageIncludeRecipe
|
|
36
36
|
include Chef::Mixin::RecipeDefinitionDSLCore
|
|
37
37
|
include Chef::Mixin::Deprecation
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
attr_accessor :cookbook_name, :recipe_name, :recipe, :params, :run_context
|
|
40
40
|
|
|
41
41
|
# Parses a potentially fully-qualified recipe name into its
|
|
@@ -63,20 +63,18 @@ class Chef
|
|
|
63
63
|
@params = Hash.new
|
|
64
64
|
@node = deprecated_ivar(run_context.node, :node, :warn)
|
|
65
65
|
end
|
|
66
|
-
|
|
66
|
+
|
|
67
67
|
# Used in DSL mixins
|
|
68
68
|
def node
|
|
69
69
|
run_context.node
|
|
70
70
|
end
|
|
71
|
-
|
|
71
|
+
|
|
72
72
|
# Used by the DSL to look up resources when executing in the context of a
|
|
73
73
|
# recipe.
|
|
74
|
-
#--
|
|
75
|
-
# what does this do? and what is args? TODO 5-14-2010.
|
|
76
74
|
def resources(*args)
|
|
77
75
|
run_context.resource_collection.find(*args)
|
|
78
76
|
end
|
|
79
|
-
|
|
77
|
+
|
|
80
78
|
# Sets a tag, or list of tags, for this node. Syntactic sugar for
|
|
81
79
|
# run_context.node[:tags].
|
|
82
80
|
#
|
|
@@ -97,7 +95,7 @@ class Chef
|
|
|
97
95
|
run_context.node[:tags]
|
|
98
96
|
end
|
|
99
97
|
end
|
|
100
|
-
|
|
98
|
+
|
|
101
99
|
# Returns true if the node is tagged with *all* of the supplied +tags+.
|
|
102
100
|
#
|
|
103
101
|
# === Parameters
|
|
@@ -112,7 +110,7 @@ class Chef
|
|
|
112
110
|
end
|
|
113
111
|
true
|
|
114
112
|
end
|
|
115
|
-
|
|
113
|
+
|
|
116
114
|
# Removes the list of tags from the node.
|
|
117
115
|
#
|
|
118
116
|
# === Parameters
|
|
@@ -125,6 +123,6 @@ class Chef
|
|
|
125
123
|
run_context.node[:tags].delete(tag)
|
|
126
124
|
end
|
|
127
125
|
end
|
|
128
|
-
|
|
126
|
+
|
|
129
127
|
end
|
|
130
128
|
end
|
data/lib/chef/resource.rb
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
8
|
# you may not use this file except in compliance with the License.
|
|
9
9
|
# You may obtain a copy of the License at
|
|
10
|
-
#
|
|
10
|
+
#
|
|
11
11
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
#
|
|
12
|
+
#
|
|
13
13
|
# Unless required by applicable law or agreed to in writing, software
|
|
14
14
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
15
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
@@ -77,7 +77,7 @@ F
|
|
|
77
77
|
include Chef::Mixin::Language
|
|
78
78
|
include Chef::Mixin::ConvertToClassName
|
|
79
79
|
include Chef::Mixin::Deprecation
|
|
80
|
-
|
|
80
|
+
|
|
81
81
|
attr_accessor :params
|
|
82
82
|
attr_accessor :provider
|
|
83
83
|
attr_accessor :allowed_actions
|
|
@@ -97,7 +97,7 @@ F
|
|
|
97
97
|
# Struct with a #resource and #action member
|
|
98
98
|
attr_reader :immediate_notifications
|
|
99
99
|
attr_reader :delayed_notifications
|
|
100
|
-
|
|
100
|
+
|
|
101
101
|
def initialize(name, run_context=nil)
|
|
102
102
|
@name = name
|
|
103
103
|
@run_context = run_context
|
|
@@ -144,7 +144,7 @@ F
|
|
|
144
144
|
raise NoMethodError, "undefined method `#{method_symbol.to_s}' for #{self.class.to_s}"
|
|
145
145
|
end
|
|
146
146
|
end
|
|
147
|
-
|
|
147
|
+
|
|
148
148
|
def load_prior_resource
|
|
149
149
|
begin
|
|
150
150
|
prior_resource = run_context.resource_collection.lookup(self.to_s)
|
|
@@ -159,7 +159,7 @@ F
|
|
|
159
159
|
true
|
|
160
160
|
end
|
|
161
161
|
end
|
|
162
|
-
|
|
162
|
+
|
|
163
163
|
def supports(args={})
|
|
164
164
|
if args.any?
|
|
165
165
|
@supports = args
|
|
@@ -167,7 +167,7 @@ F
|
|
|
167
167
|
@supports
|
|
168
168
|
end
|
|
169
169
|
end
|
|
170
|
-
|
|
170
|
+
|
|
171
171
|
def provider(arg=nil)
|
|
172
172
|
klass = if arg.kind_of?(String) || arg.kind_of?(Symbol)
|
|
173
173
|
lookup_provider_constant(arg)
|
|
@@ -180,7 +180,7 @@ F
|
|
|
180
180
|
:kind_of => [ Class ]
|
|
181
181
|
)
|
|
182
182
|
end
|
|
183
|
-
|
|
183
|
+
|
|
184
184
|
def action(arg=nil)
|
|
185
185
|
if arg
|
|
186
186
|
action_list = arg.kind_of?(Array) ? arg : [ arg ]
|
|
@@ -200,21 +200,21 @@ F
|
|
|
200
200
|
@action
|
|
201
201
|
end
|
|
202
202
|
end
|
|
203
|
-
|
|
203
|
+
|
|
204
204
|
def name(name=nil)
|
|
205
205
|
set_if_args(@name, name) do
|
|
206
206
|
raise ArgumentError, "name must be a string!" unless name.kind_of?(String)
|
|
207
207
|
@name = name
|
|
208
208
|
end
|
|
209
209
|
end
|
|
210
|
-
|
|
210
|
+
|
|
211
211
|
def noop(tf=nil)
|
|
212
|
-
set_if_args(@noop, tf) do
|
|
212
|
+
set_if_args(@noop, tf) do
|
|
213
213
|
raise ArgumentError, "noop must be true or false!" unless tf == true || tf == false
|
|
214
214
|
@noop = tf
|
|
215
215
|
end
|
|
216
216
|
end
|
|
217
|
-
|
|
217
|
+
|
|
218
218
|
def ignore_failure(arg=nil)
|
|
219
219
|
set_or_return(
|
|
220
220
|
:ignore_failure,
|
|
@@ -222,7 +222,7 @@ F
|
|
|
222
222
|
:kind_of => [ TrueClass, FalseClass ]
|
|
223
223
|
)
|
|
224
224
|
end
|
|
225
|
-
|
|
225
|
+
|
|
226
226
|
def epic_fail(arg=nil)
|
|
227
227
|
ignore_failure(arg)
|
|
228
228
|
end
|
|
@@ -243,7 +243,7 @@ F
|
|
|
243
243
|
Chef::Log.debug "adding notification from resource #{self} to `#{resource.inspect}' => `#{notification.inspect}'"
|
|
244
244
|
add_notification(action, resource, timing)
|
|
245
245
|
end
|
|
246
|
-
end
|
|
246
|
+
end
|
|
247
247
|
end
|
|
248
248
|
rescue NoMethodError
|
|
249
249
|
Chef::Log.fatal("Error processing notifies(#{args.inspect}) on #{self}")
|
|
@@ -286,7 +286,7 @@ F
|
|
|
286
286
|
def resources(*args)
|
|
287
287
|
run_context.resource_collection.find(*args)
|
|
288
288
|
end
|
|
289
|
-
|
|
289
|
+
|
|
290
290
|
def subscribes(action, resources, timing=:delayed)
|
|
291
291
|
resources = [resources].flatten
|
|
292
292
|
resources.each do |resource|
|
|
@@ -302,7 +302,7 @@ F
|
|
|
302
302
|
return *args
|
|
303
303
|
end
|
|
304
304
|
end
|
|
305
|
-
|
|
305
|
+
|
|
306
306
|
def to_s
|
|
307
307
|
"#{@resource_name}[#{@name}]"
|
|
308
308
|
end
|
|
@@ -318,13 +318,20 @@ F
|
|
|
318
318
|
end
|
|
319
319
|
text << "end\n"
|
|
320
320
|
end
|
|
321
|
-
|
|
322
|
-
|
|
321
|
+
|
|
322
|
+
def inspect
|
|
323
|
+
ivars = instance_variables.map { |ivar| ivar.to_sym } - HIDDEN_IVARS
|
|
324
|
+
ivars.inject("<#{to_s}") do |str, ivar|
|
|
325
|
+
str << " #{ivar}: #{instance_variable_get(ivar).inspect}"
|
|
326
|
+
end << ">"
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
# Serialize this object as a hash
|
|
323
330
|
def to_json(*a)
|
|
324
331
|
instance_vars = Hash.new
|
|
325
332
|
self.instance_variables.each do |iv|
|
|
326
333
|
unless iv == "@run_context"
|
|
327
|
-
instance_vars[iv] = self.instance_variable_get(iv)
|
|
334
|
+
instance_vars[iv] = self.instance_variable_get(iv)
|
|
328
335
|
end
|
|
329
336
|
end
|
|
330
337
|
results = {
|
|
@@ -333,7 +340,7 @@ F
|
|
|
333
340
|
}
|
|
334
341
|
results.to_json(*a)
|
|
335
342
|
end
|
|
336
|
-
|
|
343
|
+
|
|
337
344
|
def to_hash
|
|
338
345
|
instance_vars = Hash.new
|
|
339
346
|
self.instance_variables.each do |iv|
|
|
@@ -342,7 +349,7 @@ F
|
|
|
342
349
|
end
|
|
343
350
|
instance_vars
|
|
344
351
|
end
|
|
345
|
-
|
|
352
|
+
|
|
346
353
|
def only_if(arg=nil, args = {}, &blk)
|
|
347
354
|
if Kernel.block_given?
|
|
348
355
|
@only_if = blk
|
|
@@ -353,7 +360,7 @@ F
|
|
|
353
360
|
end
|
|
354
361
|
@only_if
|
|
355
362
|
end
|
|
356
|
-
|
|
363
|
+
|
|
357
364
|
def not_if(arg=nil, args = {}, &blk)
|
|
358
365
|
if Kernel.block_given?
|
|
359
366
|
@not_if = blk
|
|
@@ -364,7 +371,7 @@ F
|
|
|
364
371
|
end
|
|
365
372
|
@not_if
|
|
366
373
|
end
|
|
367
|
-
|
|
374
|
+
|
|
368
375
|
def run_action(action)
|
|
369
376
|
# ensure that we don't leave @updated_by_last_action set to true
|
|
370
377
|
# on accident
|
|
@@ -403,13 +410,13 @@ F
|
|
|
403
410
|
def updated_by_last_action?
|
|
404
411
|
@updated_by_last_action
|
|
405
412
|
end
|
|
406
|
-
|
|
413
|
+
|
|
407
414
|
def updated?
|
|
408
415
|
updated
|
|
409
416
|
end
|
|
410
417
|
|
|
411
418
|
class << self
|
|
412
|
-
|
|
419
|
+
|
|
413
420
|
def json_create(o)
|
|
414
421
|
resource = self.new(o["instance_vars"]["@name"])
|
|
415
422
|
o["instance_vars"].each do |k,v|
|
|
@@ -417,9 +424,9 @@ F
|
|
|
417
424
|
end
|
|
418
425
|
resource
|
|
419
426
|
end
|
|
420
|
-
|
|
427
|
+
|
|
421
428
|
include Chef::Mixin::ConvertToClassName
|
|
422
|
-
|
|
429
|
+
|
|
423
430
|
def attribute(attr_name, validation_opts={})
|
|
424
431
|
# This atrocity is the only way to support 1.8 and 1.9 at the same time
|
|
425
432
|
# When you're ready to drop 1.8 support, do this:
|
|
@@ -431,12 +438,12 @@ F
|
|
|
431
438
|
end
|
|
432
439
|
SHIM
|
|
433
440
|
class_eval(shim_method)
|
|
434
|
-
|
|
441
|
+
|
|
435
442
|
define_method("_set_or_return_#{attr_name.to_s}".to_sym) do |arg|
|
|
436
443
|
set_or_return(attr_name.to_sym, arg, validation_opts)
|
|
437
444
|
end
|
|
438
445
|
end
|
|
439
|
-
|
|
446
|
+
|
|
440
447
|
def build_from_file(cookbook_name, filename)
|
|
441
448
|
rname = filename_to_qualified_string(cookbook_name, filename)
|
|
442
449
|
|
|
@@ -444,33 +451,33 @@ F
|
|
|
444
451
|
class_name = convert_to_class_name(rname)
|
|
445
452
|
overriding = Chef::Resource.const_defined?(class_name)
|
|
446
453
|
Chef::Log.info("#{class_name} light-weight resource already initialized -- overriding!") if overriding
|
|
447
|
-
|
|
454
|
+
|
|
448
455
|
new_resource_class = Class.new self do |cls|
|
|
449
|
-
|
|
456
|
+
|
|
450
457
|
# default initialize method that ensures that when initialize is finally
|
|
451
458
|
# wrapped (see below), super is called in the event that the resource
|
|
452
459
|
# definer does not implement initialize
|
|
453
460
|
def initialize(name, run_context)
|
|
454
461
|
super(name, run_context)
|
|
455
462
|
end
|
|
456
|
-
|
|
463
|
+
|
|
457
464
|
@actions_to_create = []
|
|
458
|
-
|
|
465
|
+
|
|
459
466
|
class << cls
|
|
460
467
|
include Chef::Mixin::FromFile
|
|
461
|
-
|
|
468
|
+
|
|
462
469
|
def actions_to_create
|
|
463
470
|
@actions_to_create
|
|
464
471
|
end
|
|
465
|
-
|
|
472
|
+
|
|
466
473
|
define_method(:actions) do |*action_names|
|
|
467
474
|
actions_to_create.push(*action_names)
|
|
468
475
|
end
|
|
469
476
|
end
|
|
470
|
-
|
|
477
|
+
|
|
471
478
|
# load resource definition from file
|
|
472
479
|
cls.class_from_file(filename)
|
|
473
|
-
|
|
480
|
+
|
|
474
481
|
# create a new constructor that wraps the old one and adds the actions
|
|
475
482
|
# specified in the DSL
|
|
476
483
|
old_init = instance_method(:initialize)
|
|
@@ -482,16 +489,16 @@ F
|
|
|
482
489
|
allowed_actions.push(self.class.actions_to_create).flatten!
|
|
483
490
|
end
|
|
484
491
|
end
|
|
485
|
-
|
|
492
|
+
|
|
486
493
|
# register new class as a Chef::Resource
|
|
487
494
|
class_name = convert_to_class_name(rname)
|
|
488
495
|
Chef::Resource.const_set(class_name, new_resource_class)
|
|
489
496
|
Chef::Log.debug("Loaded contents of #{filename} into a resource named #{rname} defined in Chef::Resource::#{class_name}")
|
|
490
|
-
|
|
497
|
+
|
|
491
498
|
new_resource_class
|
|
492
499
|
end
|
|
493
|
-
|
|
494
|
-
# Resources that want providers namespaced somewhere other than
|
|
500
|
+
|
|
501
|
+
# Resources that want providers namespaced somewhere other than
|
|
495
502
|
# Chef::Provider can set the namespace with +provider_base+
|
|
496
503
|
# Ex:
|
|
497
504
|
# class MyResource < Chef::Resource
|
|
@@ -502,7 +509,7 @@ F
|
|
|
502
509
|
@provider_base ||= arg
|
|
503
510
|
@provider_base ||= Chef::Provider
|
|
504
511
|
end
|
|
505
|
-
|
|
512
|
+
|
|
506
513
|
end
|
|
507
514
|
|
|
508
515
|
private
|