chef 12.5.1-universal-mingw32 → 12.6.0-universal-mingw32
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.
- checksums.yaml +4 -4
- data/Gemfile +6 -1
- data/README.md +6 -4
- data/Rakefile +1 -4
- data/chef-windows.gemspec +21 -0
- data/chef.gemspec +58 -0
- data/lib/chef/api_client/registration.rb +9 -4
- data/lib/chef/application.rb +3 -84
- data/lib/chef/application/apply.rb +9 -2
- data/lib/chef/application/client.rb +8 -3
- data/lib/chef/application/solo.rb +7 -1
- data/lib/chef/application/windows_service.rb +21 -6
- data/lib/chef/application/windows_service_manager.rb +2 -3
- data/lib/chef/audit/runner.rb +1 -0
- data/lib/chef/chef_class.rb +1 -11
- data/lib/chef/chef_fs/chef_fs_data_store.rb +181 -2
- data/lib/chef/chef_fs/file_system/cookbook_subdir.rb +5 -0
- data/lib/chef/chef_fs/file_system/file_system_entry.rb +11 -7
- data/lib/chef/client.rb +28 -1
- data/lib/chef/cookbook/cookbook_collection.rb +14 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
- data/lib/chef/cookbook/metadata.rb +115 -9
- data/lib/chef/cookbook/remote_file_vendor.rb +1 -1
- data/lib/chef/cookbook_version.rb +6 -2
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/data_bag_item.rb +1 -1
- data/lib/chef/digester.rb +5 -1
- data/lib/chef/dsl/chef_provisioning.rb +57 -0
- data/lib/chef/dsl/cheffish.rb +64 -0
- data/lib/chef/dsl/declare_resource.rb +108 -0
- data/lib/chef/dsl/platform_introspection.rb +3 -3
- data/lib/chef/dsl/recipe.rb +3 -73
- data/lib/chef/dsl/resources.rb +27 -1
- data/lib/chef/event_dispatch/base.rb +3 -0
- data/lib/chef/event_dispatch/dispatcher.rb +5 -0
- data/lib/chef/event_dispatch/events_output_stream.rb +8 -0
- data/lib/chef/exceptions.rb +21 -1
- data/lib/chef/file_access_control/unix.rb +12 -12
- data/lib/chef/file_content_management/deploy/cp.rb +2 -2
- data/lib/chef/file_content_management/deploy/mv_unix.rb +4 -4
- data/lib/chef/file_content_management/deploy/mv_windows.rb +1 -1
- data/lib/chef/formatters/base.rb +7 -0
- data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +2 -2
- data/lib/chef/formatters/indentable_output_stream.rb +5 -0
- data/lib/chef/http.rb +19 -3
- data/lib/chef/http/decompressor.rb +2 -2
- data/lib/chef/json_compat.rb +1 -0
- data/lib/chef/knife.rb +16 -2
- data/lib/chef/knife/bootstrap.rb +55 -10
- data/lib/chef/knife/cookbook_site_install.rb +5 -1
- data/lib/chef/knife/core/bootstrap_context.rb +2 -1
- data/lib/chef/knife/core/node_presenter.rb +1 -1
- data/lib/chef/knife/ssh.rb +30 -16
- data/lib/chef/knife/ssl_check.rb +4 -2
- data/lib/chef/knife/ssl_fetch.rb +3 -2
- data/lib/chef/knife/status.rb +14 -1
- data/lib/chef/log.rb +14 -0
- data/lib/chef/mixin/get_source_from_package.rb +7 -2
- data/lib/chef/mixin/properties.rb +302 -0
- data/lib/chef/mixin/proxified_socket.rb +38 -0
- data/lib/chef/mixin/subclass_directive.rb +37 -0
- data/lib/chef/node.rb +13 -5
- data/lib/chef/platform/query_helpers.rb +14 -3
- data/lib/chef/platform/service_helpers.rb +20 -38
- data/lib/chef/policy_builder/expand_node_object.rb +3 -0
- data/lib/chef/policy_builder/policyfile.rb +1 -0
- data/lib/chef/property.rb +51 -12
- data/lib/chef/provider.rb +40 -35
- data/lib/chef/provider/deploy.rb +1 -1
- data/lib/chef/provider/dsc_resource.rb +54 -20
- data/lib/chef/provider/execute.rb +25 -4
- data/lib/chef/provider/group.rb +1 -1
- data/lib/chef/provider/lwrp_base.rb +1 -0
- data/lib/chef/provider/package.rb +76 -30
- data/lib/chef/provider/package/dpkg.rb +152 -69
- data/lib/chef/provider/package/openbsd.rb +6 -8
- data/lib/chef/provider/package/solaris.rb +2 -0
- data/lib/chef/provider/package/windows.rb +95 -14
- data/lib/chef/provider/package/windows/exe.rb +129 -0
- data/lib/chef/provider/package/windows/msi.rb +37 -13
- data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +89 -0
- data/lib/chef/provider/package/yum.rb +13 -3
- data/lib/chef/provider/powershell_script.rb +3 -0
- data/lib/chef/provider/remote_file/cache_control_data.rb +37 -4
- data/lib/chef/provider/remote_file/http.rb +1 -1
- data/lib/chef/provider/script.rb +1 -0
- data/lib/chef/provider/service.rb +13 -10
- data/lib/chef/provider/service/solaris.rb +43 -17
- data/lib/chef/provider/service/upstart.rb +3 -3
- data/lib/chef/provider/user.rb +1 -1
- data/lib/chef/provider/user/dscl.rb +111 -100
- data/lib/chef/provider/user/windows.rb +5 -3
- data/lib/chef/recipe.rb +3 -5
- data/lib/chef/resource.rb +77 -320
- data/lib/chef/resource/action_class.rb +4 -0
- data/lib/chef/resource/dpkg_package.rb +4 -3
- data/lib/chef/resource/dsc_resource.rb +40 -2
- data/lib/chef/resource/execute.rb +9 -1
- data/lib/chef/resource/ksh.rb +32 -0
- data/lib/chef/resource/lwrp_base.rb +6 -10
- data/lib/chef/resource/package.rb +8 -9
- data/lib/chef/resource/registry_key.rb +1 -1
- data/lib/chef/resource/resource_notification.rb +14 -1
- data/lib/chef/resource/script.rb +1 -1
- data/lib/chef/resource/windows_package.rb +1 -1
- data/lib/chef/resource_builder.rb +14 -7
- data/lib/chef/resource_reporter.rb +6 -0
- data/lib/chef/resources.rb +1 -7
- data/lib/chef/rest.rb +1 -1
- data/lib/chef/run_context.rb +45 -2
- data/lib/chef/run_list/run_list_expansion.rb +47 -0
- data/lib/chef/runner.rb +25 -0
- data/lib/chef/search/query.rb +16 -2
- data/lib/chef/util/diff.rb +2 -2
- data/lib/chef/util/powershell/ps_credential.rb +2 -3
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api/file.rb +51 -1
- data/lib/chef/win32/file.rb +5 -0
- data/lib/chef/win32/file/version_info.rb +93 -0
- data/lib/chef/win32/mutex.rb +1 -1
- data/spec/data/apt/chef-integration-test2-1.0/debian/changelog +5 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2.debhelper.log +45 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2.substvars +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2/DEBIAN/conffiles +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2/DEBIAN/control +10 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2/DEBIAN/md5sums +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/compat +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/conffiles +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/control +13 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/copyright +34 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/files +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/rules +13 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/source/format +1 -0
- data/spec/data/apt/chef-integration-test2_1.0-1.debian.tar.gz +0 -0
- data/spec/data/apt/chef-integration-test2_1.0-1.dsc +18 -0
- data/spec/data/apt/chef-integration-test2_1.0-1_amd64.build +91 -0
- data/spec/data/apt/chef-integration-test2_1.0-1_amd64.changes +31 -0
- data/spec/data/apt/chef-integration-test2_1.0-1_amd64.deb +0 -0
- data/spec/data/apt/chef-integration-test2_1.0.orig.tar.gz +0 -0
- data/spec/functional/application_spec.rb +1 -1
- data/spec/functional/audit/runner_spec.rb +4 -0
- data/spec/functional/knife/ssh_spec.rb +5 -5
- data/spec/functional/notifications_spec.rb +74 -4
- data/spec/functional/resource/aix_service_spec.rb +2 -2
- data/spec/functional/resource/dpkg_package_spec.rb +339 -0
- data/spec/functional/resource/ifconfig_spec.rb +3 -1
- data/spec/functional/resource/mount_spec.rb +5 -2
- data/spec/functional/resource/package_spec.rb +1 -1
- data/spec/functional/resource/user/windows_spec.rb +8 -0
- data/spec/functional/resource/windows_package_spec.rb +177 -0
- data/spec/functional/win32/version_info_spec.rb +50 -0
- data/spec/integration/client/client_spec.rb +80 -0
- data/spec/integration/knife/download_spec.rb +9 -0
- data/spec/integration/knife/upload_spec.rb +28 -1
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +93 -23
- data/spec/integration/recipes/resource_action_spec.rb +211 -116
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +72 -0
- data/spec/integration/solo/solo_spec.rb +34 -0
- data/spec/spec_helper.rb +11 -1
- data/spec/support/platform_helpers.rb +8 -0
- data/spec/support/shared/integration/integration_helper.rb +6 -0
- data/spec/support/shared/unit/execute_resource.rb +5 -0
- data/spec/support/shared/unit/platform_introspector.rb +7 -0
- data/spec/tiny_server.rb +6 -2
- data/spec/unit/api_client/registration_spec.rb +5 -4
- data/spec/unit/application_spec.rb +1 -181
- data/spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb +34 -0
- data/spec/unit/cookbook/metadata_spec.rb +122 -2
- data/spec/unit/http_spec.rb +102 -0
- data/spec/unit/knife/bootstrap_spec.rb +55 -13
- data/spec/unit/knife/core/bootstrap_context_spec.rb +10 -3
- data/spec/unit/knife/ssl_check_spec.rb +7 -3
- data/spec/unit/knife/ssl_fetch_spec.rb +2 -2
- data/spec/unit/knife/status_spec.rb +13 -13
- data/spec/unit/knife_spec.rb +26 -2
- data/spec/unit/lwrp_spec.rb +1 -1
- data/spec/unit/mixin/properties_spec.rb +97 -0
- data/spec/unit/mixin/proxified_socket_spec.rb +94 -0
- data/spec/unit/mixin/subclass_directive_spec.rb +45 -0
- data/spec/unit/node_spec.rb +9 -1
- data/spec/unit/policy_builder/policyfile_spec.rb +2 -0
- data/spec/unit/property/validation_spec.rb +14 -12
- data/spec/unit/property_spec.rb +56 -0
- data/spec/unit/provider/deploy_spec.rb +1 -1
- data/spec/unit/provider/dsc_resource_spec.rb +63 -24
- data/spec/unit/provider/execute_spec.rb +95 -28
- data/spec/unit/provider/package/dpkg_spec.rb +185 -96
- data/spec/unit/provider/package/windows/exe_spec.rb +251 -0
- data/spec/unit/provider/package/windows/msi_spec.rb +94 -10
- data/spec/unit/provider/package/windows_spec.rb +227 -26
- data/spec/unit/provider/package/yum_spec.rb +6 -0
- data/spec/unit/provider/package_spec.rb +495 -366
- data/spec/unit/provider/remote_file/cache_control_data_spec.rb +62 -36
- data/spec/unit/provider/script_spec.rb +2 -2
- data/spec/unit/provider/service/solaris_smf_service_spec.rb +110 -39
- data/spec/unit/provider/service/upstart_service_spec.rb +19 -0
- data/spec/unit/provider/user/dscl_spec.rb +14 -0
- data/spec/unit/provider/user/windows_spec.rb +2 -2
- data/spec/unit/provider/user_spec.rb +9 -0
- data/spec/unit/provider_resolver_spec.rb +6 -30
- data/spec/unit/recipe_spec.rb +46 -20
- data/spec/unit/resource/chef_gem_spec.rb +1 -1
- data/spec/unit/resource/dsc_resource_spec.rb +14 -3
- data/spec/unit/resource/ksh_spec.rb +40 -0
- data/spec/unit/resource/registry_key_spec.rb +2 -2
- data/spec/unit/resource/resource_notification_spec.rb +44 -45
- data/spec/unit/resource_reporter_spec.rb +7 -0
- data/spec/unit/resource_spec.rb +268 -253
- data/spec/unit/rest_spec.rb +2 -2
- data/spec/unit/run_list/run_list_expansion_spec.rb +18 -3
- data/spec/unit/search/query_spec.rb +19 -1
- data/spec/unit/util/powershell/ps_credential_spec.rb +8 -1
- data/spec/unit/windows_service_spec.rb +83 -38
- data/tasks/external_tests.rb +19 -9
- data/tasks/rspec.rb +1 -1
- metadata +70 -21
- data/spec/support/pedant/Gemfile +0 -3
- data/spec/support/pedant/pedant_config.rb +0 -129
- data/spec/support/pedant/run_pedant.rb +0 -63
- data/spec/support/pedant/stickywicket.pem +0 -27
- data/spec/unit/provider/package_spec.rbe +0 -0
@@ -69,7 +69,7 @@ class Chef
|
|
69
69
|
Chef::FileCache.move_to(raw_file.path, cache_filename)
|
70
70
|
else
|
71
71
|
Chef::Log.debug("Not fetching #{cache_filename}, as the cache is up to date.")
|
72
|
-
Chef::Log.debug("
|
72
|
+
Chef::Log.debug("Current checksum: #{current_checksum}; manifest checksum: #{found_manifest_record['checksum']})")
|
73
73
|
end
|
74
74
|
|
75
75
|
full_path_cache_filename = Chef::FileCache.load(cache_filename, false)
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# Author:: Tim Hinderliter (<tim@opscode.com>)
|
5
5
|
# Author:: Seth Falcon (<seth@opscode.com>)
|
6
6
|
# Author:: Daniel DeLeo (<dan@opscode.com>)
|
7
|
-
# Copyright:: Copyright 2008-
|
7
|
+
# Copyright:: Copyright 2008-2015 Chef Software, Inc.
|
8
8
|
# License:: Apache License, Version 2.0
|
9
9
|
#
|
10
10
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -450,7 +450,11 @@ class Chef
|
|
450
450
|
end
|
451
451
|
relative_search_path.map {|relative_path| File.join(segment.to_s, relative_path)}
|
452
452
|
else
|
453
|
-
|
453
|
+
if segment.to_sym == :root_files
|
454
|
+
[path]
|
455
|
+
else
|
456
|
+
[File.join(segment, path)]
|
457
|
+
end
|
454
458
|
end
|
455
459
|
end
|
456
460
|
private :preferences_for_path
|
data/lib/chef/data_bag.rb
CHANGED
data/lib/chef/data_bag_item.rb
CHANGED
@@ -170,7 +170,7 @@ class Chef
|
|
170
170
|
r = chef_server_rest
|
171
171
|
begin
|
172
172
|
if Chef::Config[:why_run]
|
173
|
-
Chef::Log.warn("In
|
173
|
+
Chef::Log.warn("In why-run mode, so NOT performing data bag item save.")
|
174
174
|
else
|
175
175
|
r.put_rest("data/#{data_bag}/#{item_id}", self)
|
176
176
|
end
|
data/lib/chef/digester.rb
CHANGED
@@ -38,7 +38,11 @@ class Chef
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def generate_checksum(file)
|
41
|
-
|
41
|
+
if file.is_a?(StringIO)
|
42
|
+
checksum_io(file, OpenSSL::Digest::SHA256.new)
|
43
|
+
else
|
44
|
+
checksum_file(file, OpenSSL::Digest::SHA256.new)
|
45
|
+
end
|
42
46
|
end
|
43
47
|
|
44
48
|
def self.generate_md5_checksum_for_file(*args)
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#
|
2
|
+
# Author:: John Keiser (<jkeiser@chef.io>)
|
3
|
+
# Copyright:: Copyright (c) 2015 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
|
+
class Chef
|
20
|
+
module DSL
|
21
|
+
# Lazy activation for the chef-provisioning gem. Specifically, we set up methods for
|
22
|
+
# each resource and DSL method in chef-provisioning which, when invoked, will
|
23
|
+
# require 'chef-provisioning' (which will define the actual method) and then call the
|
24
|
+
# method chef-provisioning defined.
|
25
|
+
module ChefProvisioning
|
26
|
+
%w(
|
27
|
+
add_machine_options
|
28
|
+
current_image_options
|
29
|
+
current_machine_options
|
30
|
+
load_balancer
|
31
|
+
machine_batch
|
32
|
+
machine_execute
|
33
|
+
machine_file
|
34
|
+
machine_image
|
35
|
+
machine
|
36
|
+
with_driver
|
37
|
+
with_image_options
|
38
|
+
with_machine_options
|
39
|
+
).each do |method_name|
|
40
|
+
eval(<<-EOM, binding, __FILE__, __LINE__+1)
|
41
|
+
def #{method_name}(*args, &block)
|
42
|
+
Chef::DSL::ChefProvisioning.load_chef_provisioning
|
43
|
+
self.#{method_name}(*args, &block)
|
44
|
+
end
|
45
|
+
EOM
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.load_chef_provisioning
|
49
|
+
# Remove all chef-provisioning methods; they will be added back in by chef-provisioning
|
50
|
+
public_instance_methods(false).each do |method_name|
|
51
|
+
remove_method(method_name)
|
52
|
+
end
|
53
|
+
require 'chef/provisioning'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#
|
2
|
+
# Author:: John Keiser (<jkeiser@chef.io>)
|
3
|
+
# Copyright:: Copyright (c) 2015 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
|
+
class Chef
|
20
|
+
module DSL
|
21
|
+
# Lazy activation for the cheffish gem. Specifically, we set up methods for
|
22
|
+
# each resource and DSL method in cheffish which, when invoked, will
|
23
|
+
# require 'cheffish' (which will define the actual method) and then call the
|
24
|
+
# method cheffish defined.
|
25
|
+
module Cheffish
|
26
|
+
%w(
|
27
|
+
chef_acl
|
28
|
+
chef_client
|
29
|
+
chef_container
|
30
|
+
chef_data_bag
|
31
|
+
chef_environment
|
32
|
+
chef_group
|
33
|
+
chef_mirror
|
34
|
+
chef_node
|
35
|
+
chef_organization
|
36
|
+
chef_role
|
37
|
+
chef_user
|
38
|
+
private_key
|
39
|
+
public_key
|
40
|
+
with_chef_data_bag
|
41
|
+
with_chef_environment
|
42
|
+
with_chef_data_bag_item_encryption
|
43
|
+
with_chef_server
|
44
|
+
with_chef_local_server
|
45
|
+
get_private_key
|
46
|
+
).each do |method_name|
|
47
|
+
eval(<<-EOM, binding, __FILE__, __LINE__+1)
|
48
|
+
def #{method_name}(*args, &block)
|
49
|
+
Chef::DSL::Cheffish.load_cheffish
|
50
|
+
self.#{method_name}(*args, &block)
|
51
|
+
end
|
52
|
+
EOM
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.load_cheffish
|
56
|
+
# Remove all cheffish methods; they will be added back in by cheffish
|
57
|
+
public_instance_methods(false).each do |method_name|
|
58
|
+
remove_method(method_name)
|
59
|
+
end
|
60
|
+
require 'cheffish'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
#--
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Author:: Christopher Walters (<cw@opscode.com>)
|
4
|
+
# Copyright:: Copyright (c) 2008, 2009-2015 Chef Software, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'chef/exceptions'
|
21
|
+
|
22
|
+
class Chef
|
23
|
+
module DSL
|
24
|
+
module DeclareResource
|
25
|
+
|
26
|
+
#
|
27
|
+
# Instantiates a resource (via #build_resource), then adds it to the
|
28
|
+
# resource collection. Note that resource classes are looked up directly,
|
29
|
+
# so this will create the resource you intended even if the method name
|
30
|
+
# corresponding to that resource has been overridden.
|
31
|
+
#
|
32
|
+
# @param type [Symbol] The type of resource (e.g. `:file` or `:package`)
|
33
|
+
# @param name [String] The name of the resource (e.g. '/x/y.txt' or 'apache2')
|
34
|
+
# @param created_at [String] The caller of the resource. Use `caller[0]`
|
35
|
+
# to get the caller of your function. Defaults to the caller of this
|
36
|
+
# function.
|
37
|
+
# @param resource_attrs_block A block that lets you set attributes of the
|
38
|
+
# resource (it is instance_eval'd on the resource instance).
|
39
|
+
#
|
40
|
+
# @return [Chef::Resource] The new resource.
|
41
|
+
#
|
42
|
+
# @example
|
43
|
+
# declare_resource(:file, '/x/y.txy', caller[0]) do
|
44
|
+
# action :delete
|
45
|
+
# end
|
46
|
+
# # Equivalent to
|
47
|
+
# file '/x/y.txt' do
|
48
|
+
# action :delete
|
49
|
+
# end
|
50
|
+
#
|
51
|
+
def declare_resource(type, name, created_at=nil, run_context: self.run_context, create_if_missing: false, &resource_attrs_block)
|
52
|
+
created_at ||= caller[0]
|
53
|
+
|
54
|
+
if create_if_missing
|
55
|
+
begin
|
56
|
+
resource = run_context.resource_collection.find(type => name)
|
57
|
+
return resource
|
58
|
+
rescue Chef::Exceptions::ResourceNotFound
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
resource = build_resource(type, name, created_at, &resource_attrs_block)
|
63
|
+
|
64
|
+
run_context.resource_collection.insert(resource, resource_type: type, instance_name: name)
|
65
|
+
resource
|
66
|
+
end
|
67
|
+
|
68
|
+
#
|
69
|
+
# Instantiate a resource of the given +type+ with the given +name+ and
|
70
|
+
# attributes as given in the +resource_attrs_block+.
|
71
|
+
#
|
72
|
+
# The resource is NOT added to the resource collection.
|
73
|
+
#
|
74
|
+
# @param type [Symbol] The type of resource (e.g. `:file` or `:package`)
|
75
|
+
# @param name [String] The name of the resource (e.g. '/x/y.txt' or 'apache2')
|
76
|
+
# @param created_at [String] The caller of the resource. Use `caller[0]`
|
77
|
+
# to get the caller of your function. Defaults to the caller of this
|
78
|
+
# function.
|
79
|
+
# @param resource_attrs_block A block that lets you set attributes of the
|
80
|
+
# resource (it is instance_eval'd on the resource instance).
|
81
|
+
#
|
82
|
+
# @return [Chef::Resource] The new resource.
|
83
|
+
#
|
84
|
+
# @example
|
85
|
+
# build_resource(:file, '/x/y.txy', caller[0]) do
|
86
|
+
# action :delete
|
87
|
+
# end
|
88
|
+
#
|
89
|
+
def build_resource(type, name, created_at=nil, run_context: self.run_context, &resource_attrs_block)
|
90
|
+
created_at ||= caller[0]
|
91
|
+
Thread.exclusive do
|
92
|
+
require 'chef/resource_builder' unless defined?(Chef::ResourceBuilder)
|
93
|
+
end
|
94
|
+
|
95
|
+
Chef::ResourceBuilder.new(
|
96
|
+
type: type,
|
97
|
+
name: name,
|
98
|
+
created_at: created_at,
|
99
|
+
params: @params,
|
100
|
+
run_context: run_context,
|
101
|
+
cookbook_name: cookbook_name,
|
102
|
+
recipe_name: recipe_name,
|
103
|
+
enclosing_provider: self.is_a?(Chef::Provider) ? self : nil
|
104
|
+
).build(&resource_attrs_block)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -50,7 +50,7 @@ class Chef
|
|
50
50
|
|
51
51
|
def value_for_node(node)
|
52
52
|
platform, version = node[:platform].to_s, node[:platform_version].to_s
|
53
|
-
# Check if we match a version constraint via Chef::VersionConstraint and Chef::Version::Platform
|
53
|
+
# Check if we match a version constraint via Chef::VersionConstraint::Platform and Chef::Version::Platform
|
54
54
|
matched_value = match_versions(node)
|
55
55
|
if @values.key?(platform) && @values[platform].key?(version)
|
56
56
|
@values[platform][version]
|
@@ -76,11 +76,11 @@ class Chef
|
|
76
76
|
keys = @values[platform].keys
|
77
77
|
keys.each do |k|
|
78
78
|
begin
|
79
|
-
if Chef::VersionConstraint.new(k).include?(node_version)
|
79
|
+
if Chef::VersionConstraint::Platform.new(k).include?(node_version)
|
80
80
|
key_matches << k
|
81
81
|
end
|
82
82
|
rescue Chef::Exceptions::InvalidVersionConstraint => e
|
83
|
-
Chef::Log.debug "Caught InvalidVersionConstraint. This means that a key in value_for_platform cannot be interpreted as a Chef::VersionConstraint."
|
83
|
+
Chef::Log.debug "Caught InvalidVersionConstraint. This means that a key in value_for_platform cannot be interpreted as a Chef::VersionConstraint::Platform."
|
84
84
|
Chef::Log.debug(e)
|
85
85
|
end
|
86
86
|
end
|
data/lib/chef/dsl/recipe.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#--
|
2
2
|
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
3
|
# Author:: Christopher Walters (<cw@opscode.com>)
|
4
|
-
# Copyright:: Copyright (c) 2008, 2009
|
4
|
+
# Copyright:: Copyright (c) 2008, 2009-2015 Chef Software, Inc.
|
5
5
|
# License:: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -17,12 +17,12 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
require 'chef/mixin/convert_to_class_name'
|
21
20
|
require 'chef/exceptions'
|
22
21
|
require 'chef/mixin/shell_out'
|
23
22
|
require 'chef/mixin/powershell_out'
|
24
23
|
require 'chef/dsl/resources'
|
25
24
|
require 'chef/dsl/definitions'
|
25
|
+
require 'chef/dsl/declare_resource'
|
26
26
|
|
27
27
|
class Chef
|
28
28
|
module DSL
|
@@ -37,76 +37,7 @@ class Chef
|
|
37
37
|
|
38
38
|
include Chef::DSL::Resources
|
39
39
|
include Chef::DSL::Definitions
|
40
|
-
|
41
|
-
#
|
42
|
-
# Instantiates a resource (via #build_resource), then adds it to the
|
43
|
-
# resource collection. Note that resource classes are looked up directly,
|
44
|
-
# so this will create the resource you intended even if the method name
|
45
|
-
# corresponding to that resource has been overridden.
|
46
|
-
#
|
47
|
-
# @param type [Symbol] The type of resource (e.g. `:file` or `:package`)
|
48
|
-
# @param name [String] The name of the resource (e.g. '/x/y.txt' or 'apache2')
|
49
|
-
# @param created_at [String] The caller of the resource. Use `caller[0]`
|
50
|
-
# to get the caller of your function. Defaults to the caller of this
|
51
|
-
# function.
|
52
|
-
# @param resource_attrs_block A block that lets you set attributes of the
|
53
|
-
# resource (it is instance_eval'd on the resource instance).
|
54
|
-
#
|
55
|
-
# @return [Chef::Resource] The new resource.
|
56
|
-
#
|
57
|
-
# @example
|
58
|
-
# declare_resource(:file, '/x/y.txy', caller[0]) do
|
59
|
-
# action :delete
|
60
|
-
# end
|
61
|
-
# # Equivalent to
|
62
|
-
# file '/x/y.txt' do
|
63
|
-
# action :delete
|
64
|
-
# end
|
65
|
-
#
|
66
|
-
def declare_resource(type, name, created_at=nil, &resource_attrs_block)
|
67
|
-
created_at ||= caller[0]
|
68
|
-
|
69
|
-
resource = build_resource(type, name, created_at, &resource_attrs_block)
|
70
|
-
|
71
|
-
run_context.resource_collection.insert(resource, resource_type: type, instance_name: name)
|
72
|
-
resource
|
73
|
-
end
|
74
|
-
|
75
|
-
#
|
76
|
-
# Instantiate a resource of the given +type+ with the given +name+ and
|
77
|
-
# attributes as given in the +resource_attrs_block+.
|
78
|
-
#
|
79
|
-
# The resource is NOT added to the resource collection.
|
80
|
-
#
|
81
|
-
# @param type [Symbol] The type of resource (e.g. `:file` or `:package`)
|
82
|
-
# @param name [String] The name of the resource (e.g. '/x/y.txt' or 'apache2')
|
83
|
-
# @param created_at [String] The caller of the resource. Use `caller[0]`
|
84
|
-
# to get the caller of your function. Defaults to the caller of this
|
85
|
-
# function.
|
86
|
-
# @param resource_attrs_block A block that lets you set attributes of the
|
87
|
-
# resource (it is instance_eval'd on the resource instance).
|
88
|
-
#
|
89
|
-
# @return [Chef::Resource] The new resource.
|
90
|
-
#
|
91
|
-
# @example
|
92
|
-
# build_resource(:file, '/x/y.txy', caller[0]) do
|
93
|
-
# action :delete
|
94
|
-
# end
|
95
|
-
#
|
96
|
-
def build_resource(type, name, created_at=nil, &resource_attrs_block)
|
97
|
-
created_at ||= caller[0]
|
98
|
-
|
99
|
-
Chef::ResourceBuilder.new(
|
100
|
-
type: type,
|
101
|
-
name: name,
|
102
|
-
created_at: created_at,
|
103
|
-
params: @params,
|
104
|
-
run_context: run_context,
|
105
|
-
cookbook_name: cookbook_name,
|
106
|
-
recipe_name: recipe_name,
|
107
|
-
enclosing_provider: self.is_a?(Chef::Provider) ? self : nil
|
108
|
-
).build(&resource_attrs_block)
|
109
|
-
end
|
40
|
+
include Chef::DSL::DeclareResource
|
110
41
|
|
111
42
|
def resource_class_for(snake_case_name)
|
112
43
|
Chef::Resource.resource_for_node(snake_case_name, run_context.node)
|
@@ -196,7 +127,6 @@ class Chef
|
|
196
127
|
end
|
197
128
|
|
198
129
|
# Avoid circular references for things that are only used in instance methods
|
199
|
-
require 'chef/resource_builder'
|
200
130
|
require 'chef/resource'
|
201
131
|
|
202
132
|
# **DEPRECATED**
|
data/lib/chef/dsl/resources.rb
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
#
|
2
|
+
# Author:: John Keiser <jkeiser@chef.io>
|
3
|
+
# Copyright:: Copyright (c) 2015 Chef Software, 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
|
+
require 'chef/dsl/cheffish'
|
19
|
+
require 'chef/dsl/chef_provisioning'
|
20
|
+
|
1
21
|
class Chef
|
2
22
|
module DSL
|
3
23
|
#
|
@@ -7,6 +27,11 @@ class Chef
|
|
7
27
|
#
|
8
28
|
# @api private
|
9
29
|
module Resources
|
30
|
+
# Include the lazy loaders for cheffish and chef-provisioning, so that the
|
31
|
+
# resource DSL is there but the gems aren't activated yet.
|
32
|
+
include Chef::DSL::Cheffish
|
33
|
+
include Chef::DSL::ChefProvisioning
|
34
|
+
|
10
35
|
def self.add_resource_dsl(dsl_name)
|
11
36
|
begin
|
12
37
|
module_eval(<<-EOM, __FILE__, __LINE__+1)
|
@@ -24,7 +49,8 @@ class Chef
|
|
24
49
|
end
|
25
50
|
end
|
26
51
|
def self.remove_resource_dsl(dsl_name)
|
27
|
-
|
52
|
+
remove_method(dsl_name)
|
53
|
+
rescue NameError
|
28
54
|
end
|
29
55
|
end
|
30
56
|
end
|