chef 16.0.275-universal-mingw32 → 16.2.50-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -1
- data/README.md +3 -3
- data/Rakefile +15 -1
- data/chef.gemspec +3 -3
- data/distro/powershell/chef/chef.psm1 +3 -3
- data/distro/templates/powershell/chef/chef.psm1.erb +3 -3
- data/lib/chef/application/apply.rb +2 -2
- data/lib/chef/application/base.rb +1 -1
- data/lib/chef/application/client.rb +1 -1
- data/lib/chef/application/exit_code.rb +2 -2
- data/lib/chef/application/windows_service_manager.rb +1 -1
- data/lib/chef/chef_fs/chef_fs_data_store.rb +3 -3
- data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/acls_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
- data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +1 -1
- data/lib/chef/chef_fs/path_utils.rb +4 -4
- data/lib/chef/cookbook/chefignore.rb +1 -1
- data/lib/chef/cookbook/file_system_file_vendor.rb +1 -1
- data/lib/chef/cookbook/metadata.rb +2 -2
- data/lib/chef/cookbook_loader.rb +1 -1
- data/lib/chef/cookbook_manifest.rb +1 -1
- data/lib/chef/cookbook_site_streaming_uploader.rb +1 -1
- data/lib/chef/cookbook_version.rb +7 -7
- data/lib/chef/data_bag.rb +4 -4
- data/lib/chef/data_collector.rb +1 -1
- data/lib/chef/data_collector/error_handlers.rb +1 -1
- data/lib/chef/decorator/lazy_array.rb +2 -2
- data/lib/chef/deprecated.rb +5 -1
- data/lib/chef/digester.rb +4 -4
- data/lib/chef/dsl/declare_resource.rb +1 -1
- data/lib/chef/dsl/platform_introspection.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/encryptor.rb +1 -1
- data/lib/chef/file_access_control.rb +1 -1
- data/lib/chef/formatters/base.rb +1 -1
- data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +1 -1
- data/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb +2 -2
- data/lib/chef/formatters/error_inspectors/registration_error_inspector.rb +7 -7
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +3 -3
- data/lib/chef/http.rb +18 -3
- data/lib/chef/http/decompressor.rb +1 -1
- data/lib/chef/http/http_request.rb +1 -1
- data/lib/chef/http/json_output.rb +1 -1
- data/lib/chef/http/ssl_policies.rb +18 -0
- data/lib/chef/json_compat.rb +1 -1
- data/lib/chef/key.rb +1 -1
- data/lib/chef/knife.rb +2 -2
- data/lib/chef/knife/bootstrap.rb +13 -16
- data/lib/chef/knife/bootstrap/chef_vault_handler.rb +1 -1
- data/lib/chef/knife/bootstrap/client_builder.rb +1 -1
- data/lib/chef/knife/bootstrap/templates/chef-full.erb +9 -9
- data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +3 -1
- data/lib/chef/knife/client_bulk_delete.rb +1 -1
- data/lib/chef/knife/config_get.rb +1 -1
- data/lib/chef/knife/config_use_profile.rb +15 -5
- data/lib/chef/knife/cookbook_delete.rb +1 -1
- data/lib/chef/knife/core/cookbook_scm_repo.rb +1 -1
- data/lib/chef/knife/core/hashed_command_loader.rb +1 -1
- data/lib/chef/knife/core/node_presenter.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +1 -1
- data/lib/chef/knife/core/subcommand_loader.rb +1 -1
- data/lib/chef/knife/core/windows_bootstrap_context.rb +18 -3
- data/lib/chef/knife/data_bag_create.rb +1 -1
- data/lib/chef/knife/key_create_base.rb +1 -1
- data/lib/chef/knife/key_edit_base.rb +1 -1
- data/lib/chef/knife/node_bulk_delete.rb +1 -1
- data/lib/chef/knife/node_run_list_remove.rb +1 -1
- data/lib/chef/knife/role_bulk_delete.rb +1 -1
- data/lib/chef/knife/ssh.rb +2 -2
- data/lib/chef/knife/supermarket_share.rb +1 -1
- data/lib/chef/knife/supermarket_unshare.rb +1 -1
- data/lib/chef/knife/{user_invite_recind.rb → user_invite_rescind.rb} +6 -6
- data/lib/chef/log.rb +1 -1
- data/lib/chef/mixin/api_version_request_handling.rb +1 -1
- data/lib/chef/mixin/checksum.rb +0 -1
- data/lib/chef/mixin/create_path.rb +8 -8
- data/lib/chef/mixin/openssl_helper.rb +4 -4
- data/lib/chef/mixin/properties.rb +4 -2
- data/lib/chef/mixin/securable.rb +2 -2
- data/lib/chef/mixin/shell_out.rb +1 -1
- data/lib/chef/node/attribute.rb +2 -2
- data/lib/chef/node/immutable_collections.rb +1 -1
- data/lib/chef/node/mixin/deep_merge_cache.rb +7 -7
- data/lib/chef/policy_builder/policyfile.rb +1 -1
- data/lib/chef/powershell.rb +1 -1
- data/lib/chef/property.rb +2 -2
- data/lib/chef/provider.rb +3 -3
- data/lib/chef/provider/batch.rb +3 -10
- data/lib/chef/provider/cron.rb +2 -14
- data/lib/chef/provider/directory.rb +1 -1
- data/lib/chef/provider/execute.rb +2 -1
- data/lib/chef/provider/file.rb +1 -1
- data/lib/chef/provider/group/dscl.rb +2 -2
- data/lib/chef/provider/group/windows.rb +1 -1
- data/lib/chef/provider/ifconfig.rb +7 -7
- data/lib/chef/provider/launchd.rb +28 -32
- data/lib/chef/provider/mount/aix.rb +1 -1
- data/lib/chef/provider/mount/windows.rb +2 -2
- data/lib/chef/provider/noop.rb +1 -1
- data/lib/chef/provider/package/cab.rb +1 -1
- data/lib/chef/provider/package/chocolatey.rb +1 -1
- data/lib/chef/provider/package/dpkg.rb +1 -1
- data/lib/chef/provider/package/openbsd.rb +1 -1
- data/lib/chef/provider/package/portage.rb +3 -2
- data/lib/chef/provider/package/powershell.rb +6 -2
- data/lib/chef/provider/package/rubygems.rb +3 -3
- data/lib/chef/provider/package/snap.rb +96 -27
- data/lib/chef/provider/package/windows.rb +2 -2
- data/lib/chef/provider/package/windows/msi.rb +3 -3
- data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +1 -1
- data/lib/chef/provider/package/yum.rb +1 -1
- data/lib/chef/provider/package/yum/yum_cache.rb +1 -1
- data/lib/chef/provider/powershell_script.rb +11 -15
- data/lib/chef/provider/remote_directory.rb +2 -2
- data/lib/chef/provider/remote_file/http.rb +4 -1
- data/lib/chef/provider/script.rb +4 -75
- data/lib/chef/provider/service/arch.rb +2 -2
- data/lib/chef/provider/service/debian.rb +2 -2
- data/lib/chef/provider/service/macosx.rb +13 -2
- data/lib/chef/provider/service/openbsd.rb +4 -4
- data/lib/chef/provider/service/redhat.rb +1 -1
- data/lib/chef/provider/service/simple.rb +3 -3
- data/lib/chef/provider/service/upstart.rb +1 -1
- data/lib/chef/provider/service/windows.rb +1 -1
- data/lib/chef/provider/subversion.rb +2 -2
- data/lib/chef/provider/user/aix.rb +1 -1
- data/lib/chef/provider/user/dscl.rb +6 -6
- data/lib/chef/provider/user/linux.rb +3 -3
- data/lib/chef/provider/user/mac.rb +15 -11
- data/lib/chef/provider/windows_script.rb +87 -25
- data/lib/chef/provider/windows_task.rb +5 -3
- data/lib/chef/provider/zypper_repository.rb +30 -10
- data/lib/chef/resource.rb +25 -14
- data/lib/chef/resource/alternatives.rb +1 -1
- data/lib/chef/resource/apt_package.rb +1 -1
- data/lib/chef/resource/archive_file.rb +28 -8
- data/lib/chef/resource/bash.rb +0 -1
- data/lib/chef/resource/batch.rb +4 -2
- data/lib/chef/resource/chef_client_scheduled_task.rb +13 -1
- data/lib/chef/resource/chef_gem.rb +57 -21
- data/lib/chef/resource/chef_handler.rb +2 -2
- data/lib/chef/resource/chef_vault_secret.rb +1 -1
- data/lib/chef/resource/cron/_cron_shared.rb +98 -0
- data/lib/chef/resource/cron/cron.rb +46 -0
- data/lib/chef/resource/{cron_d.rb → cron/cron_d.rb} +7 -87
- data/lib/chef/resource/cron_access.rb +11 -3
- data/lib/chef/resource/csh.rb +0 -1
- data/lib/chef/resource/dmg_package.rb +1 -1
- data/lib/chef/resource/execute.rb +478 -8
- data/lib/chef/resource/file.rb +10 -8
- data/lib/chef/resource/freebsd_package.rb +1 -1
- data/lib/chef/resource/gem_package.rb +35 -2
- data/lib/chef/resource/helpers/cron_validations.rb +6 -3
- data/lib/chef/resource/homebrew_package.rb +30 -1
- data/lib/chef/resource/homebrew_update.rb +107 -0
- data/lib/chef/resource/hostname.rb +7 -20
- data/lib/chef/resource/kernel_module.rb +14 -1
- data/lib/chef/resource/launchd.rb +4 -4
- data/lib/chef/resource/locale.rb +3 -3
- data/lib/chef/resource/macos_userdefaults.rb +14 -9
- data/lib/chef/resource/mount.rb +1 -1
- data/lib/chef/resource/msu_package.rb +1 -1
- data/lib/chef/resource/perl.rb +0 -1
- data/lib/chef/resource/plist.rb +23 -4
- data/lib/chef/resource/powershell_script.rb +4 -2
- data/lib/chef/resource/python.rb +0 -1
- data/lib/chef/resource/remote_file.rb +26 -10
- data/lib/chef/resource/ruby.rb +0 -1
- data/lib/chef/resource/scm/git.rb +1 -1
- data/lib/chef/resource/ssh_known_hosts_entry.rb +15 -0
- data/lib/chef/resource/sudo.rb +29 -2
- data/lib/chef/resource/swap_file.rb +17 -0
- data/lib/chef/resource/template.rb +1 -1
- data/lib/chef/resource/timezone.rb +15 -0
- data/lib/chef/resource/windows_ad_join.rb +30 -1
- data/lib/chef/resource/windows_audit_policy.rb +227 -0
- data/lib/chef/resource/windows_auto_run.rb +11 -0
- data/lib/chef/resource/windows_certificate.rb +27 -1
- data/lib/chef/resource/windows_dfs_server.rb +1 -1
- data/lib/chef/resource/windows_firewall_rule.rb +2 -2
- data/lib/chef/resource/windows_font.rb +3 -3
- data/lib/chef/resource/windows_package.rb +3 -3
- data/lib/chef/resource/windows_pagefile.rb +2 -2
- data/lib/chef/resource/windows_printer.rb +1 -1
- data/lib/chef/resource/windows_script.rb +2 -16
- data/lib/chef/resource/windows_security_policy.rb +47 -16
- data/lib/chef/resource/windows_share.rb +2 -2
- data/lib/chef/resource/windows_shortcut.rb +1 -2
- data/lib/chef/resource/windows_task.rb +21 -21
- data/lib/chef/resource/windows_user_privilege.rb +45 -3
- data/lib/chef/resource/yum_repository.rb +9 -9
- data/lib/chef/resource_inspector.rb +4 -3
- data/lib/chef/resources.rb +4 -2
- data/lib/chef/run_context/cookbook_compiler.rb +1 -1
- data/lib/chef/search/query.rb +1 -1
- data/lib/chef/shell/ext.rb +1 -1
- data/lib/chef/util/diff.rb +2 -2
- data/lib/chef/util/dsc/lcm_output_parser.rb +3 -3
- data/lib/chef/util/windows/net_user.rb +1 -1
- data/lib/chef/util/windows/volume.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api.rb +2 -2
- data/lib/chef/win32/api/error.rb +3 -1
- data/lib/chef/win32/api/file.rb +18 -18
- data/lib/chef/win32/api/net.rb +1 -0
- data/lib/chef/win32/file.rb +1 -1
- data/lib/chef/win32/mutex.rb +1 -1
- data/lib/chef/win32/net.rb +1 -0
- data/lib/chef/win32/process.rb +2 -2
- data/lib/chef/win32/registry.rb +2 -2
- data/lib/chef/win32/security.rb +1 -1
- data/lib/chef/win32/security/sid.rb +4 -4
- data/spec/data/lwrp/providers/buck_passer.rb +1 -1
- data/spec/data/lwrp/providers/buck_passer_2.rb +1 -1
- data/spec/data/lwrp/providers/embedded_resource_accesses_providers_scope.rb +1 -1
- data/spec/functional/resource/cron_spec.rb +10 -0
- data/spec/functional/resource/dnf_package_spec.rb +2 -2
- data/spec/functional/resource/git_spec.rb +6 -6
- data/spec/functional/resource/launchd_spec.rb +232 -0
- data/spec/functional/resource/remote_file_spec.rb +2 -2
- data/spec/functional/resource/user/dscl_spec.rb +1 -1
- data/spec/functional/resource/user/mac_user_spec.rb +1 -1
- data/spec/functional/resource/windows_task_spec.rb +12 -12
- data/spec/integration/knife/config_use_profile_spec.rb +55 -2
- data/spec/support/chef_helpers.rb +1 -1
- data/spec/support/platform_helpers.rb +1 -1
- data/spec/support/platforms/win32/spec_service.rb +1 -1
- data/spec/support/shared/functional/execute_resource.rb +1 -1
- data/spec/support/shared/functional/file_resource.rb +1 -1
- data/spec/support/shared/functional/windows_script.rb +1 -1
- data/spec/support/shared/unit/execute_resource.rb +1 -1
- data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +4 -4
- data/spec/unit/application_spec.rb +7 -0
- data/spec/unit/data_bag_spec.rb +1 -1
- data/spec/unit/http/ssl_policies_spec.rb +20 -0
- data/spec/unit/knife/bootstrap_spec.rb +2 -2
- data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +7 -1
- data/spec/unit/knife/role_env_run_list_add_spec.rb +6 -6
- data/spec/unit/knife/role_env_run_list_clear_spec.rb +4 -4
- data/spec/unit/knife/role_env_run_list_remove_spec.rb +4 -4
- data/spec/unit/knife/role_env_run_list_replace_spec.rb +4 -4
- data/spec/unit/knife/role_env_run_list_set_spec.rb +4 -4
- data/spec/unit/knife/role_run_list_add_spec.rb +6 -6
- data/spec/unit/knife/role_run_list_clear_spec.rb +4 -4
- data/spec/unit/knife/role_run_list_remove_spec.rb +4 -4
- data/spec/unit/knife/role_run_list_replace_spec.rb +4 -4
- data/spec/unit/knife/role_run_list_set_spec.rb +4 -4
- data/spec/unit/mixin/openssl_helper_spec.rb +4 -4
- data/spec/unit/mixin/user_context_spec.rb +1 -9
- data/spec/unit/node/attribute_spec.rb +1 -1
- data/spec/unit/property_spec.rb +1 -1
- data/spec/unit/provider/batch_spec.rb +130 -0
- data/spec/unit/provider/cron_spec.rb +9 -49
- data/spec/unit/provider/git_spec.rb +3 -3
- data/spec/unit/provider/group/groupadd_spec.rb +1 -1
- data/spec/unit/provider/launchd_spec.rb +8 -50
- data/spec/unit/provider/osx_profile_spec.rb +2 -2
- data/spec/unit/provider/package/msu_spec.rb +3 -3
- data/spec/unit/provider/package/portage_spec.rb +2 -2
- data/spec/unit/provider/package/powershell_spec.rb +96 -87
- data/spec/unit/provider/package/snap_spec.rb +1 -1
- data/spec/unit/provider/powershell_script_spec.rb +3 -45
- data/spec/unit/provider/script_spec.rb +20 -110
- data/spec/unit/provider/service/gentoo_service_spec.rb +1 -1
- data/spec/unit/provider/zypper_repository_spec.rb +60 -10
- data/spec/unit/provider_resolver_spec.rb +9 -9
- data/spec/unit/resource/archive_file_spec.rb +11 -2
- data/spec/unit/resource/chef_client_scheduled_task_spec.rb +17 -7
- data/spec/unit/resource/cron_spec.rb +2 -2
- data/spec/unit/resource/helpers/cron_validations_spec.rb +5 -1
- data/spec/unit/resource/homebrew_update_spec.rb +30 -0
- data/spec/unit/resource/powershell_script_spec.rb +10 -15
- data/spec/unit/resource/timezone_spec.rb +1 -1
- data/spec/unit/resource/windows_audit_policy_spec.rb +64 -0
- data/spec/unit/resource/windows_dns_record_spec.rb +3 -3
- data/spec/unit/resource/windows_dns_zone_spec.rb +2 -2
- data/spec/unit/resource/windows_package_spec.rb +10 -0
- data/spec/unit/resource/windows_task_spec.rb +1 -1
- data/spec/unit/resource/windows_uac_spec.rb +2 -2
- data/spec/unit/resource/yum_repository_spec.rb +21 -21
- data/spec/unit/resource_spec.rb +67 -1
- data/spec/unit/run_context_spec.rb +1 -1
- data/spec/unit/util/dsc/configuration_generator_spec.rb +1 -1
- data/spec/unit/util/threaded_job_queue_spec.rb +9 -0
- data/spec/unit/win32/registry_spec.rb +1 -1
- metadata +24 -23
- data/lib/chef/resource/cron.rb +0 -157
data/lib/chef/resource/file.rb
CHANGED
@@ -56,28 +56,30 @@ class Chef
|
|
56
56
|
allowed_actions :create, :delete, :touch, :create_if_missing
|
57
57
|
|
58
58
|
property :path, String, name_property: true,
|
59
|
-
|
59
|
+
description: "The full path to the file, including the file name and its extension. For example: /files/file.txt. Default value: the name of the resource block. Microsoft Windows: A path that begins with a forward slash (/) will point to the root of the current working directory of the #{Chef::Dist::CLIENT} process. This path can vary from system to system. Therefore, using a path that begins with a forward slash (/) is not recommended."
|
60
60
|
|
61
61
|
property :atomic_update, [ TrueClass, FalseClass ], desired_state: false, default: lazy { docker? && special_docker_files?(path) ? false : Chef::Config[:file_atomic_update] },
|
62
|
-
|
63
|
-
|
62
|
+
default_description: "False if modifying /etc/hosts, /etc/hostname, or /etc/resolv.conf within Docker containers. Otherwise default to the client.rb 'file_atomic_update' config value.",
|
63
|
+
description: "Perform atomic file updates on a per-resource basis. Set to true for atomic file updates. Set to false for non-atomic file updates. This setting overrides `file_atomic_update`, which is a global setting found in the `client.rb` file."
|
64
64
|
|
65
65
|
property :backup, [ Integer, FalseClass ], desired_state: false, default: 5,
|
66
|
-
|
66
|
+
description: "The number of backups to be kept in `/var/chef/backup` (for UNIX- and Linux-based platforms) or `C:/chef/backup` (for the Microsoft Windows platform). Set to `false` to prevent backups from being kept."
|
67
67
|
|
68
|
-
property :checksum, [
|
68
|
+
property :checksum, [ String, nil ],
|
69
|
+
regex: /^\h{64}$/,
|
70
|
+
coerce: lambda { |s| s.is_a?(String) ? s.downcase : s },
|
69
71
|
description: "The SHA-256 checksum of the file. Use to ensure that a specific file is used. If the checksum does not match, the file is not used."
|
70
72
|
|
71
73
|
property :content, [ String, nil ], desired_state: false,
|
72
|
-
|
74
|
+
description: "A string that is written to the file. The contents of this property replace any previous content when this property has something other than the default value. The default behavior will not modify content."
|
73
75
|
|
74
76
|
property :diff, [ String, nil ], desired_state: false, skip_docs: true
|
75
77
|
|
76
78
|
property :force_unlink, [ TrueClass, FalseClass ], desired_state: false, default: false,
|
77
|
-
|
79
|
+
description: "How #{Chef::Dist::PRODUCT} handles certain situations when the target file turns out not to be a file. For example, when a target file is actually a symlink. Set to `true` for #{Chef::Dist::PRODUCT} to delete the non-file target and replace it with the specified file. Set to `false` for #{Chef::Dist::PRODUCT} to raise an error."
|
78
80
|
|
79
81
|
property :manage_symlink_source, [ TrueClass, FalseClass ], desired_state: false,
|
80
|
-
|
82
|
+
description: "Change the behavior of the file resource if it is pointed at a symlink. When this value is set to true, #{Chef::Dist::PRODUCT} will manage the symlink's permissions or will replace the symlink with a normal file if the resource has content. When this value is set to false, #{Chef::Dist::PRODUCT} will follow the symlink and will manage the permissions and content of symlink's target file. The default behavior is true but emits a warning that the default value will be changed to false in a future version; setting this explicitly to true or false suppresses this warning."
|
81
83
|
|
82
84
|
property :verifications, Array, default: lazy { [] }
|
83
85
|
|
@@ -25,7 +25,40 @@ class Chef
|
|
25
25
|
unified_mode true
|
26
26
|
provides :gem_package
|
27
27
|
|
28
|
-
description
|
28
|
+
description <<~DESC
|
29
|
+
Use the **gem_package** resource to manage gem packages that are only included in recipes.
|
30
|
+
When a gem is installed from a local file, it must be added to the node using the **remote_file** or **cookbook_file** resources.
|
31
|
+
|
32
|
+
Note: The **gem_package** resource must be specified as `gem_package` and cannot be shortened to `package` in a recipe.
|
33
|
+
|
34
|
+
Warning: The **chef_gem** and **gem_package** resources are both used to install Ruby gems. For any machine on which #{Chef::Dist::PRODUCT} is
|
35
|
+
installed, there are two instances of Ruby. One is the standard, system-wide instance of Ruby and the other is a dedicated instance that is
|
36
|
+
available only to #{Chef::Dist::PRODUCT}.
|
37
|
+
Use the **chef_gem** resource to install gems into the instance of Ruby that is dedicated to #{Chef::Dist::PRODUCT}.
|
38
|
+
Use the **gem_package** resource to install all other gems (i.e. install gems system-wide).
|
39
|
+
DESC
|
40
|
+
|
41
|
+
examples <<~EXAMPLES
|
42
|
+
The following examples demonstrate various approaches for using the **gem_package** resource in recipes:
|
43
|
+
|
44
|
+
**Install a gem file from the local file system**
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
gem_package 'right_aws' do
|
48
|
+
source '/tmp/right_aws-1.11.0.gem'
|
49
|
+
action :install
|
50
|
+
end
|
51
|
+
```
|
52
|
+
|
53
|
+
**Use the `ignore_failure` common attribute**
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
gem_package 'syntax' do
|
57
|
+
action :install
|
58
|
+
ignore_failure true
|
59
|
+
end
|
60
|
+
```
|
61
|
+
EXAMPLES
|
29
62
|
|
30
63
|
property :package_name, String,
|
31
64
|
description: "An optional property to set the package name if it differs from the resource block's name.",
|
@@ -53,7 +86,7 @@ class Chef
|
|
53
86
|
default: lazy { Chef::Config[:clear_gem_sources] }, desired_state: false
|
54
87
|
|
55
88
|
property :gem_binary, String, desired_state: false,
|
56
|
-
description: "The path of a gem binary to use for the installation. By default, the same version of Ruby that is used by #{Chef::Dist::PRODUCT} will be
|
89
|
+
description: "The path of a gem binary to use for the installation. By default, the same version of Ruby that is used by #{Chef::Dist::PRODUCT} will be used."
|
57
90
|
|
58
91
|
property :include_default_source, [ TrueClass, FalseClass, nil ],
|
59
92
|
description: "Set to `false` to not include `Chef::Config[:rubygems_url]` in the sources.",
|
@@ -35,7 +35,7 @@ class Chef
|
|
35
35
|
# Lists of individual values, ranges, and step values all share the validity range for type
|
36
36
|
spec.split(%r{\/|-|,}).each do |x|
|
37
37
|
next if x == "*"
|
38
|
-
return false unless
|
38
|
+
return false unless /^\d+$/.match?(x)
|
39
39
|
|
40
40
|
x = x.to_i
|
41
41
|
return false unless x >= min && x <= max
|
@@ -62,13 +62,16 @@ class Chef
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
# validate the provided day of the week is sun-sat, 0-7, or *
|
65
|
+
# validate the provided day of the week is sun-sat, sunday-saturday, 0-7, or *
|
66
|
+
# Added crontab param to check cron resource
|
66
67
|
# @param spec the value to validate
|
67
68
|
# @return [Boolean] valid or not?
|
68
69
|
def validate_dow(spec)
|
70
|
+
spec = spec.to_s
|
69
71
|
spec == "*" ||
|
70
72
|
validate_numeric(spec, 0, 7) ||
|
71
|
-
%w{sun mon tue wed thu fri sat}.include?(
|
73
|
+
%w{sun mon tue wed thu fri sat}.include?(spec.downcase) ||
|
74
|
+
%w{sunday monday tuesday wednesday thursday friday saturday}.include?(spec.downcase)
|
72
75
|
end
|
73
76
|
|
74
77
|
# validate the day of the month is 1-31
|
@@ -29,8 +29,37 @@ class Chef
|
|
29
29
|
provides :homebrew_package
|
30
30
|
provides :package, os: "darwin"
|
31
31
|
|
32
|
-
description "Use the **homebrew_package** resource to manage packages for the macOS platform."
|
32
|
+
description "Use the **homebrew_package** resource to manage packages for the macOS platform. Note: Starting with #{Chef::Dist::PRODUCT} 16 the homebrew resource now accepts an array of packages for installing multiple packages at once."
|
33
33
|
introduced "12.0"
|
34
|
+
examples <<~DOC
|
35
|
+
**Install a package**:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
homebrew_package 'git'
|
39
|
+
```
|
40
|
+
|
41
|
+
**Install multiple packages at once**:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
homebrew_package %w(git fish ruby)
|
45
|
+
```
|
46
|
+
|
47
|
+
**Specify the Homebrew user with a UUID**
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
homebrew_package 'git' do
|
51
|
+
homebrew_user 1001
|
52
|
+
end
|
53
|
+
```
|
54
|
+
|
55
|
+
**Specify the Homebrew user with a string**:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
homebrew_package 'vim' do
|
59
|
+
homebrew_user 'user1'
|
60
|
+
end
|
61
|
+
```
|
62
|
+
DOC
|
34
63
|
|
35
64
|
property :homebrew_user, [ String, Integer ],
|
36
65
|
description: "The name or uid of the Homebrew owner to be used by #{Chef::Dist::PRODUCT} when executing a command."
|
@@ -0,0 +1,107 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Joshua Timberman (<jtimberman@chef.io>)
|
3
|
+
# Author:: Dan Webb (<dan@webb-agile-solutions.ltd>)
|
4
|
+
#
|
5
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
6
|
+
# Copyright:: Copyright (c) Webb Agile Solutions Ltd.
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
|
21
|
+
require_relative "../resource"
|
22
|
+
require_relative "../dist"
|
23
|
+
|
24
|
+
class Chef
|
25
|
+
class Resource
|
26
|
+
class HomebrewUpdate < Chef::Resource
|
27
|
+
unified_mode true
|
28
|
+
|
29
|
+
provides(:homebrew_update) { true }
|
30
|
+
|
31
|
+
description "Use the **homebrew_update** resource to manage Homebrew repository updates on macOS."
|
32
|
+
introduced "16.2"
|
33
|
+
examples <<~DOC
|
34
|
+
**Update the homebrew repository data at a specified interval**:
|
35
|
+
```ruby
|
36
|
+
homebrew_update 'all platforms' do
|
37
|
+
frequency 86400
|
38
|
+
action :periodic
|
39
|
+
end
|
40
|
+
```
|
41
|
+
**Update the Homebrew repository at the start of a #{Chef::Dist::PRODUCT} run**:
|
42
|
+
```ruby
|
43
|
+
homebrew_update 'update'
|
44
|
+
```
|
45
|
+
DOC
|
46
|
+
|
47
|
+
# allow bare homebrew_update with no name
|
48
|
+
property :name, String, default: ""
|
49
|
+
|
50
|
+
property :frequency, Integer,
|
51
|
+
description: "Determines how frequently (in seconds) Homebrew updates are made. Use this property when the `:periodic` action is specified.",
|
52
|
+
default: 86_400
|
53
|
+
|
54
|
+
default_action :periodic
|
55
|
+
allowed_actions :update, :periodic
|
56
|
+
|
57
|
+
action_class do
|
58
|
+
BREW_STAMP_DIR = "/var/lib/homebrew/periodic".freeze
|
59
|
+
BREW_STAMP = "#{BREW_STAMP_DIR}/update-success-stamp".freeze
|
60
|
+
|
61
|
+
# Determines whether we need to run `homebrew update`
|
62
|
+
#
|
63
|
+
# @return [Boolean]
|
64
|
+
def brew_up_to_date?
|
65
|
+
::File.exist?("#{BREW_STAMP}") &&
|
66
|
+
::File.mtime("#{BREW_STAMP}") > Time.now - new_resource.frequency
|
67
|
+
end
|
68
|
+
|
69
|
+
def do_update
|
70
|
+
directory BREW_STAMP_DIR do
|
71
|
+
recursive true
|
72
|
+
end
|
73
|
+
|
74
|
+
file "#{BREW_STAMP}" do
|
75
|
+
content "BREW::Update::Post-Invoke-Success\n"
|
76
|
+
action :create_if_missing
|
77
|
+
end
|
78
|
+
|
79
|
+
execute "brew update" do
|
80
|
+
command %w{brew update}
|
81
|
+
default_env true
|
82
|
+
user Homebrew.owner
|
83
|
+
notifies :touch, "file[#{BREW_STAMP}]", :immediately
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
action :periodic do
|
89
|
+
return unless mac_os_x?
|
90
|
+
|
91
|
+
unless brew_up_to_date?
|
92
|
+
converge_by "update new lists of packages" do
|
93
|
+
do_update
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
action :update do
|
99
|
+
return unless mac_os_x?
|
100
|
+
|
101
|
+
converge_by "force update new lists of packages" do
|
102
|
+
do_update
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -1,4 +1,7 @@
|
|
1
1
|
#
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
2
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
3
6
|
# you may not use this file except in compliance with the License.
|
4
7
|
# You may obtain a copy of the License at
|
@@ -13,6 +16,7 @@
|
|
13
16
|
#
|
14
17
|
|
15
18
|
require_relative "../resource"
|
19
|
+
require_relative "../dist"
|
16
20
|
|
17
21
|
class Chef
|
18
22
|
class Resource
|
@@ -149,7 +153,7 @@ class Chef
|
|
149
153
|
# this must come before other methods like /etc/hostname and /etc/sysconfig/network
|
150
154
|
declare_resource(:execute, "hostnamectl set-hostname #{new_resource.hostname}") do
|
151
155
|
notifies :reload, "ohai[reload hostname]"
|
152
|
-
not_if { shell_out!("hostnamectl status",
|
156
|
+
not_if { shell_out!("hostnamectl status", returns: [0, 1]).stdout =~ /Static hostname:\s*#{new_resource.hostname}\s*$/ }
|
153
157
|
end
|
154
158
|
when ::File.exist?("/etc/hostname")
|
155
159
|
# debian family uses /etc/hostname
|
@@ -199,24 +203,7 @@ class Chef
|
|
199
203
|
group node["root_group"]
|
200
204
|
mode "0644"
|
201
205
|
end
|
202
|
-
when ::File.exist?("/
|
203
|
-
# Solaris <= 5.10 systems prior to svccfg taking over this functionality (must come before svccfg handling)
|
204
|
-
declare_resource(:file, "/etc/nodename") do
|
205
|
-
content "#{new_resource.hostname}\n"
|
206
|
-
owner "root"
|
207
|
-
group node["root_group"]
|
208
|
-
mode "0644"
|
209
|
-
end
|
210
|
-
# Solaris also has /etc/inet/hosts (copypasta alert)
|
211
|
-
unless new_resource.ipaddress.nil?
|
212
|
-
newline = "#{new_resource.ipaddress} #{new_resource.hostname}"
|
213
|
-
newline << " #{new_resource.aliases.join(" ")}" if new_resource.aliases && !new_resource.aliases.empty?
|
214
|
-
newline << " #{new_resource.hostname[/[^\.]*/]}"
|
215
|
-
r = append_replacing_matching_lines("/etc/inet/hosts", /^#{new_resource.ipaddress}\s+|\s+#{new_resource.hostname}\s+/, newline)
|
216
|
-
r.notifies :reload, "ohai[reload hostname]"
|
217
|
-
end
|
218
|
-
when ::File.exist?("/usr/sbin/svccfg")
|
219
|
-
# Solaris >= 5.11 systems using svccfg (must come after /etc/nodename handling)
|
206
|
+
when ::File.exist?("/usr/sbin/svccfg") # solaris 5.11
|
220
207
|
declare_resource(:execute, "svccfg -s system/identity:node setprop config/nodename=\'#{new_resource.hostname}\'") do
|
221
208
|
notifies :run, "execute[svcadm refresh]", :immediately
|
222
209
|
notifies :run, "execute[svcadm restart]", :immediately
|
@@ -262,7 +249,7 @@ class Chef
|
|
262
249
|
|
263
250
|
# reboot because $windows
|
264
251
|
declare_resource(:reboot, "setting hostname") do
|
265
|
-
reason "
|
252
|
+
reason "#{Chef::Dist::PRODUCT} updated system hostname"
|
266
253
|
action :nothing
|
267
254
|
only_if { new_resource.windows_reboot }
|
268
255
|
end
|
@@ -19,11 +19,14 @@ class Chef
|
|
19
19
|
introduced "14.3"
|
20
20
|
examples <<~DOC
|
21
21
|
Install and load a kernel module, and ensure it loads on reboot.
|
22
|
+
|
22
23
|
```ruby
|
23
24
|
kernel_module 'loop'
|
24
25
|
```
|
26
|
+
|
25
27
|
Install and load a kernel with a specific set of options, and ensure it loads on reboot. Consult kernel module
|
26
28
|
documentation for specific options that are supported.
|
29
|
+
|
27
30
|
```ruby
|
28
31
|
kernel_module 'loop' do
|
29
32
|
options [
|
@@ -32,31 +35,41 @@ class Chef
|
|
32
35
|
]
|
33
36
|
end
|
34
37
|
```
|
38
|
+
|
35
39
|
Load a kernel module.
|
40
|
+
|
36
41
|
```ruby
|
37
42
|
kernel_module 'loop' do
|
38
43
|
action :load
|
39
44
|
end
|
40
45
|
```
|
41
|
-
|
46
|
+
|
47
|
+
Unload a kernel module and remove module config, so it doesn't load on reboot.
|
48
|
+
|
42
49
|
```ruby
|
43
50
|
kernel_module 'loop' do
|
44
51
|
action :uninstall
|
45
52
|
end
|
46
53
|
```
|
54
|
+
|
47
55
|
Unload kernel module.
|
56
|
+
|
48
57
|
```ruby
|
49
58
|
kernel_module 'loop' do
|
50
59
|
action :unload
|
51
60
|
end
|
52
61
|
```
|
62
|
+
|
53
63
|
Blacklist a module from loading.
|
64
|
+
|
54
65
|
```ruby
|
55
66
|
kernel_module 'loop' do
|
56
67
|
action :blacklist
|
57
68
|
end
|
58
69
|
```
|
70
|
+
|
59
71
|
Disable a kernel module.
|
72
|
+
|
60
73
|
```ruby
|
61
74
|
kernel_module 'loop' do
|
62
75
|
action :disable
|
@@ -76,20 +76,20 @@ class Chef
|
|
76
76
|
property :start_calendar_interval, [Hash, Array],
|
77
77
|
description: "A Hash (similar to crontab) that defines the calendar frequency at which a job is started or an Array.",
|
78
78
|
coerce: proc { |type|
|
79
|
-
|
79
|
+
# Coerce into an array of hashes to make validation easier
|
80
80
|
array = if type.is_a?(Array)
|
81
81
|
type
|
82
82
|
else
|
83
83
|
[type]
|
84
84
|
end
|
85
85
|
|
86
|
-
|
86
|
+
# Check to make sure that our array only has hashes
|
87
87
|
unless array.all? { |obj| obj.is_a?(Hash) }
|
88
88
|
error_msg = "start_calendar_interval must be a single hash or an array of hashes!"
|
89
89
|
raise Chef::Exceptions::ValidationFailed, error_msg
|
90
90
|
end
|
91
91
|
|
92
|
-
|
92
|
+
# Make sure the hashes don't have any incorrect keys/values
|
93
93
|
array.each do |entry|
|
94
94
|
allowed_keys = %w{Minute Hour Day Weekday Month}
|
95
95
|
unless entry.keys.all? { |key| allowed_keys.include?(key) }
|
@@ -105,7 +105,7 @@ class Chef
|
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
-
|
108
|
+
# Don't return array if we only have one entry
|
109
109
|
if array.size == 1
|
110
110
|
array.first
|
111
111
|
else
|
data/lib/chef/resource/locale.rb
CHANGED
@@ -45,7 +45,7 @@ class Chef
|
|
45
45
|
property :lang, String,
|
46
46
|
description: "Sets the default system language.",
|
47
47
|
regex: [LOCALE_REGEX],
|
48
|
-
validation_message: "The provided lang is not valid. It should be a non-empty string without any leading
|
48
|
+
validation_message: "The provided lang is not valid. It should be a non-empty string without any leading whitespace."
|
49
49
|
|
50
50
|
property :lc_env, Hash,
|
51
51
|
description: "A Hash of LC_* env variables in the form of `({ 'LC_ENV_VARIABLE' => 'VALUE' })`.",
|
@@ -59,7 +59,7 @@ class Chef
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
unless h.values.all? { |x| x =~ LOCALE_REGEX }
|
62
|
-
error_msg = "Values of option lc_env should be non-empty string without any leading
|
62
|
+
error_msg = "Values of option lc_env should be non-empty string without any leading whitespace."
|
63
63
|
raise Chef::Exceptions::ValidationFailed, error_msg
|
64
64
|
end
|
65
65
|
h
|
@@ -120,7 +120,7 @@ class Chef
|
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
|
-
# Generates the
|
123
|
+
# Generates the localization files from templates using locale-gen.
|
124
124
|
# @see http://manpages.ubuntu.com/manpages/cosmic/man8/locale-gen.8.html
|
125
125
|
# @raise [Mixlib::ShellOut::ShellCommandFailed] not a supported language or locale
|
126
126
|
#
|