chef 13.6.4-universal-mingw32 → 13.7.16-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 +5 -5
- data/VERSION +1 -1
- data/acceptance/Gemfile +2 -2
- data/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb +1 -6
- data/distro/powershell/chef/chef.psm1 +1 -5
- data/lib/chef/api_client.rb +5 -5
- data/lib/chef/api_client_v1.rb +6 -6
- data/lib/chef/application.rb +3 -2
- data/lib/chef/application/knife.rb +4 -0
- data/lib/chef/chef_class.rb +2 -2
- data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/data_handler_base.rb +2 -4
- data/lib/chef/client.rb +3 -3
- data/lib/chef/cookbook/chefignore.rb +4 -0
- data/lib/chef/cookbook/cookbook_collection.rb +2 -2
- data/lib/chef/cookbook/metadata.rb +2 -2
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/deprecated.rb +10 -0
- data/lib/chef/event_dispatch/base.rb +2 -2
- data/lib/chef/http.rb +10 -10
- data/lib/chef/knife.rb +16 -15
- data/lib/chef/knife/configure.rb +12 -36
- data/lib/chef/knife/cookbook_upload.rb +4 -4
- data/lib/chef/knife/core/bootstrap_context.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +6 -2
- data/lib/chef/knife/core/ui.rb +1 -1
- data/lib/chef/knife/data_bag_secret_options.rb +1 -1
- data/lib/chef/knife/data_bag_show.rb +1 -1
- data/lib/chef/knife/edit.rb +1 -1
- data/lib/chef/knife/ssh.rb +47 -35
- data/lib/chef/knife/user_create.rb +2 -0
- data/lib/chef/knife/user_delete.rb +2 -0
- data/lib/chef/knife/user_edit.rb +2 -0
- data/lib/chef/knife/user_reregister.rb +2 -0
- data/lib/chef/knife/user_show.rb +2 -0
- data/lib/chef/mixin/powershell_out.rb +1 -1
- data/lib/chef/node/attribute.rb +46 -70
- data/lib/chef/node/attribute_collections.rb +5 -5
- data/lib/chef/node/common_api.rb +1 -1
- data/lib/chef/node/immutable_collections.rb +180 -23
- data/lib/chef/node/mixin/state_tracking.rb +6 -6
- data/lib/chef/node_map.rb +63 -45
- data/lib/chef/property.rb +8 -8
- data/lib/chef/provider.rb +9 -3
- data/lib/chef/provider/apt_preference.rb +1 -1
- data/lib/chef/provider/apt_repository.rb +1 -1
- data/lib/chef/provider/apt_update.rb +1 -1
- data/lib/chef/provider/file.rb +1 -1
- data/lib/chef/provider/group/dscl.rb +6 -2
- data/lib/chef/provider/ifconfig.rb +96 -34
- data/lib/chef/provider/launchd.rb +0 -1
- data/lib/chef/provider/log.rb +3 -13
- data/lib/chef/provider/package/dnf.rb +1 -1
- data/lib/chef/provider/package/smartos.rb +2 -2
- data/lib/chef/provider/reboot.rb +12 -0
- data/lib/chef/provider/remote_directory.rb +1 -1
- data/lib/chef/provider/remote_file/http.rb +3 -2
- data/lib/chef/provider/service/solaris.rb +6 -2
- data/lib/chef/provider/systemd_unit.rb +34 -33
- data/lib/chef/provider/user/dscl.rb +1 -1
- data/lib/chef/provider/windows_path.rb +6 -7
- data/lib/chef/provider/windows_task.rb +89 -33
- data/lib/chef/provider/yum_repository.rb +24 -9
- data/lib/chef/resource/apt_package.rb +1 -0
- data/lib/chef/resource/apt_preference.rb +4 -0
- data/lib/chef/resource/apt_repository.rb +4 -0
- data/lib/chef/resource/apt_update.rb +3 -0
- data/lib/chef/resource/bash.rb +4 -0
- data/lib/chef/resource/batch.rb +5 -0
- data/lib/chef/resource/bff_package.rb +4 -0
- data/lib/chef/resource/breakpoint.rb +6 -0
- data/lib/chef/resource/cab_package.rb +6 -6
- data/lib/chef/resource/chef_gem.rb +13 -0
- data/lib/chef/resource/chocolatey_package.rb +4 -6
- data/lib/chef/resource/cookbook_file.rb +13 -15
- data/lib/chef/resource/cron.rb +2 -0
- data/lib/chef/resource/csh.rb +4 -0
- data/lib/chef/resource/directory.rb +8 -26
- data/lib/chef/resource/dnf_package.rb +5 -0
- data/lib/chef/resource/dpkg_package.rb +2 -0
- data/lib/chef/resource/dsc_resource.rb +5 -0
- data/lib/chef/resource/dsc_script.rb +6 -0
- data/lib/chef/resource/env.rb +3 -0
- data/lib/chef/resource/erl_call.rb +5 -0
- data/lib/chef/resource/execute.rb +5 -1
- data/lib/chef/resource/file.rb +2 -1
- data/lib/chef/resource/file/verification.rb +10 -0
- data/lib/chef/resource/freebsd_package.rb +10 -2
- data/lib/chef/resource/gem_package.rb +2 -0
- data/lib/chef/resource/git.rb +2 -0
- data/lib/chef/resource/group.rb +1 -0
- data/lib/chef/resource/homebrew_package.rb +3 -0
- data/lib/chef/resource/http_request.rb +2 -0
- data/lib/chef/resource/ifconfig.rb +23 -150
- data/lib/chef/resource/ips_package.rb +1 -0
- data/lib/chef/resource/ksh.rb +6 -0
- data/lib/chef/resource/launchd.rb +5 -4
- data/lib/chef/resource/link.rb +10 -0
- data/lib/chef/resource/log.rb +19 -46
- data/lib/chef/resource/macports_package.rb +1 -0
- data/lib/chef/resource/mdadm.rb +4 -0
- data/lib/chef/resource/mount.rb +1 -0
- data/lib/chef/resource/msu_package.rb +7 -8
- data/lib/chef/resource/ohai.rb +2 -0
- data/lib/chef/resource/openbsd_package.rb +3 -0
- data/lib/chef/resource/osx_profile.rb +10 -40
- data/lib/chef/resource/package.rb +6 -0
- data/lib/chef/resource/pacman_package.rb +1 -0
- data/lib/chef/resource/paludis_package.rb +3 -0
- data/lib/chef/resource/perl.rb +4 -0
- data/lib/chef/resource/portage_package.rb +1 -0
- data/lib/chef/resource/powershell_package.rb +5 -0
- data/lib/chef/resource/powershell_script.rb +8 -0
- data/lib/chef/resource/python.rb +4 -0
- data/lib/chef/resource/reboot.rb +14 -20
- data/lib/chef/resource/registry_key.rb +1 -0
- data/lib/chef/resource/remote_directory.rb +3 -0
- data/lib/chef/resource/remote_file.rb +2 -0
- data/lib/chef/resource/resource_notification.rb +17 -0
- data/lib/chef/resource/route.rb +1 -0
- data/lib/chef/resource/rpm_package.rb +1 -0
- data/lib/chef/resource/ruby.rb +4 -0
- data/lib/chef/resource/ruby_block.rb +3 -0
- data/lib/chef/resource/script.rb +4 -0
- data/lib/chef/resource/service.rb +1 -0
- data/lib/chef/resource/smartos_package.rb +1 -0
- data/lib/chef/resource/solaris_package.rb +1 -0
- data/lib/chef/resource/subversion.rb +1 -0
- data/lib/chef/resource/systemd_unit.rb +6 -0
- data/lib/chef/resource/template.rb +9 -0
- data/lib/chef/resource/user.rb +1 -0
- data/lib/chef/resource/windows_package.rb +2 -0
- data/lib/chef/resource/windows_path.rb +5 -10
- data/lib/chef/resource/windows_service.rb +3 -0
- data/lib/chef/resource/windows_task.rb +66 -87
- data/lib/chef/resource/yum_repository.rb +26 -22
- data/lib/chef/resource/zypper_package.rb +2 -0
- data/lib/chef/resource/zypper_repository.rb +6 -1
- data/lib/chef/run_context.rb +8 -2
- data/lib/chef/server_api.rb +1 -0
- data/lib/chef/util/selinux.rb +5 -4
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version/platform.rb +18 -0
- data/lib/chef/version_constraint/platform.rb +2 -0
- data/spec/data/client.d_00/02-strings.rb +2 -0
- data/spec/functional/assets/chefinittest +6 -4
- data/spec/functional/knife/ssh_spec.rb +54 -7
- data/spec/functional/resource/bff_spec.rb +3 -3
- data/spec/functional/resource/ifconfig_spec.rb +1 -1
- data/spec/functional/resource/mount_spec.rb +7 -3
- data/spec/functional/resource/user/useradd_spec.rb +4 -4
- data/spec/functional/resource/windows_task_spec.rb +6 -6
- data/spec/functional/win32/security_spec.rb +7 -33
- data/spec/integration/knife/data_bag_show_spec.rb +1 -1
- data/spec/integration/recipes/noop_resource_spec.rb +1 -1
- data/spec/integration/recipes/recipe_dsl_spec.rb +30 -30
- data/spec/integration/recipes/resource_action_spec.rb +2 -2
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +71 -15
- data/spec/spec_helper.rb +19 -0
- data/spec/support/shared/functional/execute_resource.rb +1 -1
- data/spec/support/shared/unit/application_dot_d.rb +2 -0
- data/spec/support/shared/unit/execute_resource.rb +8 -1
- data/spec/support/shared/unit/provider/file.rb +9 -1
- data/spec/unit/chef_fs/data_handler/data_bag_item_data_handler.rb +10 -7
- data/spec/unit/chef_fs/file_system/repository/directory_spec.rb +2 -2
- data/spec/unit/client_spec.rb +1 -1
- data/spec/unit/deprecated_spec.rb +4 -4
- data/spec/unit/http_spec.rb +9 -0
- data/spec/unit/knife/bootstrap_spec.rb +5 -0
- data/spec/unit/knife/configure_spec.rb +10 -60
- data/spec/unit/knife/data_bag_create_spec.rb +40 -2
- data/spec/unit/knife/data_bag_show_spec.rb +16 -2
- data/spec/unit/knife/ssh_spec.rb +85 -39
- data/spec/unit/knife_spec.rb +2 -0
- data/spec/unit/lwrp_spec.rb +5 -3
- data/spec/unit/mixin/powershell_type_coercions_spec.rb +7 -6
- data/spec/unit/node/attribute_spec.rb +55 -24
- data/spec/unit/node/immutable_collections_spec.rb +28 -14
- data/spec/unit/node/vivid_mash_spec.rb +27 -10
- data/spec/unit/node_map_spec.rb +34 -0
- data/spec/unit/property_spec.rb +13 -13
- data/spec/unit/provider/group/dscl_spec.rb +14 -5
- data/spec/unit/provider/ifconfig_spec.rb +10 -3
- data/spec/unit/provider/remote_file/http_spec.rb +23 -19
- data/spec/unit/provider/service/solaris_smf_service_spec.rb +6 -5
- data/spec/unit/provider/user/dscl_spec.rb +26 -0
- data/spec/unit/provider/windows_task_spec.rb +148 -4
- data/spec/unit/provider_spec.rb +1 -1
- data/spec/unit/resource/apt_package_spec.rb +1 -1
- data/spec/unit/resource/bash_spec.rb +8 -10
- data/spec/unit/resource/batch_spec.rb +1 -1
- data/spec/unit/resource/cab_package_spec.rb +19 -1
- data/spec/unit/resource/chef_gem_spec.rb +3 -3
- data/spec/unit/resource/chocolatey_package_spec.rb +10 -10
- data/spec/unit/resource/conditional_spec.rb +2 -2
- data/spec/unit/resource/cookbook_file_spec.rb +24 -30
- data/spec/unit/resource/cron_spec.rb +79 -82
- data/spec/unit/resource/csh_spec.rb +8 -10
- data/spec/unit/resource/deploy_spec.rb +1 -1
- data/spec/unit/resource/directory_spec.rb +28 -31
- data/spec/unit/resource/dnf_package_spec.rb +9 -9
- data/spec/unit/resource/env_spec.rb +7 -7
- data/spec/unit/resource/erl_call_spec.rb +9 -9
- data/spec/unit/resource/execute_spec.rb +6 -6
- data/spec/unit/resource/file/verification_spec.rb +18 -4
- data/spec/unit/resource/file_spec.rb +53 -56
- data/spec/unit/resource/freebsd_package_spec.rb +7 -7
- data/spec/unit/resource/gem_package_spec.rb +1 -1
- data/spec/unit/resource/git_spec.rb +7 -9
- data/spec/unit/resource/group_spec.rb +60 -70
- data/spec/unit/resource/http_request_spec.rb +16 -19
- data/spec/unit/resource/ifconfig_spec.rb +3 -3
- data/spec/unit/resource/ips_package_spec.rb +3 -5
- data/spec/unit/resource/ksh_spec.rb +8 -10
- data/spec/unit/resource/launchd_spec.rb +17 -10
- data/spec/unit/resource/link_spec.rb +53 -53
- data/spec/unit/resource/log_spec.rb +24 -28
- data/spec/unit/resource/mdadm_spec.rb +42 -44
- data/spec/unit/resource/mount_spec.rb +97 -99
- data/spec/unit/resource/msu_package_spec.rb +14 -8
- data/spec/unit/resource/ohai_spec.rb +15 -17
- data/spec/unit/resource/openbsd_package_spec.rb +3 -3
- data/spec/unit/resource/osx_profile_spec.rb +7 -7
- data/spec/unit/resource/package_spec.rb +36 -40
- data/spec/unit/resource/perl_spec.rb +8 -11
- data/spec/unit/resource/portage_package_spec.rb +8 -10
- data/spec/unit/resource/powershell_package_spec.rb +9 -9
- data/spec/unit/resource/python_spec.rb +8 -11
- data/spec/unit/resource/reboot_spec.rb +50 -0
- data/spec/unit/resource/registry_key_spec.rb +84 -98
- data/spec/unit/resource/remote_directory_spec.rb +40 -42
- data/spec/unit/resource/remote_file_spec.rb +78 -80
- data/spec/unit/resource/route_spec.rb +42 -44
- data/spec/unit/resource/rpm_package_spec.rb +5 -7
- data/spec/unit/resource/ruby_block_spec.rb +14 -16
- data/spec/unit/resource/ruby_spec.rb +8 -12
- data/spec/unit/resource/scm_spec.rb +66 -69
- data/spec/unit/resource/script_spec.rb +1 -1
- data/spec/unit/resource/service_spec.rb +80 -83
- data/spec/unit/resource/smartos_package_spec.rb +5 -0
- data/spec/unit/resource/solaris_package_spec.rb +3 -5
- data/spec/unit/resource/subversion_spec.rb +18 -16
- data/spec/unit/resource/systemd_unit_spec.rb +50 -54
- data/spec/unit/resource/template_spec.rb +56 -61
- data/spec/unit/resource/user_spec.rb +47 -53
- data/spec/unit/resource/windows_package_spec.rb +1 -1
- data/spec/unit/resource/windows_path_spec.rb +11 -8
- data/spec/unit/resource/windows_task_spec.rb +129 -33
- data/spec/unit/resource/yum_package_spec.rb +1 -1
- data/spec/unit/resource/yum_repository_spec.rb +61 -8
- data/spec/unit/resource/zypper_repository_spec.rb +17 -18
- data/spec/unit/util/selinux_spec.rb +3 -6
- data/tasks/dependencies.rb +0 -5
- data/tasks/rspec.rb +1 -1
- metadata +7 -19
- data/acceptance/.DS_Store +0 -0
- data/acceptance/.bundle/config +0 -2
- data/acceptance/top-cookbooks/.kitchen.docker.yml +0 -13
- data/acceptance/top-cookbooks/.kitchen.git.yml +0 -11
- data/distro/.DS_Store +0 -0
- data/lib/.DS_Store +0 -0
- data/lib/chef/.DS_Store +0 -0
- data/lib/chef/knife/.DS_Store +0 -0
- data/lib/chef/mixin/.DS_Store +0 -0
- data/spec/.DS_Store +0 -0
- data/spec/functional/.DS_Store +0 -0
- data/spec/support/.DS_Store +0 -0
- data/spec/unit/.DS_Store +0 -0
- data/tasks/.DS_Store +0 -0
data/lib/chef/property.rb
CHANGED
@@ -99,7 +99,7 @@ class Chef
|
|
99
99
|
if options.has_key?(:name_attribute)
|
100
100
|
# If we have both name_attribute and name_property and they differ, raise an error
|
101
101
|
if options.has_key?(:name_property)
|
102
|
-
raise ArgumentError, "
|
102
|
+
raise ArgumentError, "name_attribute and name_property are functionally identical and both cannot be specified on a property at once. Use just one on property #{self}"
|
103
103
|
end
|
104
104
|
# replace name_property with name_attribute in place
|
105
105
|
options = Hash[options.map { |k, v| k == :name_attribute ? [ :name_property, v ] : [ k, v ] }]
|
@@ -107,7 +107,7 @@ class Chef
|
|
107
107
|
end
|
108
108
|
|
109
109
|
if options.has_key?(:default) && options.has_key?(:name_property)
|
110
|
-
raise ArgumentError, "
|
110
|
+
raise ArgumentError, "A property cannot be both a name_property/name_attribute and have a default value. Use one or the other on property #{self}"
|
111
111
|
end
|
112
112
|
|
113
113
|
# Recursively freeze the default if it isn't a lazy value.
|
@@ -361,7 +361,7 @@ class Chef
|
|
361
361
|
end
|
362
362
|
|
363
363
|
if value.nil? && required?
|
364
|
-
raise Chef::Exceptions::ValidationFailed, "#{name} is required"
|
364
|
+
raise Chef::Exceptions::ValidationFailed, "#{name} is a required property"
|
365
365
|
else
|
366
366
|
value
|
367
367
|
end
|
@@ -386,7 +386,7 @@ class Chef
|
|
386
386
|
value = set_value(resource, input_to_stored_value(resource, value))
|
387
387
|
|
388
388
|
if value.nil? && required?
|
389
|
-
raise Chef::Exceptions::ValidationFailed, "#{name} is required"
|
389
|
+
raise Chef::Exceptions::ValidationFailed, "#{name} is a required property"
|
390
390
|
else
|
391
391
|
value
|
392
392
|
end
|
@@ -457,7 +457,7 @@ class Chef
|
|
457
457
|
# options.
|
458
458
|
#
|
459
459
|
# @param resource [Chef::Resource] The resource we're validating against
|
460
|
-
# (to provide context for the
|
460
|
+
# (to provide context for the validation).
|
461
461
|
# @param value The value to validate.
|
462
462
|
#
|
463
463
|
# @raise Chef::Exceptions::ValidationFailed If the value is invalid for
|
@@ -514,18 +514,18 @@ class Chef
|
|
514
514
|
# very confusing results.
|
515
515
|
if property_redefines_method?
|
516
516
|
resource_name = declared_in.respond_to?(:resource_name) ? declared_in.resource_name : declared_in
|
517
|
-
raise ArgumentError, "Property `#{name}` of resource `#{resource_name}` overwrites an existing method."
|
517
|
+
raise ArgumentError, "Property `#{name}` of resource `#{resource_name}` overwrites an existing method. A different name should be used for this property."
|
518
518
|
end
|
519
519
|
|
520
520
|
# We prefer this form because the property name won't show up in the
|
521
521
|
# stack trace if you use `define_method`.
|
522
522
|
declared_in.class_eval <<-EOM, __FILE__, __LINE__ + 1
|
523
523
|
def #{name}(value=NOT_PASSED)
|
524
|
-
raise "Property `#{name}` of `\#{self}` was incorrectly passed a block.
|
524
|
+
raise "Property `#{name}` of `\#{self}` was incorrectly passed a block. Possible property-resource collision. To call a resource named `#{name}` either rename the property or else use `declare_resource(:#{name}, ...)`" if block_given?
|
525
525
|
self.class.properties[#{name.inspect}].call(self, value)
|
526
526
|
end
|
527
527
|
def #{name}=(value)
|
528
|
-
raise "Property `#{name}` of `\#{self}` was incorrectly passed a block.
|
528
|
+
raise "Property `#{name}` of `\#{self}` was incorrectly passed a block. Possible property-resource collision. To call a resource named `#{name}` either rename the property or else use `declare_resource(:#{name}, ...)`" if block_given?
|
529
529
|
self.class.properties[#{name.inspect}].set(self, value)
|
530
530
|
end
|
531
531
|
EOM
|
data/lib/chef/provider.rb
CHANGED
@@ -250,7 +250,13 @@ class Chef
|
|
250
250
|
properties_str = if new_resource.sensitive
|
251
251
|
specified_properties.join(", ")
|
252
252
|
else
|
253
|
-
specified_properties.map
|
253
|
+
specified_properties.map do |property|
|
254
|
+
"#{property}=" << if new_resource.class.properties[property].sensitive?
|
255
|
+
"(suppressed sensitive property)"
|
256
|
+
else
|
257
|
+
new_resource.send(property).inspect
|
258
|
+
end
|
259
|
+
end.join(", ")
|
254
260
|
end
|
255
261
|
Chef::Log.debug("Skipping update of #{new_resource}: has not changed any of the specified properties #{properties_str}.")
|
256
262
|
return false
|
@@ -259,7 +265,7 @@ class Chef
|
|
259
265
|
# Print the pretty green text and run the block
|
260
266
|
property_size = modified.map { |p| p.size }.max
|
261
267
|
modified.map! do |p|
|
262
|
-
properties_str = if new_resource.sensitive
|
268
|
+
properties_str = if new_resource.sensitive || new_resource.class.properties[p].sensitive?
|
263
269
|
"(suppressed sensitive property)"
|
264
270
|
else
|
265
271
|
"#{new_resource.send(p).inspect} (was #{current_resource.send(p).inspect})"
|
@@ -274,7 +280,7 @@ class Chef
|
|
274
280
|
property_size = properties.map { |p| p.size }.max
|
275
281
|
created = properties.map do |property|
|
276
282
|
default = " (default value)" unless new_resource.property_is_set?(property)
|
277
|
-
properties_str = if new_resource.sensitive
|
283
|
+
properties_str = if new_resource.sensitive || new_resource.class.properties[property].sensitive?
|
278
284
|
"(suppressed sensitive property)"
|
279
285
|
else
|
280
286
|
new_resource.send(property).inspect
|
@@ -24,7 +24,7 @@ require "chef/log"
|
|
24
24
|
class Chef
|
25
25
|
class Provider
|
26
26
|
class AptPreference < Chef::Provider
|
27
|
-
provides :apt_preference,
|
27
|
+
provides :apt_preference, platform_family: "debian"
|
28
28
|
|
29
29
|
APT_PREFERENCE_DIR = "/etc/apt/preferences.d".freeze
|
30
30
|
|
@@ -27,7 +27,7 @@ class Chef
|
|
27
27
|
class AptRepository < Chef::Provider
|
28
28
|
include Chef::Mixin::ShellOut
|
29
29
|
|
30
|
-
provides :apt_repository,
|
30
|
+
provides :apt_repository, platform_family: "debian"
|
31
31
|
|
32
32
|
LIST_APT_KEYS = "apt-key list".freeze
|
33
33
|
LIST_APT_KEY_FINGERPRINTS = "apt-key adv --list-public-keys --with-fingerprint --with-colons".freeze
|
@@ -23,7 +23,7 @@ require "chef/dsl/declare_resource"
|
|
23
23
|
class Chef
|
24
24
|
class Provider
|
25
25
|
class AptUpdate < Chef::Provider
|
26
|
-
provides :apt_update,
|
26
|
+
provides :apt_update, platform_family: "debian"
|
27
27
|
|
28
28
|
APT_CONF_DIR = "/etc/apt/apt.conf.d"
|
29
29
|
STAMP_DIR = "/var/lib/apt/periodic"
|
data/lib/chef/provider/file.rb
CHANGED
@@ -339,7 +339,7 @@ class Chef
|
|
339
339
|
if tempfile
|
340
340
|
new_resource.verify.each do |v|
|
341
341
|
if ! v.verify(tempfile.path)
|
342
|
-
raise Chef::Exceptions::ValidationFailed.new "Proposed content for #{new_resource.path} failed verification #{v}"
|
342
|
+
raise Chef::Exceptions::ValidationFailed.new "Proposed content for #{new_resource.path} failed verification #{new_resource.sensitive ? '[sensitive]' : v}"
|
343
343
|
end
|
344
344
|
end
|
345
345
|
end
|
@@ -88,8 +88,12 @@ class Chef
|
|
88
88
|
|
89
89
|
def gid_used?(gid)
|
90
90
|
return false unless gid
|
91
|
-
|
92
|
-
|
91
|
+
search_gids = safe_dscl("search", "/Groups", "PrimaryGroupID", gid.to_s)
|
92
|
+
|
93
|
+
# dscl -search should not return anything if the gid doesn't exist,
|
94
|
+
# but on the off-chance that it does, check whether the given gid is
|
95
|
+
# in the output.
|
96
|
+
!!(search_gids =~ /\b#{gid}\b/)
|
93
97
|
end
|
94
98
|
|
95
99
|
def set_gid
|
@@ -23,20 +23,14 @@ require "chef/resource/file"
|
|
23
23
|
require "chef/exceptions"
|
24
24
|
require "erb"
|
25
25
|
|
26
|
-
# Recipe example:
|
27
|
-
#
|
28
|
-
# int = {Hash with your network settings...}
|
29
|
-
#
|
30
|
-
# ifconfig int['ip'] do
|
31
|
-
# ignore_failure true
|
32
|
-
# device int['dev']
|
33
|
-
# mask int['mask']
|
34
|
-
# gateway int['gateway']
|
35
|
-
# mtu int['mtu']
|
36
|
-
# end
|
37
|
-
|
38
26
|
class Chef
|
39
27
|
class Provider
|
28
|
+
# use the ifconfig resource to manage interfaces on *nix systems
|
29
|
+
#
|
30
|
+
# @example set a static ip on eth1
|
31
|
+
# ifconfig '33.33.33.80' do
|
32
|
+
# device 'eth1'
|
33
|
+
# end
|
40
34
|
class Ifconfig < Chef::Provider
|
41
35
|
provides :ifconfig
|
42
36
|
|
@@ -57,30 +51,98 @@ class Chef
|
|
57
51
|
@ifconfig_success = true
|
58
52
|
@interfaces = {}
|
59
53
|
|
60
|
-
@
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
@interfaces[@int_name]["inet_addr"] = (line =~ /inet addr:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /inet addr:/
|
67
|
-
@interfaces[@int_name]["bcast"] = (line =~ /Bcast:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /Bcast:/
|
68
|
-
@interfaces[@int_name]["mask"] = (line =~ /Mask:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /Mask:/
|
69
|
-
@interfaces[@int_name]["mtu"] = (line =~ /MTU:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /MTU:/
|
70
|
-
@interfaces[@int_name]["metric"] = (line =~ /Metric:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /Metric:/
|
54
|
+
@ifconfig_version = nil
|
55
|
+
|
56
|
+
@net_tools_version = shell_out("ifconfig --version")
|
57
|
+
@net_tools_version.stderr.each_line do |line|
|
58
|
+
if line =~ /^net-tools (\d+.\d+)/
|
59
|
+
@ifconfig_version = line.match(/^net-tools (\d+.\d+)/)[1]
|
71
60
|
end
|
61
|
+
end
|
62
|
+
|
63
|
+
if @ifconfig_version.nil?
|
64
|
+
raise "net-tools not found - this is required for ifconfig"
|
65
|
+
elsif @ifconfig_version.to_f < 2.0
|
66
|
+
# Example output for 1.60 is as follows: (sanitized but format intact)
|
67
|
+
# eth0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
|
68
|
+
# inet addr:192.168.1.1 Bcast:192.168.0.1 Mask:255.255.248.0
|
69
|
+
# inet6 addr: 0000::00:0000:0000:0000/64 Scope:Link
|
70
|
+
# UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
|
71
|
+
# RX packets:65158911 errors:0 dropped:0 overruns:0 frame:0
|
72
|
+
# TX packets:41723949 errors:0 dropped:0 overruns:0 carrier:0
|
73
|
+
# collisions:0 txqueuelen:1000
|
74
|
+
# RX bytes:42664658792 (39.7 GiB) TX bytes:52722603938 (49.1 GiB)
|
75
|
+
# Interrupt:30
|
76
|
+
@status = shell_out("ifconfig")
|
77
|
+
@status.stdout.each_line do |line|
|
78
|
+
if !line[0..9].strip.empty?
|
79
|
+
@int_name = line[0..9].strip
|
80
|
+
@interfaces[@int_name] = { "hwaddr" => (line =~ /(HWaddr)/ ? ($') : "nil").strip.chomp }
|
81
|
+
else
|
82
|
+
@interfaces[@int_name]["inet_addr"] = (line =~ /inet addr:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /inet addr:/
|
83
|
+
@interfaces[@int_name]["bcast"] = (line =~ /Bcast:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /Bcast:/
|
84
|
+
@interfaces[@int_name]["mask"] = (line =~ /Mask:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /Mask:/
|
85
|
+
@interfaces[@int_name]["mtu"] = (line =~ /MTU:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /MTU:/
|
86
|
+
@interfaces[@int_name]["metric"] = (line =~ /Metric:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /Metric:/
|
87
|
+
end
|
72
88
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
89
|
+
next unless @interfaces.key?(new_resource.device)
|
90
|
+
@interface = @interfaces.fetch(new_resource.device)
|
91
|
+
|
92
|
+
current_resource.target(new_resource.target)
|
93
|
+
current_resource.device(new_resource.device)
|
94
|
+
current_resource.inet_addr(@interface["inet_addr"])
|
95
|
+
current_resource.hwaddr(@interface["hwaddr"])
|
96
|
+
current_resource.bcast(@interface["bcast"])
|
97
|
+
current_resource.mask(@interface["mask"])
|
98
|
+
current_resource.mtu(@interface["mtu"])
|
99
|
+
current_resource.metric(@interface["metric"])
|
100
|
+
end
|
101
|
+
elsif @ifconfig_version.to_f >= 2.0
|
102
|
+
# Example output for 2.10-alpha is as follows: (sanitized but format intact)
|
103
|
+
# eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
|
104
|
+
# inet 192.168.1.1 netmask 255.255.240.0 broadcast 192.168.0.1
|
105
|
+
# inet6 0000::0000:000:0000:0000 prefixlen 64 scopeid 0x20<link>
|
106
|
+
# ether 00:00:00:00:00:00 txqueuelen 1000 (Ethernet)
|
107
|
+
# RX packets 2383836 bytes 1642630840 (1.5 GiB)
|
108
|
+
# RX errors 0 dropped 0 overruns 0 frame 0
|
109
|
+
# TX packets 1244218 bytes 977339327 (932.0 MiB)
|
110
|
+
# TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
111
|
+
@status = shell_out("ifconfig")
|
112
|
+
@status.stdout.each_line do |line|
|
113
|
+
addr_regex = /^(\w+):?(\d*):?\ .+$/
|
114
|
+
if line =~ addr_regex
|
115
|
+
if line.match(addr_regex).nil?
|
116
|
+
@int_name = "nil"
|
117
|
+
elsif line.match(addr_regex)[2] == ""
|
118
|
+
@int_name = line.match(addr_regex)[1]
|
119
|
+
@interfaces[@int_name] = Hash.new
|
120
|
+
@interfaces[@int_name]["mtu"] = (line =~ /mtu (\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /mtu/ && @interfaces[@int_name]["mtu"].nil?
|
121
|
+
else
|
122
|
+
@int_name = "#{line.match(addr_regex)[1]}:#{line.match(addr_regex)[2]}"
|
123
|
+
@interfaces[@int_name] = Hash.new
|
124
|
+
@interfaces[@int_name]["mtu"] = (line =~ /mtu (\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /mtu/ && @interfaces[@int_name]["mtu"].nil?
|
125
|
+
end
|
126
|
+
else
|
127
|
+
@interfaces[@int_name]["inet_addr"] = (line =~ /inet (\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /inet/ && @interfaces[@int_name]["inet_addr"].nil?
|
128
|
+
@interfaces[@int_name]["bcast"] = (line =~ /broadcast (\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /broadcast/ && @interfaces[@int_name]["bcast"].nil?
|
129
|
+
@interfaces[@int_name]["mask"] = (line =~ /netmask (\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /netmask/ && @interfaces[@int_name]["mask"].nil?
|
130
|
+
@interfaces[@int_name]["hwaddr"] = (line =~ /ether (\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /ether/ && @interfaces[@int_name]["hwaddr"].nil?
|
131
|
+
@interfaces[@int_name]["metric"] = (line =~ /Metric:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /Metric:/ && @interfaces[@int_name]["metric"].nil?
|
132
|
+
end
|
133
|
+
|
134
|
+
next unless @interfaces.key?(new_resource.device)
|
135
|
+
@interface = @interfaces.fetch(new_resource.device)
|
136
|
+
|
137
|
+
current_resource.target(new_resource.target)
|
138
|
+
current_resource.device(new_resource.device)
|
139
|
+
current_resource.inet_addr(@interface["inet_addr"])
|
140
|
+
current_resource.hwaddr(@interface["hwaddr"])
|
141
|
+
current_resource.bcast(@interface["bcast"])
|
142
|
+
current_resource.mask(@interface["mask"])
|
143
|
+
current_resource.mtu(@interface["mtu"])
|
144
|
+
current_resource.metric(@interface["metric"])
|
145
|
+
end
|
84
146
|
end
|
85
147
|
current_resource
|
86
148
|
end
|
data/lib/chef/provider/log.rb
CHANGED
@@ -17,37 +17,27 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
class Chef
|
20
|
-
|
21
20
|
class Provider
|
22
|
-
|
23
21
|
class Log
|
24
|
-
|
25
|
-
# Chef log provider, allows logging to chef's logs from recipes
|
22
|
+
# Chef log provider, allows logging to chef's logs
|
26
23
|
class ChefLog < Chef::Provider
|
27
|
-
|
28
24
|
provides :log
|
29
25
|
|
30
26
|
# No concept of a 'current' resource for logs, this is a no-op
|
31
27
|
#
|
32
|
-
#
|
33
|
-
# true:: Always return true
|
28
|
+
# @return [true] Always returns true
|
34
29
|
def load_current_resource
|
35
30
|
true
|
36
31
|
end
|
37
32
|
|
38
33
|
# Write the log to Chef's log
|
39
34
|
#
|
40
|
-
#
|
41
|
-
# true:: Always return true
|
35
|
+
# @return [true] Always returns true
|
42
36
|
def action_write
|
43
37
|
Chef::Log.send(new_resource.level, new_resource.message)
|
44
38
|
new_resource.updated_by_last_action(true) if Chef::Config[:count_log_resource_updates]
|
45
39
|
end
|
46
|
-
|
47
40
|
end
|
48
|
-
|
49
41
|
end
|
50
|
-
|
51
42
|
end
|
52
|
-
|
53
43
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Bryan McLellan (btm@loftninjas.org)
|
4
4
|
# Matthew Landauer (matthew@openaustralia.org)
|
5
5
|
# Ben Rockwood (benr@joyent.com)
|
6
|
-
# Copyright:: Copyright 2009-
|
6
|
+
# Copyright:: Copyright 2009-2018, Bryan McLellan, Matthew Landauer
|
7
7
|
# License:: Apache License, Version 2.0
|
8
8
|
#
|
9
9
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -30,7 +30,7 @@ class Chef
|
|
30
30
|
attr_accessor :is_virtual_package
|
31
31
|
|
32
32
|
provides :package, platform: "smartos"
|
33
|
-
provides :smartos_package,
|
33
|
+
provides :smartos_package, platform_family: "smartos"
|
34
34
|
|
35
35
|
def load_current_resource
|
36
36
|
Chef::Log.debug("#{new_resource} loading current resource")
|
data/lib/chef/provider/reboot.rb
CHANGED
@@ -21,9 +21,19 @@ require "chef/provider"
|
|
21
21
|
|
22
22
|
class Chef
|
23
23
|
class Provider
|
24
|
+
# Use the reboot resource to reboot a node, a necessary step with some
|
25
|
+
# installations on certain platforms. This resource is supported for use on
|
26
|
+
# the Microsoft Windows, macOS, and Linux platforms.
|
27
|
+
#
|
28
|
+
# In using this resource via notifications, it's important to *only* use
|
29
|
+
# immediate notifications. Delayed notifications produce unintuitive and
|
30
|
+
# probably undesired results.
|
31
|
+
#
|
32
|
+
# @since 12.0.0
|
24
33
|
class Reboot < Chef::Provider
|
25
34
|
provides :reboot
|
26
35
|
|
36
|
+
# @return [void]
|
27
37
|
def load_current_resource
|
28
38
|
@current_resource ||= Chef::Resource::Reboot.new(new_resource.name)
|
29
39
|
current_resource.reason(new_resource.reason)
|
@@ -31,6 +41,8 @@ class Chef
|
|
31
41
|
current_resource
|
32
42
|
end
|
33
43
|
|
44
|
+
# add a reboot to the node run_context
|
45
|
+
# @return [void]
|
34
46
|
def request_reboot
|
35
47
|
node.run_context.request_reboot(
|
36
48
|
:delay_mins => new_resource.delay_mins,
|
@@ -153,7 +153,7 @@ class Chef
|
|
153
153
|
#
|
154
154
|
# FIXME: it should do breadth-first, see CHEF-5080 (please use a performant sort)
|
155
155
|
#
|
156
|
-
# @return Array<String> The list of files to transfer
|
156
|
+
# @return [Array<String>] The list of files to transfer
|
157
157
|
# @api private
|
158
158
|
#
|
159
159
|
def files_to_transfer
|
@@ -61,12 +61,13 @@ class Chef
|
|
61
61
|
|
62
62
|
def fetch
|
63
63
|
http = Chef::HTTP::Simple.new(uri, http_client_opts)
|
64
|
+
tempfile = Chef::FileContentManagement::Tempfile.new(@new_resource).tempfile
|
64
65
|
if want_progress?
|
65
|
-
tempfile = http.streaming_request_with_progress(uri, headers) do |size, total|
|
66
|
+
tempfile = http.streaming_request_with_progress(uri, headers, tempfile) do |size, total|
|
66
67
|
events.resource_update_progress(new_resource, size, total, progress_interval)
|
67
68
|
end
|
68
69
|
else
|
69
|
-
tempfile = http.streaming_request(uri, headers)
|
70
|
+
tempfile = http.streaming_request(uri, headers, tempfile)
|
70
71
|
end
|
71
72
|
if tempfile
|
72
73
|
update_cache_control_data(tempfile, http.last_response)
|
@@ -31,7 +31,7 @@ class Chef
|
|
31
31
|
super
|
32
32
|
@init_command = "/usr/sbin/svcadm"
|
33
33
|
@status_command = "/bin/svcs"
|
34
|
-
@
|
34
|
+
@maintenance = false
|
35
35
|
end
|
36
36
|
|
37
37
|
def load_current_resource
|
@@ -54,6 +54,8 @@ class Chef
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def enable_service
|
57
|
+
# Running service status to update maintenance status to invoke svcadm clear
|
58
|
+
service_status
|
57
59
|
shell_out!(default_init_command, "clear", @new_resource.service_name) if @maintenance
|
58
60
|
enable_flags = [ "-s", @new_resource.options ].flatten.compact
|
59
61
|
shell_out!(default_init_command, "enable", *enable_flags, @new_resource.service_name)
|
@@ -93,6 +95,9 @@ class Chef
|
|
93
95
|
# dependency require_all/error svc:/milestone/multi-user:default (online)
|
94
96
|
# $
|
95
97
|
|
98
|
+
# Set the default value for maintenance
|
99
|
+
@maintenance = false
|
100
|
+
|
96
101
|
# load output into hash
|
97
102
|
status = {}
|
98
103
|
cmd.stdout.each_line do |line|
|
@@ -101,7 +106,6 @@ class Chef
|
|
101
106
|
end
|
102
107
|
|
103
108
|
# check service state
|
104
|
-
@maintenance = false
|
105
109
|
case status["state"]
|
106
110
|
when "online"
|
107
111
|
@current_resource.enabled(true)
|