chef 12.0.0.alpha.0-x86-mingw32 → 12.0.0.alpha.1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +3 -5
- data/lib/chef/api_client.rb +1 -1
- data/lib/chef/application.rb +16 -8
- data/lib/chef/chef_fs/chef_fs_data_store.rb +1 -1
- data/lib/chef/chef_fs/command_line.rb +1 -1
- data/lib/chef/chef_fs/file_system.rb +1 -1
- data/lib/chef/chef_fs/file_system/acl_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +3 -3
- data/lib/chef/chef_fs/file_system/cookbook_file.rb +2 -2
- data/lib/chef/chef_fs/file_system/rest_list_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/rest_list_entry.rb +4 -4
- data/lib/chef/config.rb +6 -5
- data/lib/chef/config_fetcher.rb +1 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +126 -43
- data/lib/chef/cookbook/metadata.rb +102 -53
- data/lib/chef/cookbook/syntax_check.rb +1 -1
- data/lib/chef/cookbook_loader.rb +62 -14
- data/lib/chef/cookbook_site_streaming_uploader.rb +12 -1
- data/lib/chef/cookbook_version.rb +13 -4
- data/lib/chef/data_bag.rb +28 -15
- data/lib/chef/data_bag_item.rb +5 -7
- data/lib/chef/digester.rb +5 -9
- data/lib/chef/dsl/recipe.rb +14 -0
- data/lib/chef/encrypted_data_bag_item.rb +1 -0
- data/lib/chef/encrypted_data_bag_item/assertions.rb +57 -0
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +52 -28
- data/lib/chef/encrypted_data_bag_item/encrypted_data_bag_item_assertions.rb +37 -0
- data/lib/chef/encrypted_data_bag_item/encryption_failure.rb +22 -0
- data/lib/chef/encrypted_data_bag_item/encryptor.rb +79 -8
- data/lib/chef/environment.rb +1 -3
- data/lib/chef/exceptions.rb +18 -3
- data/lib/chef/formatters/base.rb +7 -0
- data/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb +1 -1
- data/lib/chef/handler/json_file.rb +0 -1
- data/lib/chef/http/json_output.rb +1 -1
- data/lib/chef/json_compat.rb +24 -6
- data/lib/chef/knife/bootstrap.rb +2 -2
- data/lib/chef/knife/client_delete.rb +1 -1
- data/lib/chef/knife/cookbook_site_download.rb +1 -1
- data/lib/chef/knife/cookbook_site_list.rb +1 -1
- data/lib/chef/knife/cookbook_site_search.rb +1 -1
- data/lib/chef/knife/cookbook_site_share.rb +2 -2
- data/lib/chef/knife/cookbook_site_show.rb +3 -3
- data/lib/chef/knife/cookbook_site_unshare.rb +1 -1
- data/lib/chef/knife/core/node_editor.rb +2 -3
- data/lib/chef/knife/core/ui.rb +2 -2
- data/lib/chef/knife/deps.rb +2 -3
- data/lib/chef/mixin/shell_out.rb +1 -1
- data/lib/chef/mixin/windows_architecture_helper.rb +1 -0
- data/lib/chef/node.rb +1 -2
- data/lib/chef/platform/provider_mapping.rb +33 -6
- data/lib/chef/provider.rb +0 -2
- data/lib/chef/provider/cookbook_file/content.rb +1 -1
- data/lib/chef/provider/cron.rb +11 -0
- data/lib/chef/provider/deploy.rb +3 -2
- data/lib/chef/provider/deploy/revision.rb +2 -2
- data/lib/chef/provider/env.rb +1 -1
- data/lib/chef/provider/env/windows.rb +5 -9
- data/lib/chef/provider/file.rb +84 -33
- data/lib/chef/provider/git.rb +2 -1
- data/lib/chef/provider/group/aix.rb +17 -2
- data/lib/chef/provider/group/dscl.rb +27 -9
- data/lib/chef/provider/group/pw.rb +8 -1
- data/lib/chef/provider/http_request.rb +4 -4
- data/lib/chef/provider/log.rb +4 -14
- data/lib/chef/provider/mount/mount.rb +2 -2
- data/lib/chef/provider/package/ips.rb +17 -23
- data/lib/chef/provider/package/paludis.rb +2 -2
- data/lib/chef/provider/package/rpm.rb +2 -2
- data/lib/chef/provider/package/rubygems.rb +2 -0
- data/lib/chef/provider/package/yum.rb +2 -0
- data/lib/chef/provider/package/zypper.rb +1 -1
- data/lib/chef/provider/remote_file/cache_control_data.rb +2 -2
- data/lib/chef/provider/service/windows.rb +87 -21
- data/lib/chef/provider/user/aix.rb +95 -0
- data/lib/chef/provider/user/dscl.rb +544 -156
- data/lib/chef/provider/user/useradd.rb +1 -0
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/resource.rb +4 -3
- data/lib/chef/resource/freebsd_package.rb +10 -2
- data/lib/chef/resource/paludis_package.rb +1 -0
- data/lib/chef/resource/scm.rb +10 -0
- data/lib/chef/resource/user.rb +27 -0
- data/lib/chef/resource/windows_service.rb +53 -0
- data/lib/chef/resource_collection.rb +23 -12
- data/lib/chef/resource_reporter.rb +10 -10
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/role.rb +3 -3
- data/lib/chef/run_list.rb +6 -3
- data/lib/chef/user.rb +1 -1
- data/lib/chef/util/diff.rb +1 -2
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version_constraint.rb +4 -4
- data/spec/data/cookbooks/angrybash/metadata.rb +2 -0
- data/spec/data/cookbooks/apache2/metadata.rb +2 -0
- data/spec/data/cookbooks/borken/metadata.rb +2 -0
- data/spec/data/cookbooks/ignorken/metadata.rb +2 -0
- data/spec/data/cookbooks/java/metadata.rb +2 -0
- data/spec/data/cookbooks/name-mismatch-versionnumber/README.md +4 -0
- data/spec/data/cookbooks/name-mismatch-versionnumber/metadata.rb +8 -0
- data/spec/data/cookbooks/name-mismatch-versionnumber/recipes/default.rb +8 -0
- data/spec/data/cookbooks/openldap/files/default/remotedir/not_a_template.erb +2 -0
- data/spec/data/cookbooks/preseed/metadata.rb +2 -0
- data/spec/data/incomplete-metadata-chef-repo/incomplete-metadata/README.md +4 -0
- data/spec/data/incomplete-metadata-chef-repo/incomplete-metadata/metadata.rb +13 -0
- data/spec/data/incomplete-metadata-chef-repo/incomplete-metadata/recipes/default.rb +8 -0
- data/spec/data/invalid-metadata-chef-repo/invalid-metadata/README.md +4 -0
- data/spec/data/invalid-metadata-chef-repo/invalid-metadata/metadata.rb +10 -0
- data/spec/data/invalid-metadata-chef-repo/invalid-metadata/recipes/default.rb +8 -0
- data/spec/data/mac_users/10.7-8.plist.xml +559 -0
- data/spec/data/mac_users/10.7-8.shadow.xml +11 -0
- data/spec/data/mac_users/10.7.plist.xml +559 -0
- data/spec/data/mac_users/10.7.shadow.xml +11 -0
- data/spec/data/mac_users/10.8.plist.xml +559 -0
- data/spec/data/mac_users/10.8.shadow.xml +21 -0
- data/spec/data/mac_users/10.9.plist.xml +560 -0
- data/spec/data/mac_users/10.9.shadow.xml +21 -0
- data/spec/data/object_loader/environments/test.json +2 -0
- data/spec/data/object_loader/environments/test_json_class.json +2 -0
- data/spec/data/object_loader/nodes/test.json +2 -0
- data/spec/data/object_loader/nodes/test_json_class.json +2 -0
- data/spec/data/object_loader/roles/test.json +2 -0
- data/spec/data/object_loader/roles/test_json_class.json +2 -0
- data/spec/functional/resource/bff_spec.rb +1 -1
- data/spec/functional/resource/cron_spec.rb +20 -1
- data/spec/functional/resource/env_spec.rb +137 -0
- data/spec/functional/resource/group_spec.rb +7 -5
- data/spec/functional/resource/remote_file_spec.rb +12 -1
- data/spec/functional/resource/user/dscl_spec.rb +198 -0
- data/spec/functional/resource/{user_spec.rb → user/useradd_spec.rb} +175 -37
- data/spec/integration/client/client_spec.rb +6 -4
- data/spec/integration/client/ipv6_spec.rb +16 -14
- data/spec/integration/knife/chef_fs_data_store_spec.rb +57 -46
- data/spec/integration/knife/chef_repo_path_spec.rb +105 -78
- data/spec/integration/knife/chef_repository_file_system_spec.rb +100 -84
- data/spec/integration/knife/chefignore_spec.rb +76 -46
- data/spec/integration/knife/common_options_spec.rb +16 -21
- data/spec/integration/knife/cookbook_api_ipv6_spec.rb +3 -3
- data/spec/integration/knife/delete_spec.rb +66 -46
- data/spec/integration/knife/deps_spec.rb +145 -94
- data/spec/integration/knife/diff_spec.rb +176 -110
- data/spec/integration/knife/download_spec.rb +229 -133
- data/spec/integration/knife/list_spec.rb +62 -54
- data/spec/integration/knife/raw_spec.rb +24 -9
- data/spec/integration/knife/redirection_spec.rb +2 -2
- data/spec/integration/knife/serve_spec.rb +2 -2
- data/spec/integration/knife/show_spec.rb +32 -26
- data/spec/integration/knife/upload_spec.rb +308 -165
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +10 -8
- data/spec/integration/solo/solo_spec.rb +22 -11
- data/spec/spec_helper.rb +3 -0
- data/spec/support/lib/chef/resource/zen_follower.rb +46 -0
- data/spec/support/platform_helpers.rb +12 -0
- data/spec/support/shared/functional/file_resource.rb +10 -0
- data/spec/support/shared/integration/chef_zero_support.rb +130 -0
- data/spec/support/shared/integration/integration_helper.rb +100 -98
- data/spec/support/shared/integration/knife_support.rb +0 -1
- data/spec/support/shared/unit/provider/file.rb +6 -4
- data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +10 -1
- data/spec/unit/api_client/registration_spec.rb +83 -74
- data/spec/unit/application_spec.rb +32 -9
- data/spec/unit/cookbook/cookbook_version_loader_spec.rb +179 -0
- data/spec/unit/cookbook/metadata_spec.rb +190 -150
- data/spec/unit/cookbook/syntax_check_spec.rb +3 -2
- data/spec/unit/cookbook_loader_spec.rb +114 -53
- data/spec/unit/{cookbook_site_streaming_uploader.rb → cookbook_site_streaming_uploader_spec.rb} +21 -1
- data/spec/unit/data_bag_spec.rb +88 -13
- data/spec/unit/deprecation_spec.rb +1 -2
- data/spec/unit/encrypted_data_bag_item_spec.rb +145 -9
- data/spec/unit/environment_spec.rb +1 -1
- data/spec/unit/formatters/base_spec.rb +48 -0
- data/spec/unit/json_compat_spec.rb +48 -17
- data/spec/unit/knife/client_delete_spec.rb +4 -4
- data/spec/unit/knife/client_show_spec.rb +15 -5
- data/spec/unit/knife/cookbook_site_download_spec.rb +1 -1
- data/spec/unit/knife/cookbook_site_share_spec.rb +3 -3
- data/spec/unit/knife/data_bag_from_file_spec.rb +0 -2
- data/spec/unit/knife/data_bag_show_spec.rb +23 -14
- data/spec/unit/knife/node_show_spec.rb +32 -15
- data/spec/unit/knife/role_show_spec.rb +59 -0
- data/spec/unit/platform_spec.rb +10 -0
- data/spec/unit/provider/deploy_spec.rb +4 -0
- data/spec/unit/provider/env_spec.rb +19 -0
- data/spec/unit/provider/git_spec.rb +22 -2
- data/spec/unit/provider/group/dscl_spec.rb +38 -1
- data/spec/unit/provider/group/pw_spec.rb +2 -2
- data/spec/unit/provider/http_request_spec.rb +8 -8
- data/spec/unit/provider/log_spec.rb +33 -53
- data/spec/unit/provider/mount/mount_spec.rb +12 -3
- data/spec/unit/provider/package/ips_spec.rb +96 -63
- data/spec/unit/provider/package/paludis_spec.rb +5 -5
- data/spec/unit/provider/package/rpm_spec.rb +12 -0
- data/spec/unit/provider/package/zypper_spec.rb +28 -16
- data/spec/unit/provider/service/windows_spec.rb +77 -17
- data/spec/unit/provider/user/dscl_spec.rb +659 -264
- data/spec/unit/provider/user/useradd_spec.rb +1 -0
- data/spec/unit/recipe_spec.rb +41 -0
- data/spec/unit/resource/scm_spec.rb +11 -0
- data/spec/unit/resource/user_spec.rb +4 -0
- data/spec/unit/resource/windows_service_spec.rb +46 -0
- data/spec/unit/resource_collection_spec.rb +33 -0
- data/spec/unit/resource_reporter_spec.rb +48 -0
- data/spec/unit/resource_spec.rb +9 -2
- data/spec/unit/role_spec.rb +6 -0
- data/spec/unit/version_constraint_spec.rb +28 -0
- metadata +61 -4
data/lib/chef/providers.rb
CHANGED
@@ -91,6 +91,7 @@ require 'chef/provider/user/pw'
|
|
91
91
|
require 'chef/provider/user/useradd'
|
92
92
|
require 'chef/provider/user/windows'
|
93
93
|
require 'chef/provider/user/solaris'
|
94
|
+
require 'chef/provider/user/aix'
|
94
95
|
|
95
96
|
require 'chef/provider/group/aix'
|
96
97
|
require 'chef/provider/group/dscl'
|
data/lib/chef/resource.rb
CHANGED
@@ -134,7 +134,6 @@ F
|
|
134
134
|
|
135
135
|
extend Chef::Mixin::ConvertToClassName
|
136
136
|
|
137
|
-
|
138
137
|
if Module.method(:const_defined?).arity == 1
|
139
138
|
def self.strict_const_defined?(const)
|
140
139
|
const_defined?(const)
|
@@ -277,7 +276,6 @@ F
|
|
277
276
|
end
|
278
277
|
end
|
279
278
|
|
280
|
-
|
281
279
|
def updated=(true_or_false)
|
282
280
|
Chef::Log.warn("Chef::Resource#updated=(true|false) is deprecated. Please call #updated_by_last_action(true|false) instead.")
|
283
281
|
Chef::Log.warn("Called from:")
|
@@ -544,7 +542,7 @@ F
|
|
544
542
|
# Serialize this object as a hash
|
545
543
|
def to_json(*a)
|
546
544
|
results = as_json
|
547
|
-
|
545
|
+
Chef::JSONCompat.to_json(results, *a)
|
548
546
|
end
|
549
547
|
|
550
548
|
def to_hash
|
@@ -662,6 +660,9 @@ F
|
|
662
660
|
end
|
663
661
|
ensure
|
664
662
|
@elapsed_time = Time.now - start_time
|
663
|
+
# Reporting endpoint doesn't accept a negative resource duration so set it to 0.
|
664
|
+
# A negative value can occur when a resource changes the system time backwards
|
665
|
+
@elapsed_time = 0 if @elapsed_time < 0
|
665
666
|
events.resource_completed(self)
|
666
667
|
end
|
667
668
|
end
|
@@ -31,17 +31,26 @@ class Chef
|
|
31
31
|
|
32
32
|
provides :package, :on_platforms => ["freebsd"]
|
33
33
|
|
34
|
+
attr_accessor :created_as_type
|
34
35
|
|
35
36
|
def initialize(name, run_context=nil)
|
36
37
|
super
|
37
38
|
@resource_name = :freebsd_package
|
39
|
+
@created_as_type = "freebsd_package"
|
38
40
|
end
|
39
41
|
|
40
42
|
def after_created
|
41
43
|
assign_provider
|
42
44
|
end
|
43
45
|
|
44
|
-
|
46
|
+
# This resource can be invoked with multiple names package & freebsd_package.
|
47
|
+
# We override the to_s method to ensure the key in resource collection
|
48
|
+
# matches the type resource is declared as using created_as_type. This
|
49
|
+
# logic can be removed once Chef does this for all resource in Chef 12:
|
50
|
+
# https://github.com/opscode/chef/issues/1817
|
51
|
+
def to_s
|
52
|
+
"#{created_as_type}[#{name}]"
|
53
|
+
end
|
45
54
|
|
46
55
|
private
|
47
56
|
|
@@ -68,4 +77,3 @@ class Chef
|
|
68
77
|
end
|
69
78
|
end
|
70
79
|
end
|
71
|
-
|
data/lib/chef/resource/scm.rb
CHANGED
@@ -40,6 +40,7 @@ class Chef
|
|
40
40
|
@allowed_actions.push(:checkout, :export, :sync, :diff, :log)
|
41
41
|
@action = [:sync]
|
42
42
|
@checkout_branch = "deploy"
|
43
|
+
@environment = nil
|
43
44
|
end
|
44
45
|
|
45
46
|
def destination(arg=nil)
|
@@ -172,6 +173,15 @@ class Chef
|
|
172
173
|
)
|
173
174
|
end
|
174
175
|
|
176
|
+
def environment(arg=nil)
|
177
|
+
set_or_return(
|
178
|
+
:environment,
|
179
|
+
arg,
|
180
|
+
:kind_of => [ Hash ]
|
181
|
+
)
|
182
|
+
end
|
183
|
+
|
184
|
+
alias :env :environment
|
175
185
|
end
|
176
186
|
end
|
177
187
|
end
|
data/lib/chef/resource/user.rb
CHANGED
@@ -38,12 +38,15 @@ class Chef
|
|
38
38
|
@password = nil
|
39
39
|
@system = false
|
40
40
|
@manage_home = false
|
41
|
+
@force = false
|
41
42
|
@non_unique = false
|
42
43
|
@action = :create
|
43
44
|
@supports = {
|
44
45
|
:manage_home => false,
|
45
46
|
:non_unique => false
|
46
47
|
}
|
48
|
+
@iterations = 27855
|
49
|
+
@salt = nil
|
47
50
|
@allowed_actions.push(:create, :remove, :modify, :manage, :lock, :unlock)
|
48
51
|
end
|
49
52
|
|
@@ -105,6 +108,22 @@ class Chef
|
|
105
108
|
)
|
106
109
|
end
|
107
110
|
|
111
|
+
def salt(arg=nil)
|
112
|
+
set_or_return(
|
113
|
+
:salt,
|
114
|
+
arg,
|
115
|
+
:kind_of => [ String ]
|
116
|
+
)
|
117
|
+
end
|
118
|
+
|
119
|
+
def iterations(arg=nil)
|
120
|
+
set_or_return(
|
121
|
+
:iterations,
|
122
|
+
arg,
|
123
|
+
:kind_of => [ Integer ]
|
124
|
+
)
|
125
|
+
end
|
126
|
+
|
108
127
|
def system(arg=nil)
|
109
128
|
set_or_return(
|
110
129
|
:system,
|
@@ -121,6 +140,14 @@ class Chef
|
|
121
140
|
)
|
122
141
|
end
|
123
142
|
|
143
|
+
def force(arg=nil)
|
144
|
+
set_or_return(
|
145
|
+
:force,
|
146
|
+
arg,
|
147
|
+
:kind_of => [ TrueClass, FalseClass ]
|
148
|
+
)
|
149
|
+
end
|
150
|
+
|
124
151
|
def non_unique(arg=nil)
|
125
152
|
set_or_return(
|
126
153
|
:non_unique,
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Bryan McLellan <btm@loftninjas.org>
|
3
|
+
# Copyright:: Copyright (c) 2014 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/service'
|
20
|
+
|
21
|
+
class Chef
|
22
|
+
class Resource
|
23
|
+
class WindowsService < Chef::Resource::Service
|
24
|
+
|
25
|
+
# Until #1773 is resolved, you need to manually specify the windows_service resource
|
26
|
+
# to use action :configure_startup and attribute startup_type
|
27
|
+
|
28
|
+
# provides :service, :on_platforms => ["windows"]
|
29
|
+
|
30
|
+
identity_attr :service_name
|
31
|
+
|
32
|
+
state_attrs :enabled, :running
|
33
|
+
|
34
|
+
def initialize(name, run_context=nil)
|
35
|
+
super
|
36
|
+
@resource_name = :windows_service
|
37
|
+
@provider = Chef::Provider::Service::Windows
|
38
|
+
@allowed_actions.push(:configure_startup)
|
39
|
+
@startup_type = :automatic
|
40
|
+
end
|
41
|
+
|
42
|
+
def startup_type(arg=nil)
|
43
|
+
# Set-Service arguments are automatic and manual
|
44
|
+
# Win32::Service returns 'auto start' or 'demand start' respectively, which the provider currently uses
|
45
|
+
set_or_return(
|
46
|
+
:startup_type,
|
47
|
+
arg,
|
48
|
+
:equal_to => [ :automatic, :manual, :disabled ]
|
49
|
+
)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -67,24 +67,33 @@ class Chef
|
|
67
67
|
alias_method :push, :<<
|
68
68
|
|
69
69
|
def insert(resource)
|
70
|
-
is_chef_resource(resource)
|
71
70
|
if @insert_after_idx
|
72
71
|
# in the middle of executing a run, so any resources inserted now should
|
73
72
|
# be placed after the most recent addition done by the currently executing
|
74
73
|
# resource
|
75
|
-
|
76
|
-
# update name -> location mappings and register new resource
|
77
|
-
@resources_by_name.each_key do |key|
|
78
|
-
@resources_by_name[key] += 1 if @resources_by_name[key] > @insert_after_idx
|
79
|
-
end
|
80
|
-
@resources_by_name[resource.to_s] = @insert_after_idx + 1
|
74
|
+
insert_at(@insert_after_idx + 1, resource)
|
81
75
|
@insert_after_idx += 1
|
82
76
|
else
|
77
|
+
is_chef_resource(resource)
|
83
78
|
@resources << resource
|
84
79
|
@resources_by_name[resource.to_s] = @resources.length - 1
|
85
80
|
end
|
86
81
|
end
|
87
82
|
|
83
|
+
def insert_at(insert_at_index, *resources)
|
84
|
+
resources.each do |resource|
|
85
|
+
is_chef_resource(resource)
|
86
|
+
end
|
87
|
+
@resources.insert(insert_at_index, *resources)
|
88
|
+
# update name -> location mappings and register new resource
|
89
|
+
@resources_by_name.each_key do |key|
|
90
|
+
@resources_by_name[key] += resources.size if @resources_by_name[key] >= insert_at_index
|
91
|
+
end
|
92
|
+
resources.each_with_index do |resource, i|
|
93
|
+
@resources_by_name[resource.to_s] = insert_at_index + i
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
88
97
|
def each
|
89
98
|
@resources.each do |resource|
|
90
99
|
yield resource
|
@@ -158,7 +167,6 @@ class Chef
|
|
158
167
|
# compat.
|
159
168
|
alias_method :resources, :find
|
160
169
|
|
161
|
-
|
162
170
|
# Returns true if +query_object+ is a valid string for looking up a
|
163
171
|
# resource, or raises InvalidResourceSpecification if not.
|
164
172
|
# === Arguments
|
@@ -189,16 +197,19 @@ class Chef
|
|
189
197
|
end
|
190
198
|
|
191
199
|
# Serialize this object as a hash
|
192
|
-
def
|
200
|
+
def to_hash
|
193
201
|
instance_vars = Hash.new
|
194
202
|
self.instance_variables.each do |iv|
|
195
203
|
instance_vars[iv] = self.instance_variable_get(iv)
|
196
204
|
end
|
197
|
-
|
205
|
+
{
|
198
206
|
'json_class' => self.class.name,
|
199
207
|
'instance_vars' => instance_vars
|
200
208
|
}
|
201
|
-
|
209
|
+
end
|
210
|
+
|
211
|
+
def to_json(*a)
|
212
|
+
Chef::JSONCompat.to_json(to_hash, *a)
|
202
213
|
end
|
203
214
|
|
204
215
|
def self.json_create(o)
|
@@ -247,7 +258,7 @@ class Chef
|
|
247
258
|
|
248
259
|
def is_chef_resource(arg)
|
249
260
|
unless arg.kind_of?(Chef::Resource)
|
250
|
-
raise ArgumentError, "
|
261
|
+
raise ArgumentError, "Cannot insert a #{arg.class} into a resource collection: must be a subclass of Chef::Resource"
|
251
262
|
end
|
252
263
|
true
|
253
264
|
end
|
@@ -230,18 +230,18 @@ class Chef
|
|
230
230
|
resource_history_url = "reports/nodes/#{node_name}/runs/#{run_id}"
|
231
231
|
Chef::Log.info("Sending resource update report (run-id: #{run_id})")
|
232
232
|
Chef::Log.debug run_data.inspect
|
233
|
-
compressed_data = encode_gzip(
|
233
|
+
compressed_data = encode_gzip(Chef::JSONCompat.to_json(run_data))
|
234
|
+
Chef::Log.debug("Sending compressed run data...")
|
235
|
+
# Since we're posting compressed data we can not directly call post_rest which expects JSON
|
236
|
+
reporting_url = @rest_client.create_url(resource_history_url)
|
234
237
|
begin
|
235
|
-
Chef::Log.debug("Sending compressed run data...")
|
236
|
-
# Since we're posting compressed data we can not directly call post_rest which expects JSON
|
237
|
-
reporting_url = @rest_client.create_url(resource_history_url)
|
238
238
|
@rest_client.raw_http_request(:POST, reporting_url, headers({'Content-Encoding' => 'gzip'}), compressed_data)
|
239
|
-
rescue
|
240
|
-
if e.response
|
239
|
+
rescue StandardError => e
|
240
|
+
if e.respond_to? :response
|
241
241
|
Chef::FileCache.store("failed-reporting-data.json", Chef::JSONCompat.to_json_pretty(run_data), 0640)
|
242
|
-
Chef::Log.error("Failed to post reporting data to server (HTTP
|
242
|
+
Chef::Log.error("Failed to post reporting data to server (HTTP #{e.response.code}), saving to #{Chef::FileCache.load("failed-reporting-data.json", false)}")
|
243
243
|
else
|
244
|
-
Chef::Log.error("Failed to post reporting data to server (
|
244
|
+
Chef::Log.error("Failed to post reporting data to server (#{e})")
|
245
245
|
end
|
246
246
|
end
|
247
247
|
else
|
@@ -273,7 +273,7 @@ class Chef
|
|
273
273
|
resource_record.for_json
|
274
274
|
end
|
275
275
|
run_data["status"] = @status
|
276
|
-
run_data["run_list"] = @run_status.node.run_list
|
276
|
+
run_data["run_list"] = Chef::JSONCompat.to_json(@run_status.node.run_list)
|
277
277
|
run_data["total_res_count"] = @total_res_count.to_s
|
278
278
|
run_data["data"] = {}
|
279
279
|
run_data["start_time"] = start_time.to_s
|
@@ -283,7 +283,7 @@ class Chef
|
|
283
283
|
exception_data = {}
|
284
284
|
exception_data["class"] = exception.inspect
|
285
285
|
exception_data["message"] = exception.message
|
286
|
-
exception_data["backtrace"] = exception.backtrace
|
286
|
+
exception_data["backtrace"] = Chef::JSONCompat.to_json(exception.backtrace)
|
287
287
|
exception_data["description"] = @error_descriptions
|
288
288
|
run_data["data"]["exception"] = exception_data
|
289
289
|
end
|
data/lib/chef/resources.rb
CHANGED
@@ -64,6 +64,7 @@ require 'chef/resource/ruby_block'
|
|
64
64
|
require 'chef/resource/scm'
|
65
65
|
require 'chef/resource/script'
|
66
66
|
require 'chef/resource/service'
|
67
|
+
require 'chef/resource/windows_service'
|
67
68
|
require 'chef/resource/subversion'
|
68
69
|
require 'chef/resource/smartos_package'
|
69
70
|
require 'chef/resource/template'
|
data/lib/chef/role.rb
CHANGED
@@ -143,7 +143,7 @@ class Chef
|
|
143
143
|
|
144
144
|
# Serialize this object as a hash
|
145
145
|
def to_json(*a)
|
146
|
-
|
146
|
+
Chef::JSONCompat.to_json(to_hash, *a)
|
147
147
|
end
|
148
148
|
|
149
149
|
def update_from!(o)
|
@@ -236,8 +236,8 @@ class Chef
|
|
236
236
|
paths = Array(Chef::Config[:role_path])
|
237
237
|
paths.each do |path|
|
238
238
|
roles_files = Dir.glob(File.join(path, "**", "**"))
|
239
|
-
js_files = roles_files.select { |file| file.match
|
240
|
-
rb_files = roles_files.select { |file| file.match
|
239
|
+
js_files = roles_files.select { |file| file.match /\/#{name}\.json$/ }
|
240
|
+
rb_files = roles_files.select { |file| file.match /\/#{name}\.rb$/ }
|
241
241
|
if js_files.count > 1 or rb_files.count > 1
|
242
242
|
raise Chef::Exceptions::DuplicateRole, "Multiple roles of same type found named #{name}"
|
243
243
|
end
|
data/lib/chef/run_list.rb
CHANGED
@@ -85,8 +85,12 @@ class Chef
|
|
85
85
|
@run_list_items.join(", ")
|
86
86
|
end
|
87
87
|
|
88
|
-
def
|
89
|
-
to_a.map { |item| item.to_s}
|
88
|
+
def for_json
|
89
|
+
to_a.map { |item| item.to_s }
|
90
|
+
end
|
91
|
+
|
92
|
+
def to_json(*a)
|
93
|
+
Chef::JSONCompat.to_json(for_json, *a)
|
90
94
|
end
|
91
95
|
|
92
96
|
def empty?
|
@@ -158,6 +162,5 @@ class Chef
|
|
158
162
|
end
|
159
163
|
end
|
160
164
|
|
161
|
-
|
162
165
|
end
|
163
166
|
end
|
data/lib/chef/user.rb
CHANGED
data/lib/chef/util/diff.rb
CHANGED
data/lib/chef/version.rb
CHANGED
@@ -24,7 +24,7 @@ class Chef
|
|
24
24
|
PATTERN = /^(#{OPS.join('|')}) *([0-9].*)$/
|
25
25
|
VERSION_CLASS = Chef::Version
|
26
26
|
|
27
|
-
attr_reader :op, :version
|
27
|
+
attr_reader :op, :version
|
28
28
|
|
29
29
|
def initialize(constraint_spec=DEFAULT_CONSTRAINT)
|
30
30
|
case constraint_spec
|
@@ -50,11 +50,11 @@ class Chef
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def inspect
|
53
|
-
"(#{
|
53
|
+
"(#{to_s})"
|
54
54
|
end
|
55
55
|
|
56
56
|
def to_s
|
57
|
-
"#{@op} #{@
|
57
|
+
"#{@op} #{@raw_version}"
|
58
58
|
end
|
59
59
|
|
60
60
|
def eql?(o)
|
@@ -106,7 +106,7 @@ class Chef
|
|
106
106
|
@op = $1
|
107
107
|
@raw_version = $2
|
108
108
|
@version = self.class::VERSION_CLASS.new(@raw_version)
|
109
|
-
if raw_version.split('.').size <= 2
|
109
|
+
if @raw_version.split('.').size <= 2
|
110
110
|
@missing_patch_level = true
|
111
111
|
end
|
112
112
|
else
|