chef 12.5.1 → 12.6.0
Sign up to get free protection for your applications and to get access to all the features.
- 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 +64 -15
- 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
@@ -21,6 +21,10 @@ require 'chef/exceptions'
|
|
21
21
|
class Chef
|
22
22
|
class Resource
|
23
23
|
module ActionClass
|
24
|
+
def to_s
|
25
|
+
"#{new_resource || "<no resource>"} action #{action ? action.inspect : "<no action>"}"
|
26
|
+
end
|
27
|
+
|
24
28
|
#
|
25
29
|
# If load_current_value! is defined on the resource, use that.
|
26
30
|
#
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
-
# Copyright:: Copyright (c) 2008
|
3
|
+
# Copyright:: Copyright (c) 2008-2015 Chef Software, Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -17,14 +17,15 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require 'chef/resource/package'
|
20
|
-
require 'chef/provider/package/dpkg'
|
21
20
|
|
22
21
|
class Chef
|
23
22
|
class Resource
|
24
23
|
class DpkgPackage < Chef::Resource::Package
|
25
|
-
|
26
24
|
provides :dpkg_package, os: "linux"
|
27
25
|
|
26
|
+
resource_name :dpkg_package
|
27
|
+
|
28
|
+
property :source, [String, Array, nil]
|
28
29
|
end
|
29
30
|
end
|
30
31
|
end
|
@@ -20,17 +20,36 @@ require 'chef/dsl/powershell'
|
|
20
20
|
class Chef
|
21
21
|
class Resource
|
22
22
|
class DscResource < Chef::Resource
|
23
|
-
|
24
23
|
provides :dsc_resource, os: "windows"
|
25
24
|
|
25
|
+
# This class will check if the object responds to
|
26
|
+
# to_text. If it does, it will call that as opposed
|
27
|
+
# to inspect. This is useful for properties that hold
|
28
|
+
# objects such as PsCredential, where we do not want
|
29
|
+
# to dump the actual ivars
|
30
|
+
class ToTextHash < Hash
|
31
|
+
def to_text
|
32
|
+
descriptions = self.map do |(property, obj)|
|
33
|
+
obj_text = if obj.respond_to?(:to_text)
|
34
|
+
obj.to_text
|
35
|
+
else
|
36
|
+
obj.inspect
|
37
|
+
end
|
38
|
+
"#{property}=>#{obj_text}"
|
39
|
+
end
|
40
|
+
"{#{descriptions.join(', ')}}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
26
44
|
include Chef::DSL::Powershell
|
27
45
|
|
28
46
|
default_action :run
|
29
47
|
|
30
48
|
def initialize(name, run_context)
|
31
49
|
super
|
32
|
-
@properties =
|
50
|
+
@properties = ToTextHash.new
|
33
51
|
@resource = nil
|
52
|
+
@reboot_action = :nothing
|
34
53
|
end
|
35
54
|
|
36
55
|
def resource(value=nil)
|
@@ -68,6 +87,25 @@ class Chef
|
|
68
87
|
end
|
69
88
|
end
|
70
89
|
|
90
|
+
# This property takes the action message for the reboot resource
|
91
|
+
# If the set method of the DSC resource indicate that a reboot
|
92
|
+
# is necessary, reboot_action provides the mechanism for a reboot to
|
93
|
+
# be requested.
|
94
|
+
def reboot_action(value=nil)
|
95
|
+
if value
|
96
|
+
@reboot_action = value
|
97
|
+
else
|
98
|
+
@reboot_action
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def timeout(arg=nil)
|
103
|
+
set_or_return(
|
104
|
+
:timeout,
|
105
|
+
arg,
|
106
|
+
:kind_of => [ Integer ]
|
107
|
+
)
|
108
|
+
end
|
71
109
|
private
|
72
110
|
|
73
111
|
def value_of(value)
|
@@ -49,6 +49,7 @@ class Chef
|
|
49
49
|
@umask = nil
|
50
50
|
@default_guard_interpreter = :execute
|
51
51
|
@is_guard_interpreter = false
|
52
|
+
@live_stream = false
|
52
53
|
end
|
53
54
|
|
54
55
|
def umask(arg=nil)
|
@@ -101,8 +102,15 @@ class Chef
|
|
101
102
|
)
|
102
103
|
end
|
103
104
|
|
105
|
+
def live_stream(arg=nil)
|
106
|
+
set_or_return(
|
107
|
+
:live_stream,
|
108
|
+
arg,
|
109
|
+
:kind_of => [ TrueClass, FalseClass ])
|
110
|
+
end
|
111
|
+
|
104
112
|
def path(arg=nil)
|
105
|
-
Chef::Log.warn "'path' attribute of 'execute' is not used by any provider in Chef 11
|
113
|
+
Chef::Log.warn "The 'path' attribute of 'execute' is not used by any provider in Chef 11 or Chef 12. Use 'environment' attribute to configure 'PATH'. This attribute will be removed in Chef 13."
|
106
114
|
|
107
115
|
set_or_return(
|
108
116
|
:path,
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Nolan Davidson (<nolan.davidson@gmail.com>)
|
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
|
+
|
19
|
+
require 'chef/resource/script'
|
20
|
+
|
21
|
+
class Chef
|
22
|
+
class Resource
|
23
|
+
class Ksh < Chef::Resource::Script
|
24
|
+
|
25
|
+
def initialize(name, run_context=nil)
|
26
|
+
super
|
27
|
+
@interpreter = "ksh"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
#
|
2
|
-
# Author:: Adam Jacob (<adam@
|
3
|
-
# Author:: Christopher Walters (<cw@
|
4
|
-
# Author:: Daniel DeLeo (<dan@
|
5
|
-
# Copyright:: Copyright (c) 2008-
|
2
|
+
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
+
# Author:: Christopher Walters (<cw@chef.io>)
|
4
|
+
# Author:: Daniel DeLeo (<dan@chef.io>)
|
5
|
+
# Copyright:: Copyright (c) 2008-2015 Chef Software, Inc.
|
6
6
|
# License:: Apache License, Version 2.0
|
7
7
|
#
|
8
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -45,7 +45,7 @@ class Chef
|
|
45
45
|
|
46
46
|
def build_from_file(cookbook_name, filename, run_context)
|
47
47
|
if LWRPBase.loaded_lwrps[filename]
|
48
|
-
Chef::Log.info("
|
48
|
+
Chef::Log.info("Custom resource #{filename} from cookbook #{cookbook_name} has already been loaded! Skipping the reload.")
|
49
49
|
return loaded_lwrps[filename]
|
50
50
|
end
|
51
51
|
|
@@ -60,7 +60,7 @@ class Chef
|
|
60
60
|
# Make a useful string for the class (rather than <Class:312894723894>)
|
61
61
|
resource_class.instance_eval do
|
62
62
|
define_singleton_method(:to_s) do
|
63
|
-
"
|
63
|
+
"Custom resource #{resource_name} from cookbook #{cookbook_name}"
|
64
64
|
end
|
65
65
|
define_singleton_method(:inspect) { to_s }
|
66
66
|
end
|
@@ -102,10 +102,6 @@ class Chef
|
|
102
102
|
run_context ? run_context.node : nil
|
103
103
|
end
|
104
104
|
|
105
|
-
def lazy(&block)
|
106
|
-
DelayedEvaluator.new(&block)
|
107
|
-
end
|
108
|
-
|
109
105
|
protected
|
110
106
|
|
111
107
|
def loaded_lwrps
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
3
|
# Author:: Tyler Cloke (<tyler@opscode.com>)
|
4
|
-
# Copyright:: Copyright (c) 2008
|
4
|
+
# Copyright:: Copyright (c) 2008-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");
|
@@ -31,14 +31,13 @@ class Chef
|
|
31
31
|
|
32
32
|
def initialize(name, run_context=nil)
|
33
33
|
super
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
@timeout = nil
|
34
|
+
options nil
|
35
|
+
package_name name
|
36
|
+
response_file nil
|
37
|
+
response_file_variables Hash.new
|
38
|
+
source nil
|
39
|
+
version nil
|
40
|
+
timeout nil
|
42
41
|
end
|
43
42
|
|
44
43
|
def package_name(arg=nil)
|
@@ -125,7 +125,7 @@ class Chef
|
|
125
125
|
scrubbed_value = value.dup
|
126
126
|
if needs_checksum?(scrubbed_value)
|
127
127
|
data_io = StringIO.new(scrubbed_value[:data].to_s)
|
128
|
-
scrubbed_value[:data] = Chef::Digester.instance.
|
128
|
+
scrubbed_value[:data] = Chef::Digester.instance.generate_checksum(data_io)
|
129
129
|
end
|
130
130
|
scrubbed << scrubbed_value
|
131
131
|
end
|
@@ -20,7 +20,15 @@ require 'chef/resource'
|
|
20
20
|
|
21
21
|
class Chef
|
22
22
|
class Resource
|
23
|
-
class Notification
|
23
|
+
class Notification
|
24
|
+
|
25
|
+
attr_accessor :resource, :action, :notifying_resource
|
26
|
+
|
27
|
+
def initialize(resource, action, notifying_resource)
|
28
|
+
@resource = resource
|
29
|
+
@action = action
|
30
|
+
@notifying_resource = notifying_resource
|
31
|
+
end
|
24
32
|
|
25
33
|
def duplicates?(other_notification)
|
26
34
|
unless other_notification.respond_to?(:resource) && other_notification.respond_to?(:action)
|
@@ -104,6 +112,11 @@ is defined near #{resource.source_line}
|
|
104
112
|
raise err
|
105
113
|
end
|
106
114
|
|
115
|
+
def ==(other)
|
116
|
+
return false unless other.is_a?(self.class)
|
117
|
+
other.resource == resource && other.action == action && other.notifying_resource == notifying_resource
|
118
|
+
end
|
119
|
+
|
107
120
|
end
|
108
121
|
end
|
109
122
|
end
|
data/lib/chef/resource/script.rb
CHANGED
@@ -40,7 +40,7 @@ class Chef
|
|
40
40
|
unless arg.nil?
|
41
41
|
# Chef-13: change this to raise if the user is trying to set a value here
|
42
42
|
Chef::Log.warn "Specifying command attribute on a script resource is a coding error, use the 'code' attribute, or the execute resource"
|
43
|
-
Chef::Log.warn "This attribute is deprecated and must be fixed or this code will fail on Chef
|
43
|
+
Chef::Log.warn "This attribute is deprecated and must be fixed or this code will fail on Chef 13"
|
44
44
|
end
|
45
45
|
super
|
46
46
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Lamont Granquist (<lamont@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2015
|
3
|
+
# Copyright:: Copyright (c) 2015-2015 Chef Software, Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -18,10 +18,6 @@
|
|
18
18
|
|
19
19
|
# NOTE: this was extracted from the Recipe DSL mixin, relevant specs are in spec/unit/recipe_spec.rb
|
20
20
|
|
21
|
-
require 'chef/exceptions'
|
22
|
-
require 'chef/resource'
|
23
|
-
require 'chef/log'
|
24
|
-
|
25
21
|
class Chef
|
26
22
|
class ResourceBuilder
|
27
23
|
attr_reader :type
|
@@ -74,7 +70,14 @@ class Chef
|
|
74
70
|
resource.params = params
|
75
71
|
|
76
72
|
# Evaluate resource attribute DSL
|
77
|
-
|
73
|
+
if block_given?
|
74
|
+
resource.resource_initializing = true
|
75
|
+
begin
|
76
|
+
resource.instance_eval(&block)
|
77
|
+
ensure
|
78
|
+
resource.resource_initializing = false
|
79
|
+
end
|
80
|
+
end
|
78
81
|
|
79
82
|
# emit a cloned resource warning if it is warranted
|
80
83
|
if prior_resource
|
@@ -134,7 +137,7 @@ class Chef
|
|
134
137
|
@prior_resource ||=
|
135
138
|
begin
|
136
139
|
key = "#{type}[#{name}]"
|
137
|
-
|
140
|
+
run_context.resource_collection.lookup(key)
|
138
141
|
rescue Chef::Exceptions::ResourceNotFound
|
139
142
|
nil
|
140
143
|
end
|
@@ -142,3 +145,7 @@ class Chef
|
|
142
145
|
|
143
146
|
end
|
144
147
|
end
|
148
|
+
|
149
|
+
require 'chef/exceptions'
|
150
|
+
require 'chef/resource'
|
151
|
+
require 'chef/log'
|
@@ -112,6 +112,7 @@ class Chef
|
|
112
112
|
@exception = nil
|
113
113
|
@rest_client = rest_client
|
114
114
|
@error_descriptions = {}
|
115
|
+
@expanded_run_list = {}
|
115
116
|
end
|
116
117
|
|
117
118
|
def run_started(run_status)
|
@@ -217,6 +218,10 @@ class Chef
|
|
217
218
|
end
|
218
219
|
end
|
219
220
|
|
221
|
+
def run_list_expanded(run_list_expansion)
|
222
|
+
@expanded_run_list = run_list_expansion
|
223
|
+
end
|
224
|
+
|
220
225
|
def post_reporting_data
|
221
226
|
if reporting_enabled?
|
222
227
|
run_data = prepare_run_data
|
@@ -271,6 +276,7 @@ class Chef
|
|
271
276
|
run_data["data"] = {}
|
272
277
|
run_data["start_time"] = start_time.to_s
|
273
278
|
run_data["end_time"] = end_time.to_s
|
279
|
+
run_data["expanded_run_list"] = Chef::JSONCompat.to_json(@expanded_run_list)
|
274
280
|
|
275
281
|
if exception
|
276
282
|
exception_data = {}
|
data/lib/chef/resources.rb
CHANGED
@@ -43,6 +43,7 @@ require 'chef/resource/group'
|
|
43
43
|
require 'chef/resource/http_request'
|
44
44
|
require 'chef/resource/homebrew_package'
|
45
45
|
require 'chef/resource/ifconfig'
|
46
|
+
require 'chef/resource/ksh'
|
46
47
|
require 'chef/resource/link'
|
47
48
|
require 'chef/resource/log'
|
48
49
|
require 'chef/resource/macports_package'
|
@@ -81,10 +82,3 @@ require 'chef/resource/yum_package'
|
|
81
82
|
require 'chef/resource/lwrp_base'
|
82
83
|
require 'chef/resource/bff_package'
|
83
84
|
require 'chef/resource/zypper_package'
|
84
|
-
|
85
|
-
begin
|
86
|
-
# Optional resources chef_node, chef_client, machine, machine_image, etc.
|
87
|
-
require 'cheffish'
|
88
|
-
require 'chef/provisioning'
|
89
|
-
rescue LoadError
|
90
|
-
end
|
data/lib/chef/rest.rb
CHANGED
@@ -166,7 +166,7 @@ class Chef
|
|
166
166
|
def retriable_http_request(method, url, req_body, headers)
|
167
167
|
rest_request = Chef::HTTP::HTTPRequest.new(method, url, req_body, headers)
|
168
168
|
|
169
|
-
Chef::Log.debug("Sending HTTP
|
169
|
+
Chef::Log.debug("Sending HTTP request via #{method} to #{url.host}:#{url.port}#{rest_request.path}")
|
170
170
|
|
171
171
|
retrying_http_errors(url) do
|
172
172
|
yield rest_request
|
data/lib/chef/run_context.rb
CHANGED
@@ -103,6 +103,15 @@ class Chef
|
|
103
103
|
# Notification handling
|
104
104
|
#
|
105
105
|
|
106
|
+
#
|
107
|
+
# A Hash containing the before notifications triggered by resources
|
108
|
+
# during the converge phase of the chef run.
|
109
|
+
#
|
110
|
+
# @return [Hash[String, Array[Chef::Resource::Notification]]] A hash from
|
111
|
+
# <notifying resource name> => <list of notifications it sent>
|
112
|
+
#
|
113
|
+
attr_reader :before_notification_collection
|
114
|
+
|
106
115
|
#
|
107
116
|
# A Hash containing the immediate notifications triggered by resources
|
108
117
|
# during the converge phase of the chef run.
|
@@ -164,10 +173,25 @@ class Chef
|
|
164
173
|
def initialize_child_state
|
165
174
|
@audits = {}
|
166
175
|
@resource_collection = Chef::ResourceCollection.new
|
176
|
+
@before_notification_collection = Hash.new {|h,k| h[k] = []}
|
167
177
|
@immediate_notification_collection = Hash.new {|h,k| h[k] = []}
|
168
178
|
@delayed_notification_collection = Hash.new {|h,k| h[k] = []}
|
169
179
|
end
|
170
180
|
|
181
|
+
#
|
182
|
+
# Adds an before notification to the +before_notification_collection+.
|
183
|
+
#
|
184
|
+
# @param [Chef::Resource::Notification] The notification to add.
|
185
|
+
#
|
186
|
+
def notifies_before(notification)
|
187
|
+
nr = notification.notifying_resource
|
188
|
+
if nr.instance_of?(Chef::Resource)
|
189
|
+
before_notification_collection[nr.name] << notification
|
190
|
+
else
|
191
|
+
before_notification_collection[nr.declared_key] << notification
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
171
195
|
#
|
172
196
|
# Adds an immediate notification to the +immediate_notification_collection+.
|
173
197
|
#
|
@@ -196,6 +220,22 @@ class Chef
|
|
196
220
|
end
|
197
221
|
end
|
198
222
|
|
223
|
+
#
|
224
|
+
# Get the list of before notifications sent by the given resource.
|
225
|
+
#
|
226
|
+
# TODO seriously, this is actually wrong. resource.name is not unique,
|
227
|
+
# you need the type as well.
|
228
|
+
#
|
229
|
+
# @return [Array[Notification]]
|
230
|
+
#
|
231
|
+
def before_notifications(resource)
|
232
|
+
if resource.instance_of?(Chef::Resource)
|
233
|
+
return before_notification_collection[resource.name]
|
234
|
+
else
|
235
|
+
return before_notification_collection[resource.declared_key]
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
199
239
|
#
|
200
240
|
# Get the list of immediate notifications sent by the given resource.
|
201
241
|
#
|
@@ -268,7 +308,7 @@ class Chef
|
|
268
308
|
# @see DSL::IncludeRecipe#load_recipe
|
269
309
|
#
|
270
310
|
def load_recipe(recipe_name, current_cookbook: nil)
|
271
|
-
Chef::Log.debug("Loading
|
311
|
+
Chef::Log.debug("Loading recipe #{recipe_name} via include_recipe")
|
272
312
|
|
273
313
|
cookbook_name, recipe_short_name = Chef::Recipe.parse_recipe_name(recipe_name, current_cookbook: current_cookbook)
|
274
314
|
|
@@ -308,7 +348,7 @@ ERROR_MESSAGE
|
|
308
348
|
raise Chef::Exceptions::RecipeNotFound, "could not find recipe file #{recipe_file}"
|
309
349
|
end
|
310
350
|
|
311
|
-
Chef::Log.debug("Loading
|
351
|
+
Chef::Log.debug("Loading recipe file #{recipe_file}")
|
312
352
|
recipe = Chef::Recipe.new('@recipe_files', recipe_file, self)
|
313
353
|
recipe.from_file(recipe_file)
|
314
354
|
recipe
|
@@ -608,10 +648,13 @@ ERROR_MESSAGE
|
|
608
648
|
immediate_notification_collection
|
609
649
|
immediate_notification_collection=
|
610
650
|
immediate_notifications
|
651
|
+
before_notification_collection
|
652
|
+
before_notifications
|
611
653
|
include_recipe
|
612
654
|
initialize_child_state
|
613
655
|
load_recipe
|
614
656
|
load_recipe_file
|
657
|
+
notifies_before
|
615
658
|
notifies_immediately
|
616
659
|
notifies_delayed
|
617
660
|
parent_run_context
|