chef 16.4.35 → 16.6.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Rakefile +2 -2
- data/bin/knife +1 -1
- data/chef.gemspec +2 -1
- data/lib/chef/api_client/registration.rb +6 -6
- data/lib/chef/application.rb +19 -22
- data/lib/chef/application/apply.rb +12 -7
- data/lib/chef/application/base.rb +26 -25
- data/lib/chef/application/client.rb +16 -8
- data/lib/chef/application/exit_code.rb +13 -4
- data/lib/chef/application/knife.rb +22 -11
- data/lib/chef/application/solo.rb +2 -1
- data/lib/chef/application/windows_service.rb +14 -14
- data/lib/chef/application/windows_service_manager.rb +6 -6
- data/lib/chef/chef_fs/chef_fs_data_store.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
- data/lib/chef/chef_fs/knife.rb +2 -2
- data/lib/chef/chef_fs/parallelizer.rb +0 -1
- data/lib/chef/client.rb +12 -42
- data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
- data/lib/chef/cookbook/gem_installer.rb +1 -1
- data/lib/chef/cookbook/synchronizer.rb +2 -2
- data/lib/chef/cookbook_site_streaming_uploader.rb +13 -11
- data/lib/chef/cookbook_uploader.rb +1 -1
- data/lib/chef/data_collector.rb +7 -6
- data/lib/chef/data_collector/config_validation.rb +22 -13
- data/lib/chef/data_collector/run_end_message.rb +2 -2
- data/lib/chef/data_collector/run_start_message.rb +1 -1
- data/lib/chef/deprecated.rb +1 -1
- data/lib/chef/deprecation/warnings.rb +2 -2
- data/lib/chef/digester.rb +2 -2
- data/lib/chef/dsl/chef_vault.rb +1 -1
- data/lib/chef/dsl/data_query.rb +2 -2
- data/lib/chef/dsl/platform_introspection.rb +1 -1
- data/lib/chef/encrypted_data_bag_item.rb +3 -4
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +3 -3
- data/lib/chef/encrypted_data_bag_item/encryptor.rb +3 -3
- data/lib/chef/environment.rb +2 -2
- data/lib/chef/event_loggers/windows_eventlog.rb +2 -2
- data/lib/chef/exceptions.rb +4 -4
- data/lib/chef/file_access_control/windows.rb +5 -1
- data/lib/chef/file_content_management/tempfile.rb +1 -1
- data/lib/chef/formatters/doc.rb +7 -6
- data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +6 -5
- data/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb +3 -3
- data/lib/chef/formatters/error_inspectors/registration_error_inspector.rb +9 -9
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +2 -2
- data/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb +3 -3
- data/lib/chef/formatters/indentable_output_stream.rb +2 -2
- data/lib/chef/formatters/minimal.rb +5 -4
- data/lib/chef/http.rb +6 -4
- data/lib/chef/http/auth_credentials.rb +5 -1
- data/lib/chef/http/authenticator.rb +1 -1
- data/lib/chef/http/basic_client.rb +4 -2
- data/lib/chef/http/decompressor.rb +1 -1
- data/lib/chef/http/http_request.rb +7 -5
- data/lib/chef/http/socketless_chef_zero_client.rb +5 -2
- data/lib/chef/http/ssl_policies.rb +1 -1
- data/lib/chef/json_compat.rb +1 -1
- data/lib/chef/knife.rb +4 -4
- data/lib/chef/knife/bootstrap.rb +16 -14
- data/lib/chef/knife/bootstrap/chef_vault_handler.rb +1 -1
- data/lib/chef/knife/bootstrap/templates/chef-full.erb +3 -3
- data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +7 -7
- data/lib/chef/knife/client_create.rb +3 -3
- data/lib/chef/knife/config_get.rb +8 -97
- data/lib/chef/knife/config_get_profile.rb +9 -9
- data/lib/chef/knife/config_list.rb +139 -0
- data/lib/chef/knife/config_list_profiles.rb +8 -98
- data/lib/chef/knife/config_show.rb +127 -0
- data/lib/chef/knife/config_use.rb +61 -0
- data/lib/chef/knife/config_use_profile.rb +9 -24
- data/lib/chef/knife/configure.rb +4 -2
- data/lib/chef/knife/core/bootstrap_context.rb +2 -2
- data/lib/chef/knife/core/object_loader.rb +1 -1
- data/lib/chef/knife/core/ui.rb +1 -1
- data/lib/chef/knife/core/windows_bootstrap_context.rb +11 -11
- data/lib/chef/knife/exec.rb +2 -2
- data/lib/chef/knife/node_policy_set.rb +2 -2
- data/lib/chef/knife/node_run_list_add.rb +1 -1
- data/lib/chef/knife/node_run_list_remove.rb +1 -1
- data/lib/chef/knife/node_run_list_set.rb +1 -1
- data/lib/chef/knife/node_show.rb +2 -2
- data/lib/chef/knife/role_env_run_list_add.rb +1 -1
- data/lib/chef/knife/role_env_run_list_set.rb +1 -1
- data/lib/chef/knife/role_run_list_add.rb +1 -1
- data/lib/chef/knife/role_run_list_set.rb +1 -1
- data/lib/chef/knife/search.rb +0 -1
- data/lib/chef/knife/serve.rb +3 -3
- data/lib/chef/knife/ssh.rb +18 -3
- data/lib/chef/knife/ssl_check.rb +3 -3
- data/lib/chef/knife/status.rb +2 -2
- data/lib/chef/knife/tag_create.rb +1 -1
- data/lib/chef/knife/tag_delete.rb +1 -1
- data/lib/chef/knife/user_create.rb +2 -2
- data/lib/chef/knife/yaml_convert.rb +1 -1
- data/lib/chef/local_mode.rb +2 -2
- data/lib/chef/log/syslog.rb +2 -2
- data/lib/chef/log/winevt.rb +2 -2
- data/lib/chef/mixin/deep_merge.rb +0 -12
- data/lib/chef/mixin/openssl_helper.rb +1 -4
- data/lib/chef/mixin/powershell_exec.rb +22 -10
- data/lib/chef/mixin/powershell_out.rb +12 -5
- data/lib/chef/mixin/template.rb +3 -3
- data/lib/chef/mixin/uris.rb +4 -2
- data/lib/chef/mixin/versioned_api.rb +1 -2
- data/lib/chef/monkey_patches/net_http.rb +4 -4
- data/lib/chef/node/mixin/immutablize_hash.rb +2 -0
- data/lib/chef/node_map.rb +4 -4
- data/lib/chef/policy_builder/dynamic.rb +2 -0
- data/lib/chef/policy_builder/policyfile.rb +2 -2
- data/lib/chef/powershell.rb +3 -2
- data/lib/chef/provider.rb +1 -5
- data/lib/chef/provider/file.rb +2 -2
- data/lib/chef/provider/ifconfig.rb +2 -2
- data/lib/chef/provider/ifconfig/debian.rb +33 -15
- data/lib/chef/provider/ifconfig/redhat.rb +51 -17
- data/lib/chef/provider/launchd.rb +2 -2
- data/lib/chef/provider/link.rb +0 -9
- data/lib/chef/provider/mount/linux.rb +63 -0
- data/lib/chef/provider/package/dpkg.rb +3 -12
- data/lib/chef/provider/package/homebrew.rb +1 -1
- data/lib/chef/provider/package/rubygems.rb +21 -18
- data/lib/chef/provider/package/snap.rb +0 -1
- data/lib/chef/provider/package/windows.rb +2 -2
- data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +3 -1
- data/lib/chef/provider/package/zypper.rb +1 -1
- data/lib/chef/provider/powershell_script.rb +12 -1
- data/lib/chef/provider/remote_file/content.rb +3 -0
- data/lib/chef/provider/remote_file/ftp.rb +6 -4
- data/lib/chef/provider/remote_file/sftp.rb +6 -4
- data/lib/chef/provider/route.rb +2 -6
- data/lib/chef/provider/service/macosx.rb +2 -2
- data/lib/chef/provider/service/redhat.rb +1 -1
- data/lib/chef/provider/template_finder.rb +2 -10
- data/lib/chef/provider/user/dscl.rb +5 -5
- data/lib/chef/provider/user/mac.rb +3 -3
- data/lib/chef/provider/windows_task.rb +1 -2
- data/lib/chef/provider/zypper_repository.rb +2 -2
- data/lib/chef/provider_resolver.rb +1 -1
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/pwsh.rb +64 -0
- data/lib/chef/recipe.rb +2 -2
- data/lib/chef/resource.rb +2 -2
- data/lib/chef/resource/apt_repository.rb +6 -5
- data/lib/chef/resource/bff_package.rb +22 -0
- data/lib/chef/resource/breakpoint.rb +57 -2
- data/lib/chef/resource/build_essential.rb +1 -1
- data/lib/chef/resource/cab_package.rb +29 -0
- data/lib/chef/resource/chef_client_config.rb +313 -0
- data/lib/chef/resource/chef_client_cron.rb +35 -28
- data/lib/chef/resource/chef_client_launchd.rb +194 -0
- data/lib/chef/resource/chef_client_scheduled_task.rb +24 -21
- data/lib/chef/resource/chef_client_systemd_timer.rb +27 -20
- data/lib/chef/resource/chef_client_trusted_certificate.rb +101 -0
- data/lib/chef/resource/chef_gem.rb +10 -10
- data/lib/chef/resource/chef_handler.rb +149 -4
- data/lib/chef/resource/chef_sleep.rb +3 -3
- data/lib/chef/resource/chef_vault_secret.rb +1 -1
- data/lib/chef/resource/cookbook_file.rb +2 -2
- data/lib/chef/resource/cron/_cron_shared.rb +1 -0
- data/lib/chef/resource/cron/cron_d.rb +2 -3
- data/lib/chef/resource/dnf_package.rb +2 -2
- data/lib/chef/resource/dsc_resource.rb +0 -1
- data/lib/chef/resource/dsc_script.rb +2 -2
- data/lib/chef/resource/execute.rb +6 -6
- data/lib/chef/resource/file.rb +4 -4
- data/lib/chef/resource/gem_package.rb +5 -5
- data/lib/chef/resource/homebrew_package.rb +3 -3
- data/lib/chef/resource/homebrew_update.rb +5 -5
- data/lib/chef/resource/hostname.rb +2 -2
- data/lib/chef/resource/kernel_module.rb +1 -1
- data/lib/chef/resource/launchd.rb +17 -16
- data/lib/chef/resource/locale.rb +2 -2
- data/lib/chef/resource/macos_userdefaults.rb +3 -3
- data/lib/chef/resource/mount.rb +1 -1
- data/lib/chef/resource/notify_group.rb +0 -1
- data/lib/chef/resource/ohai.rb +46 -3
- data/lib/chef/resource/ohai_hint.rb +33 -0
- data/lib/chef/resource/openssl_dhparam.rb +27 -5
- data/lib/chef/resource/openssl_ec_private_key.rb +6 -3
- data/lib/chef/resource/openssl_ec_public_key.rb +2 -2
- data/lib/chef/resource/openssl_rsa_private_key.rb +6 -3
- data/lib/chef/resource/openssl_x509_certificate.rb +14 -14
- data/lib/chef/resource/openssl_x509_crl.rb +19 -10
- data/lib/chef/resource/openssl_x509_request.rb +14 -16
- data/lib/chef/resource/osx_profile.rb +77 -13
- data/lib/chef/resource/plist.rb +1 -1
- data/lib/chef/resource/powershell_package_source.rb +5 -5
- data/lib/chef/resource/powershell_script.rb +7 -1
- data/lib/chef/resource/reboot.rb +2 -2
- data/lib/chef/resource/remote_file.rb +3 -3
- data/lib/chef/resource/rhsm_register.rb +22 -10
- data/lib/chef/resource/ruby_block.rb +2 -2
- data/lib/chef/resource/scm/subversion.rb +2 -2
- data/lib/chef/resource/service.rb +3 -3
- data/lib/chef/resource/ssh_known_hosts_entry.rb +2 -2
- data/lib/chef/resource/support/client.erb +65 -0
- data/lib/chef/resource/support/cron.d.erb +1 -1
- data/lib/chef/resource/support/cron_access.erb +1 -1
- data/lib/chef/resource/support/sudoer.erb +1 -1
- data/lib/chef/resource/support/ulimit.erb +1 -1
- data/lib/chef/resource/sysctl.rb +1 -5
- data/lib/chef/resource/systemd_unit.rb +2 -2
- data/lib/chef/resource/template.rb +2 -2
- data/lib/chef/resource/timezone.rb +112 -73
- data/lib/chef/resource/windows_ad_join.rb +10 -3
- data/lib/chef/resource/windows_audit_policy.rb +26 -24
- data/lib/chef/resource/windows_certificate.rb +6 -4
- data/lib/chef/resource/windows_firewall_profile.rb +22 -20
- data/lib/chef/resource/windows_package.rb +28 -5
- data/lib/chef/resource/windows_printer.rb +5 -3
- data/lib/chef/resource/windows_printer_port.rb +6 -4
- data/lib/chef/resource/windows_user_privilege.rb +53 -54
- data/lib/chef/resource/windows_workgroup.rb +3 -3
- data/lib/chef/resource/yum_package.rb +2 -2
- data/lib/chef/resource_reporter.rb +0 -2
- data/lib/chef/resources.rb +4 -1
- data/lib/chef/run_context.rb +2 -2
- data/lib/chef/run_context/cookbook_compiler.rb +1 -1
- data/lib/chef/run_lock.rb +2 -2
- data/lib/chef/search/query.rb +6 -5
- data/lib/chef/shell.rb +31 -26
- data/lib/chef/shell/ext.rb +11 -11
- data/lib/chef/shell/shell_session.rb +2 -2
- data/lib/chef/train_transport.rb +5 -104
- data/lib/chef/util/backup.rb +1 -1
- data/lib/chef/util/diff.rb +3 -3
- data/lib/chef/util/powershell/cmdlet.rb +3 -1
- data/lib/chef/util/powershell/ps_credential.rb +18 -14
- data/lib/chef/util/threaded_job_queue.rb +0 -2
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/crypto.rb +1 -1
- data/lib/chef/win32/file.rb +1 -1
- data/lib/chef/win32/registry.rb +1 -2
- data/lib/chef/win32/unicode.rb +1 -1
- data/spec/data/shef-config.rb +1 -1
- data/spec/functional/event_loggers/windows_eventlog_spec.rb +6 -5
- data/spec/functional/mixin/powershell_out_spec.rb +9 -1
- data/spec/functional/resource/aix_service_spec.rb +2 -2
- data/spec/functional/resource/aixinit_service_spec.rb +1 -1
- data/spec/functional/resource/insserv_spec.rb +1 -1
- data/spec/functional/resource/powershell_script_spec.rb +57 -14
- 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 +13 -13
- data/spec/functional/version_spec.rb +3 -3
- data/spec/integration/client/client_spec.rb +4 -4
- data/spec/integration/client/exit_code_spec.rb +3 -2
- data/spec/integration/client/ipv6_spec.rb +1 -1
- data/spec/integration/knife/{config_list_profiles_spec.rb → config_list_spec.rb} +30 -29
- data/spec/integration/knife/{config_get_spec.rb → config_show_spec.rb} +3 -3
- data/spec/integration/knife/{config_use_profile_spec.rb → config_use_spec.rb} +53 -10
- data/spec/integration/knife/cookbook_api_ipv6_spec.rb +1 -1
- data/spec/integration/ohai/ohai_spec.rb +61 -0
- data/spec/integration/recipes/remote_directory.rb +1 -1
- data/spec/integration/solo/solo_spec.rb +5 -5
- data/spec/spec_helper.rb +8 -6
- data/spec/stress/win32/file_spec.rb +1 -1
- data/spec/support/chef_helpers.rb +2 -2
- data/spec/support/matchers/leak.rb +2 -2
- data/spec/support/platform_helpers.rb +22 -35
- data/spec/support/shared/functional/securable_resource.rb +108 -27
- data/spec/support/shared/functional/win32_service.rb +1 -1
- data/spec/support/shared/unit/application_dot_d.rb +5 -3
- data/spec/tiny_server.rb +0 -1
- data/spec/unit/application/client_spec.rb +2 -2
- data/spec/unit/application/exit_code_spec.rb +10 -0
- data/spec/unit/application_spec.rb +4 -6
- data/spec/unit/chef_fs/config_spec.rb +1 -1
- data/spec/unit/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
- data/spec/unit/chef_fs/parallelizer_spec.rb +5 -1
- data/spec/unit/chef_fs/path_util_spec.rb +1 -1
- data/spec/unit/cookbook/synchronizer_spec.rb +2 -2
- data/spec/unit/cookbook_spec.rb +2 -2
- data/spec/unit/data_collector/config_validation_spec.rb +208 -0
- data/spec/unit/data_collector_spec.rb +6 -117
- data/spec/unit/dsl/declare_resource_spec.rb +1 -1
- data/spec/unit/file_access_control_spec.rb +1 -1
- data/spec/unit/knife/bootstrap_spec.rb +6 -6
- data/spec/unit/knife/core/ui_spec.rb +1 -0
- data/spec/unit/knife/ssh_spec.rb +2 -2
- data/spec/unit/lwrp_spec.rb +3 -3
- data/spec/unit/mixin/deep_merge_spec.rb +15 -0
- data/spec/unit/mixin/openssl_helper_spec.rb +1 -1
- data/spec/unit/mixin/powershell_exec_spec.rb +39 -2
- data/spec/unit/mixin/powershell_out_spec.rb +14 -0
- data/spec/unit/mixin/securable_spec.rb +2 -2
- data/spec/unit/node/immutable_collections_spec.rb +2 -2
- data/spec/unit/provider/mount/linux_spec.rb +97 -0
- data/spec/unit/provider/package/chocolatey_spec.rb +1 -1
- data/spec/unit/provider/package/powershell_spec.rb +1 -1
- data/spec/unit/provider/package/rubygems_spec.rb +4 -1
- data/spec/unit/provider/powershell_script_spec.rb +11 -0
- data/spec/unit/provider/route_spec.rb +0 -2
- data/spec/unit/recipe_spec.rb +1 -1
- data/spec/unit/resource/chef_client_config_spec.rb +137 -0
- data/spec/unit/resource/chef_client_cron_spec.rb +35 -14
- data/spec/unit/resource/chef_client_launchd_spec.rb +127 -0
- data/spec/unit/resource/chef_client_systemd_timer_spec.rb +36 -1
- data/spec/unit/resource/chef_client_trusted_certificate_spec.rb +54 -0
- data/spec/unit/resource/launchd_spec.rb +8 -0
- data/spec/unit/resource/osx_profile_spec.rb +67 -1
- data/spec/unit/resource/powershell_script_spec.rb +2 -2
- data/spec/unit/resource/rhsm_register_spec.rb +56 -18
- data/spec/unit/resource/timezone_spec.rb +63 -0
- data/spec/unit/resource/windows_uac_spec.rb +1 -1
- data/spec/unit/resource/windows_user_privilege_spec.rb +55 -0
- data/spec/unit/run_lock_spec.rb +5 -1
- data/spec/unit/runner_spec.rb +1 -2
- data/spec/unit/shell/shell_ext_spec.rb +46 -3
- data/spec/unit/shell/shell_session_spec.rb +35 -64
- data/spec/unit/shell_spec.rb +16 -19
- data/spec/unit/train_transport_spec.rb +14 -13
- data/spec/unit/util/selinux_spec.rb +2 -0
- data/tasks/rspec.rb +0 -2
- metadata +46 -18
- data/lib/chef/dist.rb +0 -68
- data/spec/integration/knife/config_get_profile_spec.rb +0 -114
@@ -113,7 +113,7 @@ class Chef
|
|
113
113
|
|
114
114
|
# if resource.provider is set, just return one of those objects
|
115
115
|
def maybe_explicit_provider(resource)
|
116
|
-
resource.provider
|
116
|
+
resource.provider
|
117
117
|
end
|
118
118
|
|
119
119
|
# try dynamically finding a provider based on querying the providers to see what they support
|
data/lib/chef/providers.rb
CHANGED
@@ -119,6 +119,7 @@ require_relative "provider/mount/mount"
|
|
119
119
|
require_relative "provider/mount/aix"
|
120
120
|
require_relative "provider/mount/solaris"
|
121
121
|
require_relative "provider/mount/windows"
|
122
|
+
require_relative "provider/mount/linux"
|
122
123
|
|
123
124
|
require_relative "provider/remote_file/ftp"
|
124
125
|
require_relative "provider/remote_file/sftp"
|
data/lib/chef/pwsh.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Matt Wrock (<mwrock@chef.io>)
|
3
|
+
# Copyright:: Copyright (c) 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
|
+
class Chef
|
19
|
+
class Pwsh < Chef::PowerShell
|
20
|
+
|
21
|
+
# Run a command under pwsh (powershell core) via FFI
|
22
|
+
# This implementation requires the managed dll, native wrapper and a
|
23
|
+
# published, self contained dotnet core directory tree to exist in the
|
24
|
+
# bindir directory.
|
25
|
+
#
|
26
|
+
# @param script [String] script to run
|
27
|
+
# @return [Object] output
|
28
|
+
def initialize(script)
|
29
|
+
@dll = Pwsh.dll
|
30
|
+
super
|
31
|
+
end
|
32
|
+
|
33
|
+
protected
|
34
|
+
|
35
|
+
def exec(script)
|
36
|
+
# Note that we need to override the location of the shared dotnet core library
|
37
|
+
# location. With most .net core applications, you can simply publish them as a
|
38
|
+
# "self-contained" application allowing consumers of the application to run them
|
39
|
+
# and use its own stand alone version of the .net core runtime. However because
|
40
|
+
# this is simply a dll and not an exe, it will look for the runtime in the shared
|
41
|
+
# .net core installation folder. By setting DOTNET_MULTILEVEL_LOOKUP to 0 we can
|
42
|
+
# override that folder's location with DOTNET_ROOT. To avoid the possibility of
|
43
|
+
# interfering with other .net core processes that might rely on the common shared
|
44
|
+
# location, we revert these variables after the script completes.
|
45
|
+
original_dml = ENV["DOTNET_MULTILEVEL_LOOKUP"]
|
46
|
+
original_dotnet_root = ENV["DOTNET_ROOT"]
|
47
|
+
original_dotnet_root_x86 = ENV["DOTNET_ROOT(x86)"]
|
48
|
+
|
49
|
+
ENV["DOTNET_MULTILEVEL_LOOKUP"] = "0"
|
50
|
+
ENV["DOTNET_ROOT"] = RbConfig::CONFIG["bindir"]
|
51
|
+
ENV["DOTNET_ROOT(x86)"] = RbConfig::CONFIG["bindir"]
|
52
|
+
|
53
|
+
super
|
54
|
+
ensure
|
55
|
+
ENV["DOTNET_MULTILEVEL_LOOKUP"] = original_dml
|
56
|
+
ENV["DOTNET_ROOT"] = original_dotnet_root
|
57
|
+
ENV["DOTNET_ROOT(x86)"] = original_dotnet_root_x86
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.dll
|
61
|
+
@dll ||= Dir.glob("#{RbConfig::CONFIG["bindir"]}/**/Chef.PowerShell.Wrapper.Core.dll").last
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/chef/recipe.rb
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
|
20
|
+
autoload :YAML, "yaml"
|
21
21
|
require_relative "dsl/recipe"
|
22
22
|
require_relative "mixin/from_file"
|
23
23
|
require_relative "mixin/deprecation"
|
@@ -122,7 +122,7 @@ class Chef
|
|
122
122
|
end
|
123
123
|
|
124
124
|
def to_s
|
125
|
-
"cookbook: #{cookbook_name
|
125
|
+
"cookbook: #{cookbook_name || "(none)"}, recipe: #{recipe_name || "(none)"} "
|
126
126
|
end
|
127
127
|
|
128
128
|
def inspect
|
data/lib/chef/resource.rb
CHANGED
@@ -36,7 +36,7 @@ require_relative "resource/resource_notification"
|
|
36
36
|
require_relative "provider_resolver"
|
37
37
|
require_relative "resource_resolver"
|
38
38
|
require_relative "provider"
|
39
|
-
|
39
|
+
autoload :Set, "set"
|
40
40
|
|
41
41
|
require_relative "mixin/deprecation"
|
42
42
|
require_relative "mixin/properties"
|
@@ -1480,7 +1480,7 @@ class Chef
|
|
1480
1480
|
def self.use(partial)
|
1481
1481
|
dirname = ::File.dirname(partial)
|
1482
1482
|
basename = ::File.basename(partial, ".rb")
|
1483
|
-
basename = basename[1
|
1483
|
+
basename = basename[1..] if basename.start_with?("_")
|
1484
1484
|
class_eval IO.read(::File.expand_path("#{dirname}/_#{basename}.rb", ::File.dirname(caller_locations.first.absolute_path)))
|
1485
1485
|
end
|
1486
1486
|
|
@@ -19,7 +19,9 @@
|
|
19
19
|
require_relative "../resource"
|
20
20
|
require_relative "../http/simple"
|
21
21
|
require "tmpdir" unless defined?(Dir.mktmpdir)
|
22
|
-
|
22
|
+
module Addressable
|
23
|
+
autoload :URI, "addressable/uri"
|
24
|
+
end
|
23
25
|
|
24
26
|
class Chef
|
25
27
|
class Resource
|
@@ -60,15 +62,14 @@ class Chef
|
|
60
62
|
end
|
61
63
|
```
|
62
64
|
|
63
|
-
**Add the JuJu PPA, grab the key from the keyserver, and add source repo**:
|
65
|
+
**Add the JuJu PPA, grab the key from the Ubuntu keyserver, and add source repo**:
|
64
66
|
|
65
67
|
```ruby
|
66
68
|
apt_repository 'juju' do
|
67
|
-
uri '
|
69
|
+
uri 'ppa:juju/stable'
|
68
70
|
components ['main']
|
69
71
|
distribution 'xenial'
|
70
72
|
key 'C8068B11'
|
71
|
-
keyserver 'keyserver.ubuntu.com'
|
72
73
|
action :add
|
73
74
|
deb_src true
|
74
75
|
end
|
@@ -168,7 +169,7 @@ class Chef
|
|
168
169
|
# is the provided ID a key ID from a keyserver. Looks at length and HEX only values
|
169
170
|
# @param [String] id the key value passed by the user that *may* be an ID
|
170
171
|
def is_key_id?(id)
|
171
|
-
id = id[2
|
172
|
+
id = id[2..] if id.start_with?("0x")
|
172
173
|
id =~ /^\h+$/ && [8, 16, 40].include?(id.length)
|
173
174
|
end
|
174
175
|
|
@@ -17,6 +17,7 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require_relative "package"
|
20
|
+
require "chef-utils/dist" unless defined?(ChefUtils::Dist)
|
20
21
|
|
21
22
|
class Chef
|
22
23
|
class Resource
|
@@ -27,6 +28,27 @@ class Chef
|
|
27
28
|
|
28
29
|
description "Use the **bff_package** resource to manage packages for the AIX platform using the installp utility. When a package is installed from a local file, it must be added to the node using the **remote_file** or **cookbook_file** resources."
|
29
30
|
introduced "12.0"
|
31
|
+
examples <<~DOC
|
32
|
+
The **bff_package** resource is the default package provider on the AIX platform. The base **package** resource may be used, and then when the platform is AIX, #{ChefUtils::Dist::Infra::PRODUCT} will identify the correct package provider. The following examples show how to install part of the IBM XL C/C++ compiler.
|
33
|
+
|
34
|
+
**Installing using the base package resource**
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
package 'xlccmp.13.1.0' do
|
38
|
+
source '/var/tmp/IBM_XL_C_13.1.0/usr/sys/inst.images/xlccmp.13.1.0'
|
39
|
+
action :install
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
**Installing using the bff_package resource**
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
bff_package 'xlccmp.13.1.0' do
|
47
|
+
source '/var/tmp/IBM_XL_C_13.1.0/usr/sys/inst.images/xlccmp.13.1.0'
|
48
|
+
action :install
|
49
|
+
end
|
50
|
+
```
|
51
|
+
DOC
|
30
52
|
|
31
53
|
property :package_name, String,
|
32
54
|
description: "An optional property to set the package name if it differs from the resource block's name.",
|
@@ -17,7 +17,7 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require_relative "../resource"
|
20
|
-
|
20
|
+
require "chef-utils/dist" unless defined?(ChefUtils::Dist)
|
21
21
|
|
22
22
|
class Chef
|
23
23
|
class Resource
|
@@ -26,8 +26,63 @@ class Chef
|
|
26
26
|
|
27
27
|
provides :breakpoint, target_mode: true
|
28
28
|
|
29
|
-
description "Use the **breakpoint** resource to add breakpoints to recipes. Run the #{
|
29
|
+
description "Use the **breakpoint** resource to add breakpoints to recipes. Run the #{ChefUtils::Dist::Infra::SHELL} in #{ChefUtils::Dist::Infra::PRODUCT} mode, and then use those breakpoints to debug recipes. Breakpoints are ignored by the #{ChefUtils::Dist::Infra::CLIENT} during an actual #{ChefUtils::Dist::Infra::CLIENT} run. That said, breakpoints are typically used to debug recipes only when running them in a non-production environment, after which they are removed from those recipes before the parent cookbook is uploaded to the Chef server."
|
30
30
|
introduced "12.0"
|
31
|
+
examples <<~DOC
|
32
|
+
**A recipe without a breakpoint**
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
yum_key node['yum']['elrepo']['key'] do
|
36
|
+
url node['yum']['elrepo']['key_url']
|
37
|
+
action :add
|
38
|
+
end
|
39
|
+
|
40
|
+
yum_repository 'elrepo' do
|
41
|
+
description 'ELRepo.org Community Enterprise Linux Extras Repository'
|
42
|
+
key node['yum']['elrepo']['key']
|
43
|
+
mirrorlist node['yum']['elrepo']['url']
|
44
|
+
includepkgs node['yum']['elrepo']['includepkgs']
|
45
|
+
exclude node['yum']['elrepo']['exclude']
|
46
|
+
action :create
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
**The same recipe with breakpoints**
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
breakpoint "before yum_key node['yum']['repo_name']['key']" do
|
54
|
+
action :break
|
55
|
+
end
|
56
|
+
|
57
|
+
yum_key node['yum']['repo_name']['key'] do
|
58
|
+
url node['yum']['repo_name']['key_url']
|
59
|
+
action :add
|
60
|
+
end
|
61
|
+
|
62
|
+
breakpoint "after yum_key node['yum']['repo_name']['key']" do
|
63
|
+
action :break
|
64
|
+
end
|
65
|
+
|
66
|
+
breakpoint "before yum_repository 'repo_name'" do
|
67
|
+
action :break
|
68
|
+
end
|
69
|
+
|
70
|
+
yum_repository 'repo_name' do
|
71
|
+
description 'description'
|
72
|
+
key node['yum']['repo_name']['key']
|
73
|
+
mirrorlist node['yum']['repo_name']['url']
|
74
|
+
includepkgs node['yum']['repo_name']['includepkgs']
|
75
|
+
exclude node['yum']['repo_name']['exclude']
|
76
|
+
action :create
|
77
|
+
end
|
78
|
+
|
79
|
+
breakpoint "after yum_repository 'repo_name'" do
|
80
|
+
action :break
|
81
|
+
end
|
82
|
+
```
|
83
|
+
|
84
|
+
where the name of each breakpoint is an arbitrary string. In the previous examples, the names are used to indicate if the breakpoint is before or after a resource, and then also to specify which resource.
|
85
|
+
DOC
|
31
86
|
|
32
87
|
default_action :break
|
33
88
|
|
@@ -29,6 +29,35 @@ class Chef
|
|
29
29
|
|
30
30
|
description "Use the **cab_package** resource to install or remove Microsoft Windows cabinet (.cab) packages."
|
31
31
|
introduced "12.15"
|
32
|
+
examples <<~'DOC'
|
33
|
+
**Using local path in source**
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
cab_package 'Install .NET 3.5 sp1 via KB958488' do
|
37
|
+
source 'C:\Users\xyz\AppData\Local\Temp\Windows6.1-KB958488-x64.cab'
|
38
|
+
action :install
|
39
|
+
end
|
40
|
+
|
41
|
+
cab_package 'Remove .NET 3.5 sp1 via KB958488' do
|
42
|
+
source 'C:\Users\xyz\AppData\Local\Temp\Windows6.1-KB958488-x64.cab'
|
43
|
+
action :remove
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
**Using URL in source**
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
cab_package 'Install .NET 3.5 sp1 via KB958488' do
|
51
|
+
source 'https://s3.amazonaws.com/my_bucket/Windows6.1-KB958488-x64.cab'
|
52
|
+
action :install
|
53
|
+
end
|
54
|
+
|
55
|
+
cab_package 'Remove .NET 3.5 sp1 via KB958488' do
|
56
|
+
source 'https://s3.amazonaws.com/my_bucket/Temp\Windows6.1-KB958488-x64.cab'
|
57
|
+
action :remove
|
58
|
+
end
|
59
|
+
```
|
60
|
+
DOC
|
32
61
|
|
33
62
|
allowed_actions :install, :remove
|
34
63
|
|
@@ -0,0 +1,313 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require_relative "../resource"
|
18
|
+
require "chef-utils/dist" unless defined?(ChefUtils::Dist)
|
19
|
+
|
20
|
+
class Chef
|
21
|
+
class Resource
|
22
|
+
class ChefClientConfig < Chef::Resource
|
23
|
+
unified_mode true
|
24
|
+
|
25
|
+
provides :chef_client_config
|
26
|
+
|
27
|
+
description "Use the **chef_client_config** resource to create a client.rb file in the #{ChefUtils::Dist::Infra::PRODUCT} configuration directory. See the [client.rb docs](https://docs.chef.io/config_rb_client/) for more details on options available in the client.rb configuration file."
|
28
|
+
introduced "16.6"
|
29
|
+
examples <<~DOC
|
30
|
+
**Bare minimum #{ChefUtils::Dist::Infra::PRODUCT} client.rb**:
|
31
|
+
|
32
|
+
The absolute minimum configuration necessary for a node to communicate with the Infra Server is the URL of the Infra Server. All other configuration options either have values at the server side (Policyfiles, Roles, Environments, etc) or have default values determined at client startup.
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
chef_client_config 'Create client.rb' do
|
36
|
+
chef_server_url 'https://chef.example.dmz'
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
**More complex #{ChefUtils::Dist::Infra::PRODUCT} client.rb**:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
chef_client_config 'Create client.rb' do
|
44
|
+
chef_server_url 'https://chef.example.dmz'
|
45
|
+
log_level :info
|
46
|
+
log_location :syslog
|
47
|
+
http_proxy 'proxy.example.dmz'
|
48
|
+
https_proxy 'proxy.example.dmz'
|
49
|
+
no_proxy %w(internal.example.dmz)
|
50
|
+
end
|
51
|
+
```
|
52
|
+
|
53
|
+
**Adding additional config content to the client.rb**:
|
54
|
+
|
55
|
+
This resource aims to provide common configuration options. Some configuration options are missing and some users may want to use arbitrary Ruby code within their configuration. For this we offer an `additional_config` property that can be used to add any configuration or code to the bottom of the `client.rb` file. Also keep in mind that within the configuration directory is a `client.d` directory where you can put additional `.rb` files containing configuration options. These can be created using `file` or `template` resources within your cookbooks as necessary.
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
chef_client_config 'Create client.rb' do
|
59
|
+
chef_server_url 'https://chef.example.dmz'
|
60
|
+
additional_config <<~CONFIG
|
61
|
+
# Extra config code to safely load a gem into the client run.
|
62
|
+
# Since the config is Ruby you can run any Ruby code you want via the client.rb.
|
63
|
+
# It's a great way to break things, so be careful
|
64
|
+
begin
|
65
|
+
require 'aws-sdk'
|
66
|
+
rescue LoadError
|
67
|
+
Chef::Log.warn "Failed to load aws-sdk."
|
68
|
+
end
|
69
|
+
CONFIG
|
70
|
+
end
|
71
|
+
```
|
72
|
+
|
73
|
+
**Setup two report handlers in the client.rb**:
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
chef_client_config 'Create client.rb' do
|
77
|
+
chef_server_url 'https://chef.example.dmz'
|
78
|
+
report_handlers [
|
79
|
+
{
|
80
|
+
'class' => 'ReportHandler1Class',
|
81
|
+
'arguments' => ["'FirstArgument'", "'SecondArgument'"],
|
82
|
+
},
|
83
|
+
{
|
84
|
+
'class' => 'ReportHandler2Class',
|
85
|
+
'arguments' => ["'FirstArgument'", "'SecondArgument'"],
|
86
|
+
},
|
87
|
+
]
|
88
|
+
end
|
89
|
+
```
|
90
|
+
DOC
|
91
|
+
|
92
|
+
# @todo policy_file or policy_group being set requires the other to be set so enforce that.
|
93
|
+
# @todo all properties for automate report
|
94
|
+
# @todo add all descriptions
|
95
|
+
# @todo validate handler hash structure
|
96
|
+
|
97
|
+
#
|
98
|
+
# @param [String, Symbol] prop_val the value from the property
|
99
|
+
#
|
100
|
+
# @return [Symbol] The symbol form of the symbol-like string, string, or symbol value
|
101
|
+
#
|
102
|
+
def string_to_symbol(prop_val)
|
103
|
+
if prop_val.is_a?(String) && prop_val.start_with?(":")
|
104
|
+
prop_val[1..-1].to_sym
|
105
|
+
else
|
106
|
+
prop_val.to_sym
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
property :config_directory, String,
|
111
|
+
description: "The directory to store the client.rb in.",
|
112
|
+
default: ChefConfig::Config.etc_chef_dir,
|
113
|
+
default_description: "`/etc/chef/` on *nix-like systems and `C:\chef\` on Windows"
|
114
|
+
|
115
|
+
property :user, String,
|
116
|
+
description: "The user that should own the client.rb file and the configuration directory if it needs to be created. Note: The configuration directory will not be created if it already exists, which allows you to further control the setup of that directory outside of this resource."
|
117
|
+
|
118
|
+
property :group, String,
|
119
|
+
description: "The group that should own the client.rb file and the configuration directory if it needs to be created. Note: The configuration directory will not be created if it already exists, which allows you to further control the setup of that directory outside of this resource."
|
120
|
+
|
121
|
+
property :node_name, [String, NilClass], # this accepts nil so people can disable the default
|
122
|
+
description: "The name of the node. This configuration sets the `node.name` value used in cookbooks and the `client_name` value used when authenticating to a #{ChefUtils::Dist::Server::PRODUCT} to determine what configuration to apply. Note: By default this configuration uses the `node.name` value which would be set during bootstrap. Hard coding this value in the `client.rb` config avoids logic within #{ChefUtils::Dist::Server::PRODUCT} that performs DNS lookups and may fail in the event of a DNS outage. To skip this default value and instead use the built-in #{ChefUtils::Dist::Server::PRODUCT} logic, set this property to `nil`",
|
123
|
+
default: lazy { node.name },
|
124
|
+
default_description: "The `node.name` value reported by #{ChefUtils::Dist::Infra::PRODUCT}."
|
125
|
+
|
126
|
+
property :chef_server_url, String,
|
127
|
+
description: "The URL for the #{ChefUtils::Dist::Server::PRODUCT}.",
|
128
|
+
required: true
|
129
|
+
|
130
|
+
# @todo Allow passing this as a string and convert it to the symbol
|
131
|
+
property :ssl_verify_mode, [Symbol, String],
|
132
|
+
equal_to: %i{verify_none verify_peer},
|
133
|
+
coerce: proc { |x| string_to_symbol(x) },
|
134
|
+
description: <<~DESC
|
135
|
+
Set the verify mode for HTTPS requests.
|
136
|
+
|
137
|
+
* Use :verify_none for no validation of SSL certificates.
|
138
|
+
* Use :verify_peer for validation of all SSL certificates, including the #{ChefUtils::Dist::Server::PRODUCT} connections, S3 connections, and any HTTPS remote_file resource URLs used in #{ChefUtils::Dist::Infra::PRODUCT} runs. This is the recommended setting.
|
139
|
+
DESC
|
140
|
+
|
141
|
+
property :formatters, Array,
|
142
|
+
description: "",
|
143
|
+
default: []
|
144
|
+
|
145
|
+
property :event_loggers, Array,
|
146
|
+
description: "",
|
147
|
+
default: []
|
148
|
+
|
149
|
+
property :log_level, Symbol,
|
150
|
+
description: "The level of logging performed by the #{ChefUtils::Dist::Infra::PRODUCT}.",
|
151
|
+
equal_to: %i{auto trace debug info warn fatal}
|
152
|
+
|
153
|
+
property :log_location, [String, Symbol],
|
154
|
+
description: "The location to save logs to. This can either by a path to a log file on disk `:syslog` to log to Syslog, `:win_evt` to log to the Windows Event Log, or `'STDERR'`/`'STDOUT'` to log to the *nix text streams.",
|
155
|
+
callbacks: {
|
156
|
+
"accepts Symbol values of ':win_evt' for Windows Event Log or ':syslog' for Syslog" => lambda { |p|
|
157
|
+
p.is_a?(Symbol) ? %i{win_evt syslog}.include?(p) : true
|
158
|
+
},
|
159
|
+
}
|
160
|
+
|
161
|
+
property :http_proxy, String,
|
162
|
+
description: "The proxy server to use for HTTP connections."
|
163
|
+
|
164
|
+
property :https_proxy, String,
|
165
|
+
description: "The proxy server to use for HTTPS connections."
|
166
|
+
|
167
|
+
property :ftp_proxy, String,
|
168
|
+
description: "The proxy server to use for FTP connections."
|
169
|
+
|
170
|
+
property :no_proxy, [String, Array],
|
171
|
+
description: "A comma-separated list or an array of URLs that do not need a proxy.",
|
172
|
+
coerce: proc { |x| x.is_a?(Array) ? x.join(",") : x },
|
173
|
+
default: []
|
174
|
+
|
175
|
+
# @todo we need to fixup bad plugin naming inputs here
|
176
|
+
property :ohai_disabled_plugins, Array,
|
177
|
+
description: "Ohai plugins that should be disabled in order to speed up the #{ChefUtils::Dist::Infra::PRODUCT} run and reduce the size of node data sent to #{ChefUtils::Dist::Infra::PRODUCT}",
|
178
|
+
coerce: proc { |x| x.map { |v| string_to_symbol(v).capitalize } },
|
179
|
+
default: []
|
180
|
+
|
181
|
+
# @todo we need to fixup bad plugin naming inputs here
|
182
|
+
property :ohai_optional_plugins, Array,
|
183
|
+
description: "Optional Ohai plugins that should be enabled to provide additional Ohai data for use in cookbooks.",
|
184
|
+
coerce: proc { |x| x.map { |v| string_to_symbol(v).capitalize } },
|
185
|
+
default: []
|
186
|
+
|
187
|
+
property :minimal_ohai, [true, false],
|
188
|
+
description: "Run a minimal set of Ohai plugins providing data necessary for the execution of #{ChefUtils::Dist::Infra::PRODUCT}'s built-in resources. Setting this to true will skip many large and time consuming data sets such as `cloud` or `packages`. Setting this this to true may break cookbooks that assume all Ohai data will be present."
|
189
|
+
|
190
|
+
property :start_handlers, Array,
|
191
|
+
description: %q(An array of hashes that contain a report handler class and the arguments to pass to that class on initialization. The hash should include `class` and `argument` keys where `class` is a String and `argument` is an array of quoted String values. For example: `[{'class' => 'MyHandler', %w('"argument1"', '"argument2"')}]`),
|
192
|
+
default: []
|
193
|
+
|
194
|
+
property :report_handlers, Array,
|
195
|
+
description: %q(An array of hashes that contain a report handler class and the arguments to pass to that class on initialization. The hash should include `class` and `argument` keys where `class` is a String and `argument` is an array of quoted String values. For example: `[{'class' => 'MyHandler', %w('"argument1"', '"argument2"')}]`),
|
196
|
+
default: []
|
197
|
+
|
198
|
+
property :exception_handlers, Array,
|
199
|
+
description: %q(An array of hashes that contain a exception handler class and the arguments to pass to that class on initialization. The hash should include `class` and `argument` keys where `class` is a String and `argument` is an array of quoted String values. For example: `[{'class' => 'MyHandler', %w('"argument1"', '"argument2"')}]`),
|
200
|
+
default: []
|
201
|
+
|
202
|
+
property :chef_license, String,
|
203
|
+
description: "Accept the [Chef EULA](https://www.chef.io/end-user-license-agreement/)",
|
204
|
+
equal_to: %w{accept accept-no-persist accept-silent}
|
205
|
+
|
206
|
+
property :policy_name, String,
|
207
|
+
description: "The name of a policy, as identified by the `name` setting in a Policyfile.rb file. `policy_group` when setting this property."
|
208
|
+
|
209
|
+
property :policy_group, String,
|
210
|
+
description: "The name of a `policy group` that exists on the #{ChefUtils::Dist::Server::PRODUCT}. `policy_name` must also be specified when setting this property."
|
211
|
+
|
212
|
+
property :named_run_list, String,
|
213
|
+
description: "A specific named runlist defined in the node's applied Policyfile, which the should be used when running #{ChefUtils::Dist::Infra::PRODUCT}."
|
214
|
+
|
215
|
+
property :pid_file, String,
|
216
|
+
description: "The location in which a process identification number (pid) is saved. An executable, when started as a daemon, writes the pid to the specified file. "
|
217
|
+
|
218
|
+
property :file_cache_path, String,
|
219
|
+
description: "The location in which cookbooks (and other transient data) files are stored when they are synchronized. This value can also be used in recipes to download files with the `remote_file` resource."
|
220
|
+
|
221
|
+
property :file_backup_path, String,
|
222
|
+
description: "The location in which backup files are stored. If this value is empty, backup files are stored in the directory of the target file"
|
223
|
+
|
224
|
+
property :file_staging_uses_destdir, String,
|
225
|
+
description: "How file staging (via temporary files) is done. When `true`, temporary files are created in the directory in which files will reside. When `false`, temporary files are created under `ENV['TMP']`"
|
226
|
+
|
227
|
+
property :additional_config, String,
|
228
|
+
description: "Additional text to add at the bottom of the client.rb config. This can be used to run custom Ruby or to add less common config options"
|
229
|
+
|
230
|
+
action :create do
|
231
|
+
unless ::Dir.exist?(new_resource.config_directory)
|
232
|
+
directory new_resource.config_directory do
|
233
|
+
user new_resource.user unless new_resource.user.nil?
|
234
|
+
group new_resource.group unless new_resource.group.nil?
|
235
|
+
mode "0750"
|
236
|
+
recursive true
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
unless ::Dir.exist?(::File.join(new_resource.config_directory, "client.d"))
|
241
|
+
directory ::File.join(new_resource.config_directory, "client.d") do
|
242
|
+
user new_resource.user unless new_resource.user.nil?
|
243
|
+
group new_resource.group unless new_resource.group.nil?
|
244
|
+
mode "0750"
|
245
|
+
recursive true
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
template ::File.join(new_resource.config_directory, "client.rb") do
|
250
|
+
source ::File.expand_path("support/client.erb", __dir__)
|
251
|
+
user new_resource.user unless new_resource.user.nil?
|
252
|
+
group new_resource.group unless new_resource.group.nil?
|
253
|
+
local true
|
254
|
+
variables(
|
255
|
+
chef_license: new_resource.chef_license,
|
256
|
+
chef_server_url: new_resource.chef_server_url,
|
257
|
+
event_loggers: new_resource.event_loggers,
|
258
|
+
exception_handlers: format_handler(new_resource.exception_handlers),
|
259
|
+
file_backup_path: new_resource.file_backup_path,
|
260
|
+
file_cache_path: new_resource.file_cache_path,
|
261
|
+
file_staging_uses_destdir: new_resource.file_staging_uses_destdir,
|
262
|
+
formatters: new_resource.formatters,
|
263
|
+
http_proxy: new_resource.http_proxy,
|
264
|
+
https_proxy: new_resource.https_proxy,
|
265
|
+
ftp_proxy: new_resource.ftp_proxy,
|
266
|
+
log_level: new_resource.log_level,
|
267
|
+
log_location: new_resource.log_location,
|
268
|
+
minimal_ohai: new_resource.minimal_ohai,
|
269
|
+
named_run_list: new_resource.named_run_list,
|
270
|
+
no_proxy: new_resource.no_proxy,
|
271
|
+
node_name: new_resource.node_name,
|
272
|
+
ohai_disabled_plugins: new_resource.ohai_disabled_plugins,
|
273
|
+
ohai_optional_plugins: new_resource.ohai_optional_plugins,
|
274
|
+
pid_file: new_resource.pid_file,
|
275
|
+
policy_group: new_resource.policy_group,
|
276
|
+
policy_name: new_resource.policy_name,
|
277
|
+
report_handlers: format_handler(new_resource.report_handlers),
|
278
|
+
ssl_verify_mode: new_resource.ssl_verify_mode,
|
279
|
+
start_handlers: format_handler(new_resource.start_handlers),
|
280
|
+
additional_config: new_resource.additional_config
|
281
|
+
)
|
282
|
+
mode "0640"
|
283
|
+
action :create
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
action :remove do
|
288
|
+
file ::File.join(new_resource.config_directory, "client.rb") do
|
289
|
+
action :delete
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
action_class do
|
294
|
+
#
|
295
|
+
# Format the handler document in the way we want it presented in the client.rb file
|
296
|
+
#
|
297
|
+
# @param [Hash] a handler property
|
298
|
+
#
|
299
|
+
# @return [Array] Array of handler data
|
300
|
+
#
|
301
|
+
def format_handler(handler_property)
|
302
|
+
handler_data = []
|
303
|
+
|
304
|
+
handler_property.each do |handler|
|
305
|
+
handler_data << "#{handler["class"]}.new(#{handler["arguments"].join(",")})"
|
306
|
+
end
|
307
|
+
|
308
|
+
handler_data
|
309
|
+
end
|
310
|
+
end
|
311
|
+
end
|
312
|
+
end
|
313
|
+
end
|