chef 17.10.95 → 18.1.0
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 +4 -4
- data/Gemfile +16 -8
- data/README.md +7 -7
- data/Rakefile +3 -22
- data/{chef-universal-mingw32.gemspec → chef-universal-mingw-ucrt.gemspec} +8 -7
- data/chef.gemspec +12 -5
- data/lib/chef/api_client_v1.rb +9 -1
- data/lib/chef/application/exit_code.rb +3 -3
- data/lib/chef/chef_fs/file_system.rb +21 -7
- data/lib/chef/client.rb +169 -17
- data/lib/chef/compliance/input.rb +1 -1
- data/lib/chef/compliance/profile.rb +1 -1
- data/lib/chef/compliance/profile_collection.rb +0 -1
- data/lib/chef/compliance/waiver.rb +1 -1
- data/lib/chef/cookbook/syntax_check.rb +2 -2
- data/lib/chef/dsl/reader_helpers.rb +1 -1
- data/lib/chef/dsl/rest_resource.rb +77 -0
- data/lib/chef/event_dispatch/base.rb +3 -0
- data/lib/chef/exceptions.rb +8 -0
- data/lib/chef/http/authenticator.rb +170 -3
- data/lib/chef/http/ssl_policies.rb +3 -3
- data/lib/chef/mixin/powershell_exec.rb +5 -28
- data/lib/chef/node/mixin/immutablize_array.rb +1 -0
- data/lib/chef/property.rb +13 -6
- data/lib/chef/provider/cron.rb +5 -1
- data/lib/chef/provider/group/windows.rb +1 -1
- data/lib/chef/provider/http_request.rb +11 -9
- data/lib/chef/provider/launchd.rb +1 -0
- data/lib/chef/provider/mount/linux.rb +5 -0
- data/lib/chef/provider/mount/mount.rb +8 -0
- data/lib/chef/provider/mount/windows.rb +1 -1
- data/lib/chef/provider/package/chocolatey.rb +1 -18
- data/lib/chef/provider/package/rubygems.rb +1 -1
- data/lib/chef/provider/package/snap.rb +1 -1
- data/lib/chef/provider/package/windows/msi.rb +2 -2
- data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +1 -1
- data/lib/chef/provider/package/yum/yum_helper.py +5 -17
- data/lib/chef/provider/package/zypper/version.rb +60 -0
- data/lib/chef/provider/package/zypper.rb +47 -3
- data/lib/chef/provider/service/windows.rb +1 -1
- data/lib/chef/provider/user/aix.rb +5 -0
- data/lib/chef/provider/user/linux.rb +29 -0
- data/lib/chef/provider/user/mac.rb +1 -1
- data/lib/chef/provider/user.rb +46 -14
- data/lib/chef/provider/yum_repository.rb +13 -1
- data/lib/chef/provider.rb +1 -1
- data/lib/chef/recipe.rb +1 -1
- data/lib/chef/resource/_rest_resource.rb +389 -0
- data/lib/chef/resource/alternatives.rb +0 -1
- data/lib/chef/resource/apt_package.rb +2 -1
- data/lib/chef/resource/apt_preference.rb +0 -1
- data/lib/chef/resource/apt_repository.rb +0 -1
- data/lib/chef/resource/apt_update.rb +0 -1
- data/lib/chef/resource/archive_file.rb +0 -1
- data/lib/chef/resource/bash.rb +0 -1
- data/lib/chef/resource/batch.rb +0 -1
- data/lib/chef/resource/bff_package.rb +0 -1
- data/lib/chef/resource/breakpoint.rb +0 -1
- data/lib/chef/resource/build_essential.rb +0 -1
- data/lib/chef/resource/cab_package.rb +0 -1
- data/lib/chef/resource/chef_client_config.rb +12 -14
- data/lib/chef/resource/chef_client_cron.rb +1 -2
- data/lib/chef/resource/chef_client_launchd.rb +2 -2
- data/lib/chef/resource/chef_client_scheduled_task.rb +3 -3
- data/lib/chef/resource/chef_client_systemd_timer.rb +0 -1
- data/lib/chef/resource/chef_client_trusted_certificate.rb +0 -1
- data/lib/chef/resource/chef_gem.rb +0 -1
- data/lib/chef/resource/chef_handler.rb +0 -1
- data/lib/chef/resource/chef_sleep.rb +1 -3
- data/lib/chef/resource/chef_vault_secret.rb +0 -1
- data/lib/chef/resource/chocolatey_config.rb +0 -1
- data/lib/chef/resource/chocolatey_feature.rb +0 -1
- data/lib/chef/resource/chocolatey_package.rb +0 -1
- data/lib/chef/resource/chocolatey_source.rb +0 -1
- data/lib/chef/resource/cookbook_file.rb +0 -1
- data/lib/chef/resource/cron/_cron_shared.rb +0 -1
- data/lib/chef/resource/cron/cron.rb +0 -1
- data/lib/chef/resource/cron/cron_d.rb +15 -1
- data/lib/chef/resource/cron_access.rb +0 -1
- data/lib/chef/resource/csh.rb +0 -1
- data/lib/chef/resource/directory.rb +0 -1
- data/lib/chef/resource/dmg_package.rb +2 -1
- data/lib/chef/resource/dnf_package.rb +0 -1
- data/lib/chef/resource/dpkg_package.rb +0 -1
- data/lib/chef/resource/dsc_resource.rb +0 -1
- data/lib/chef/resource/dsc_script.rb +0 -1
- data/lib/chef/resource/execute.rb +0 -1
- data/lib/chef/resource/file.rb +0 -1
- data/lib/chef/resource/freebsd_package.rb +2 -1
- data/lib/chef/resource/gem_package.rb +2 -1
- data/lib/chef/resource/group.rb +25 -2
- data/lib/chef/resource/habitat/habitat_package.rb +0 -1
- data/lib/chef/resource/habitat/habitat_sup.rb +6 -7
- data/lib/chef/resource/habitat/habitat_sup_windows.rb +1 -1
- data/lib/chef/resource/habitat_config.rb +0 -1
- data/lib/chef/resource/habitat_install.rb +0 -1
- data/lib/chef/resource/habitat_service.rb +0 -1
- data/lib/chef/resource/habitat_user_toml.rb +0 -1
- data/lib/chef/resource/homebrew_cask.rb +0 -1
- data/lib/chef/resource/homebrew_package.rb +2 -1
- data/lib/chef/resource/homebrew_tap.rb +0 -1
- data/lib/chef/resource/homebrew_update.rb +0 -2
- data/lib/chef/resource/hostname.rb +0 -1
- data/lib/chef/resource/http_request.rb +0 -1
- data/lib/chef/resource/ifconfig.rb +0 -1
- data/lib/chef/resource/inspec_input.rb +0 -1
- data/lib/chef/resource/inspec_waiver.rb +0 -1
- data/lib/chef/resource/inspec_waiver_file_entry.rb +2 -3
- data/lib/chef/resource/ips_package.rb +0 -1
- data/lib/chef/resource/kernel_module.rb +0 -1
- data/lib/chef/resource/ksh.rb +0 -1
- data/lib/chef/resource/launchd.rb +3 -1
- data/lib/chef/resource/link.rb +0 -1
- data/lib/chef/resource/locale.rb +2 -6
- data/lib/chef/resource/log.rb +0 -1
- data/lib/chef/resource/lwrp_base.rb +0 -4
- data/lib/chef/resource/macos_userdefaults.rb +8 -13
- data/lib/chef/resource/macosx_service.rb +0 -1
- data/lib/chef/resource/macports_package.rb +2 -1
- data/lib/chef/resource/mdadm.rb +0 -1
- data/lib/chef/resource/mount.rb +0 -1
- data/lib/chef/resource/msu_package.rb +0 -1
- data/lib/chef/resource/notify_group.rb +0 -2
- data/lib/chef/resource/ohai.rb +0 -1
- data/lib/chef/resource/ohai_hint.rb +0 -1
- data/lib/chef/resource/openbsd_package.rb +2 -1
- data/lib/chef/resource/openssl_dhparam.rb +0 -2
- data/lib/chef/resource/openssl_ec_private_key.rb +0 -2
- data/lib/chef/resource/openssl_ec_public_key.rb +0 -2
- data/lib/chef/resource/openssl_rsa_private_key.rb +0 -2
- data/lib/chef/resource/openssl_rsa_public_key.rb +0 -2
- data/lib/chef/resource/openssl_x509_certificate.rb +0 -2
- data/lib/chef/resource/openssl_x509_crl.rb +0 -2
- data/lib/chef/resource/openssl_x509_request.rb +0 -2
- data/lib/chef/resource/osx_profile.rb +0 -1
- data/lib/chef/resource/package.rb +0 -1
- data/lib/chef/resource/pacman_package.rb +2 -1
- data/lib/chef/resource/paludis_package.rb +0 -1
- data/lib/chef/resource/perl.rb +0 -1
- data/lib/chef/resource/plist.rb +7 -3
- data/lib/chef/resource/portage_package.rb +2 -1
- data/lib/chef/resource/powershell_package.rb +0 -1
- data/lib/chef/resource/powershell_package_source.rb +0 -1
- data/lib/chef/resource/powershell_script.rb +0 -1
- data/lib/chef/resource/python.rb +0 -1
- data/lib/chef/resource/reboot.rb +0 -1
- data/lib/chef/resource/registry_key.rb +0 -1
- data/lib/chef/resource/remote_directory.rb +0 -1
- data/lib/chef/resource/remote_file.rb +0 -1
- data/lib/chef/resource/rhsm_errata.rb +0 -1
- data/lib/chef/resource/rhsm_errata_level.rb +0 -1
- data/lib/chef/resource/rhsm_register.rb +2 -4
- data/lib/chef/resource/rhsm_repo.rb +0 -1
- data/lib/chef/resource/rhsm_subscription.rb +0 -1
- data/lib/chef/resource/route.rb +0 -1
- data/lib/chef/resource/rpm_package.rb +2 -1
- data/lib/chef/resource/ruby.rb +0 -1
- data/lib/chef/resource/ruby_block.rb +0 -1
- data/lib/chef/resource/scm/_scm.rb +0 -2
- data/lib/chef/resource/scm/git.rb +0 -2
- data/lib/chef/resource/scm/subversion.rb +0 -2
- data/lib/chef/resource/script.rb +0 -1
- data/lib/chef/resource/selinux/common_helpers.rb +47 -0
- data/lib/chef/resource/selinux/selinux_debian.erb +18 -0
- data/lib/chef/resource/selinux/selinux_default.erb +15 -0
- data/lib/chef/resource/selinux_boolean.rb +101 -0
- data/lib/chef/resource/selinux_fcontext.rb +160 -0
- data/lib/chef/resource/selinux_install.rb +107 -0
- data/lib/chef/resource/selinux_module.rb +143 -0
- data/lib/chef/resource/selinux_permissive.rb +64 -0
- data/lib/chef/resource/selinux_port.rb +118 -0
- data/lib/chef/resource/selinux_state.rb +166 -0
- data/lib/chef/resource/service.rb +0 -1
- data/lib/chef/resource/smartos_package.rb +2 -1
- data/lib/chef/resource/snap_package.rb +2 -1
- data/lib/chef/resource/solaris_package.rb +2 -1
- data/lib/chef/resource/ssh_known_hosts_entry.rb +0 -1
- data/lib/chef/resource/sudo.rb +0 -1
- data/lib/chef/resource/support/client.erb +2 -2
- data/lib/chef/resource/swap_file.rb +0 -1
- data/lib/chef/resource/sysctl.rb +1 -2
- data/lib/chef/resource/systemd_unit.rb +0 -1
- data/lib/chef/resource/template.rb +0 -1
- data/lib/chef/resource/timezone.rb +0 -1
- data/lib/chef/resource/user/aix_user.rb +0 -1
- data/lib/chef/resource/user/linux_user.rb +0 -1
- data/lib/chef/resource/user/mac_user.rb +0 -1
- data/lib/chef/resource/user/pw_user.rb +0 -1
- data/lib/chef/resource/user/solaris_user.rb +0 -1
- data/lib/chef/resource/user/windows_user.rb +0 -1
- data/lib/chef/resource/user.rb +10 -1
- data/lib/chef/resource/user_ulimit.rb +0 -1
- data/lib/chef/resource/whyrun_safe_ruby_block.rb +0 -1
- data/lib/chef/resource/windows_ad_join.rb +0 -2
- data/lib/chef/resource/windows_audit_policy.rb +0 -2
- data/lib/chef/resource/windows_auto_run.rb +0 -1
- data/lib/chef/resource/windows_defender.rb +0 -1
- data/lib/chef/resource/windows_defender_exclusion.rb +0 -1
- data/lib/chef/resource/windows_dfs_folder.rb +0 -1
- data/lib/chef/resource/windows_dfs_namespace.rb +0 -1
- data/lib/chef/resource/windows_dfs_server.rb +0 -1
- data/lib/chef/resource/windows_dns_record.rb +0 -1
- data/lib/chef/resource/windows_dns_zone.rb +0 -1
- data/lib/chef/resource/windows_env.rb +0 -1
- data/lib/chef/resource/windows_feature.rb +0 -1
- data/lib/chef/resource/windows_feature_dism.rb +0 -1
- data/lib/chef/resource/windows_feature_powershell.rb +0 -1
- data/lib/chef/resource/windows_firewall_profile.rb +0 -2
- data/lib/chef/resource/windows_firewall_rule.rb +0 -1
- data/lib/chef/resource/windows_font.rb +2 -3
- data/lib/chef/resource/windows_package.rb +3 -4
- data/lib/chef/resource/windows_pagefile.rb +0 -2
- data/lib/chef/resource/windows_path.rb +0 -1
- data/lib/chef/resource/windows_printer.rb +0 -1
- data/lib/chef/resource/windows_printer_port.rb +0 -1
- data/lib/chef/resource/windows_script.rb +0 -2
- data/lib/chef/resource/windows_security_policy.rb +0 -1
- data/lib/chef/resource/windows_service.rb +0 -1
- data/lib/chef/resource/windows_share.rb +0 -1
- data/lib/chef/resource/windows_shortcut.rb +1 -2
- data/lib/chef/resource/windows_task.rb +0 -1
- data/lib/chef/resource/windows_uac.rb +0 -1
- data/lib/chef/resource/windows_update_settings.rb +0 -1
- data/lib/chef/resource/windows_user_privilege.rb +0 -1
- data/lib/chef/resource/windows_workgroup.rb +0 -1
- data/lib/chef/resource/yum_package.rb +2 -1
- data/lib/chef/resource/yum_repository.rb +4 -1
- data/lib/chef/resource/zypper_package.rb +2 -1
- data/lib/chef/resource/zypper_repository.rb +0 -1
- data/lib/chef/resource.rb +12 -5
- data/lib/chef/resources.rb +7 -0
- data/lib/chef/run_context.rb +3 -3
- data/lib/chef/secret_fetcher/azure_key_vault.rb +3 -3
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/handle.rb +6 -7
- data/lib/chef/win32/registry.rb +7 -3
- data/spec/data/chef_guid +1 -0
- data/spec/data/nodes/mcwfhpowell.json +3 -0
- data/spec/data/rubygems.org/sexp_processor-info +2 -1
- data/spec/data/trusted_certs/example.crt +20 -29
- data/spec/data/trusted_certs/example_no_cn.crt +34 -30
- data/spec/data/trusted_certs/opscode.pem +54 -33
- data/spec/functional/assets/yumrepo-empty/repodata/01a3b489a465bcac22a43492163df43451dc6ce47d27f66de289756b91635523-filelists.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo-empty/repodata/401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93-filelists.xml.gz +0 -0
- data/spec/functional/assets/yumrepo-empty/repodata/5dc1e6e73c84803f059bb3065e684e56adfc289a7e398946574d79dac6643945-primary.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo-empty/repodata/6bf9672d0862e8ef8b8ff05a2fd0208a922b1f5978e6589d87944c88259cb670-other.xml.gz +0 -0
- data/spec/functional/assets/yumrepo-empty/repodata/7c36572015e075add2b38b900837bcdbb8a504130ddff49b2351a7fc0affa3d4-other.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo-empty/repodata/dabe2ce5481d23de1f4f52bdcfee0f9af98316c9e0de2ce8123adeefa0dd08b9-primary.xml.gz +0 -0
- data/spec/functional/assets/yumrepo-empty/repodata/repomd.xml +55 -0
- data/spec/functional/resource/chocolatey_package_spec.rb +20 -32
- data/spec/functional/resource/dsc_script_spec.rb +1 -1
- data/spec/functional/resource/group_spec.rb +10 -6
- data/spec/functional/resource/link_spec.rb +8 -8
- data/spec/functional/resource/macos_userdefaults_spec.rb +4 -4
- data/spec/functional/resource/plist_spec.rb +25 -0
- data/spec/functional/resource/user/linux_user_spec.rb +127 -0
- data/spec/functional/resource/windows_certificate_spec.rb +1 -26
- data/spec/functional/resource/windows_font_spec.rb +12 -9
- data/spec/functional/resource/yum_package_spec.rb +17 -1
- data/spec/functional/resource/zypper_package_spec.rb +12 -0
- data/spec/functional/shell_spec.rb +1 -2
- data/spec/functional/version_spec.rb +1 -1
- data/spec/integration/client/client_spec.rb +82 -3
- data/spec/integration/client/exit_code_spec.rb +1 -1
- data/spec/integration/client/fips_spec.rb +20 -0
- data/spec/integration/client/ipv6_spec.rb +1 -1
- data/spec/integration/compliance/compliance_spec.rb +1 -1
- data/spec/integration/recipes/accumulator_spec.rb +1 -1
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
- data/spec/integration/recipes/lwrp_spec.rb +1 -1
- data/spec/integration/recipes/notifies_spec.rb +1 -1
- data/spec/integration/recipes/notifying_block_spec.rb +1 -1
- data/spec/integration/recipes/remote_directory.rb +1 -1
- data/spec/integration/recipes/unified_mode_spec.rb +1 -1
- data/spec/integration/recipes/use_partial_spec.rb +2 -1
- data/spec/integration/solo/solo_spec.rb +2 -2
- data/spec/spec_helper.rb +5 -0
- data/spec/support/platform_helpers.rb +8 -0
- data/spec/support/ruby_installer.rb +1 -1
- data/spec/support/shared/functional/windows_script.rb +2 -2
- data/spec/unit/application/client_spec.rb +0 -10
- data/spec/unit/chef_fs/file_system_spec.rb +2 -0
- data/spec/unit/client_spec.rb +57 -8
- data/spec/unit/compliance/reporter/chef_server_automate_spec.rb +1 -1
- data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
- data/spec/unit/http/authenticator_spec.rb +68 -0
- data/spec/unit/mixin/powershell_exec_spec.rb +5 -5
- data/spec/unit/platform/query_helpers_spec.rb +2 -17
- data/spec/unit/property/validation_spec.rb +30 -0
- data/spec/unit/provider/cron_spec.rb +36 -0
- data/spec/unit/provider/http_request_spec.rb +60 -72
- data/spec/unit/provider/mount/linux_spec.rb +10 -0
- data/spec/unit/provider/package/chocolatey_spec.rb +3 -19
- data/spec/unit/provider/package/rubygems_spec.rb +1 -1
- data/spec/unit/provider/package/zypper_spec.rb +32 -0
- data/spec/unit/provider/user/linux_spec.rb +51 -11
- data/spec/unit/provider/user_spec.rb +24 -6
- data/spec/unit/resource/archive_file_spec.rb +1 -1
- data/spec/unit/resource/chef_client_cron_spec.rb +5 -0
- data/spec/unit/resource/chef_client_launchd_spec.rb +5 -0
- data/spec/unit/resource/chef_client_scheduled_task_spec.rb +5 -0
- data/spec/unit/resource/chef_client_systemd_timer_spec.rb +1 -1
- data/spec/unit/resource/cron_d_spec.rb +37 -1
- data/spec/unit/resource/macos_user_defaults_spec.rb +4 -4
- data/spec/unit/resource/rest_resource_spec.rb +381 -0
- data/spec/unit/resource/selinux_boolean_spec.rb +92 -0
- data/spec/unit/resource/selinux_fcontext_spec.rb +65 -0
- data/spec/unit/resource/selinux_install_spec.rb +60 -0
- data/spec/unit/resource/selinux_module_spec.rb +55 -0
- data/spec/unit/resource/selinux_permissive_spec.rb +39 -0
- data/spec/unit/resource/selinux_port_spec.rb +42 -0
- data/spec/unit/resource/selinux_state_spec.rb +46 -0
- data/spec/unit/resource/sysctl_spec.rb +2 -2
- data/spec/unit/resource/user/linux_user_spec.rb +42 -0
- data/spec/unit/resource/yum_repository_spec.rb +4 -0
- data/spec/unit/resource_spec.rb +0 -1
- data/spec/unit/util/dsc/local_configuration_manager_spec.rb +1 -1
- data/tasks/rspec.rb +1 -1
- metadata +107 -31
- /data/spec/functional/assets/chocolatey_feed/{test-A.1.0.0.nupkg → test-A.1.0.nupkg} +0 -0
- /data/spec/functional/assets/chocolatey_feed/{test-A.1.5.0.nupkg → test-A.1.5.nupkg} +0 -0
- /data/spec/functional/assets/chocolatey_feed/{test-A.2.0.0.nupkg → test-A.2.0.nupkg} +0 -0
- /data/spec/functional/assets/chocolatey_feed/{test-B.1.0.0.nupkg → test-B.1.0.nupkg} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{01a3b-filelists.sqlite.bz2 → 4632d67cb92636e7575d911c24f0e04d3505a944e97c483abe0c3e73a7c62d33-filelists.sqlite.bz2} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{6bf96-other.xml.gz → 74599b793e54d877323837d2d81a1c3c594c44e4335f9528234bb490f7b9b439-other.xml.gz} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{5dc1e-primary.sqlite.bz2 → a845d418f919d2115ab95a56b2c76f6825ad0d0bede49181a55c04f58995d057-primary.sqlite.bz2} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{7c365-other.sqlite.bz2 → af9b7cf9ef23bd7b43068d74a460f3b5d06753d638e58e4a0c9edc35bfb9cdc4-other.sqlite.bz2} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{401dc-filelists.xml.gz → bdb4f5f1492a3b9532f22c43110a81500dd744f23da0aec5c33b2a41317c737d-filelists.xml.gz} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{dabe2-primary.xml.gz → c10d1d34ce99e02f12ec96ef68360543ab1bb7c3cb81a4a2bf78df7d8597e9df-primary.xml.gz} +0 -0
|
@@ -248,8 +248,8 @@ class Chef
|
|
|
248
248
|
# Debugs ruby syntax errors by printing the path to the file and any
|
|
249
249
|
# diagnostic info given in +error_message+
|
|
250
250
|
def invalid_ruby_file(ruby_file, error_message)
|
|
251
|
-
file_relative_path = ruby_file[
|
|
252
|
-
Chef::Log.fatal("Cookbook file #{file_relative_path} has a ruby syntax error
|
|
251
|
+
file_relative_path = ruby_file[ruby_file.index(cookbook_path.split("/").last), ruby_file.length]
|
|
252
|
+
Chef::Log.fatal("Cookbook file #{file_relative_path} has a ruby syntax error.")
|
|
253
253
|
error_message.each_line { |l| Chef::Log.fatal(l.chomp) }
|
|
254
254
|
false
|
|
255
255
|
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright:: Copyright 2008-2016, Chef, Inc.
|
|
3
|
+
# License:: Apache License, Version 2.0
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#
|
|
17
|
+
|
|
18
|
+
require "chef/constants" unless defined?(NOT_PASSED)
|
|
19
|
+
|
|
20
|
+
class Chef
|
|
21
|
+
module DSL
|
|
22
|
+
module RestResource
|
|
23
|
+
def rest_property_map(rest_property_map = NOT_PASSED)
|
|
24
|
+
if rest_property_map != NOT_PASSED
|
|
25
|
+
rest_property_map = rest_property_map.to_h { |k| [k.to_sym, k] } if rest_property_map.is_a? Array
|
|
26
|
+
|
|
27
|
+
@rest_property_map = rest_property_map
|
|
28
|
+
end
|
|
29
|
+
@rest_property_map
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# URL to collection
|
|
33
|
+
def rest_api_collection(rest_api_collection = NOT_PASSED)
|
|
34
|
+
if rest_api_collection != NOT_PASSED
|
|
35
|
+
raise ArgumentError, "You must pass an absolute path to rest_api_collection" unless rest_api_collection.start_with? "/"
|
|
36
|
+
|
|
37
|
+
@rest_api_collection = rest_api_collection
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
@rest_api_collection
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# RFC6570-Templated URL to document
|
|
44
|
+
def rest_api_document(rest_api_document = NOT_PASSED, first_element_only: false)
|
|
45
|
+
if rest_api_document != NOT_PASSED
|
|
46
|
+
raise ArgumentError, "You must pass an absolute path to rest_api_document" unless rest_api_document.start_with? "/"
|
|
47
|
+
|
|
48
|
+
@rest_api_document = rest_api_document
|
|
49
|
+
@rest_api_document_first_element_only = first_element_only
|
|
50
|
+
end
|
|
51
|
+
@rest_api_document
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Explicit REST document identity mapping
|
|
55
|
+
def rest_identity_map(rest_identity_map = NOT_PASSED)
|
|
56
|
+
@rest_identity_map = rest_identity_map if rest_identity_map != NOT_PASSED
|
|
57
|
+
@rest_identity_map
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Mark up properties for POST only, not PATCH/PUT
|
|
61
|
+
def rest_post_only_properties(rest_post_only_properties = NOT_PASSED)
|
|
62
|
+
if rest_post_only_properties != NOT_PASSED
|
|
63
|
+
@rest_post_only_properties = Array(rest_post_only_properties).map(&:to_sym)
|
|
64
|
+
end
|
|
65
|
+
@rest_post_only_properties || []
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def rest_api_document_first_element_only(rest_api_document_first_element_only = NOT_PASSED)
|
|
69
|
+
if rest_api_document_first_element_only != NOT_PASSED
|
|
70
|
+
@rest_api_document_first_element_only = rest_api_document_first_element_only
|
|
71
|
+
end
|
|
72
|
+
@rest_api_document_first_element_only
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -273,6 +273,9 @@ class Chef
|
|
|
273
273
|
# Called if the converge phase fails
|
|
274
274
|
def converge_failed(exception); end
|
|
275
275
|
|
|
276
|
+
# Called when migrating from a pem on disk to a pem stored in Keychain or Windows Certstore
|
|
277
|
+
def key_migration_status(key_migrated = false); end
|
|
278
|
+
|
|
276
279
|
# TODO: need events for notification resolve?
|
|
277
280
|
# def notifications_resolved
|
|
278
281
|
# end
|
data/lib/chef/exceptions.rb
CHANGED
|
@@ -561,5 +561,13 @@ class Chef
|
|
|
561
561
|
super "before subscription from #{notification.resource} resource cannot be setup to #{notification.notifying_resource} resource, which has already fired while in unified mode"
|
|
562
562
|
end
|
|
563
563
|
end
|
|
564
|
+
|
|
565
|
+
class RestError < RuntimeError; end
|
|
566
|
+
|
|
567
|
+
class RestTargetError < RestError; end
|
|
568
|
+
|
|
569
|
+
class RestTimeout < RestError; end
|
|
570
|
+
|
|
571
|
+
class RestOperationFailed < RestError; end
|
|
564
572
|
end
|
|
565
573
|
end
|
|
@@ -16,16 +16,19 @@
|
|
|
16
16
|
# limitations under the License.
|
|
17
17
|
#
|
|
18
18
|
|
|
19
|
+
require "chef/mixin/powershell_exec"
|
|
19
20
|
require_relative "auth_credentials"
|
|
20
21
|
require_relative "../exceptions"
|
|
22
|
+
require_relative "../win32/registry"
|
|
21
23
|
autoload :OpenSSL, "openssl"
|
|
22
24
|
|
|
23
25
|
class Chef
|
|
24
26
|
class HTTP
|
|
25
27
|
class Authenticator
|
|
26
|
-
|
|
27
28
|
DEFAULT_SERVER_API_VERSION = "2".freeze
|
|
28
29
|
|
|
30
|
+
extend Chef::Mixin::PowershellExec
|
|
31
|
+
|
|
29
32
|
attr_reader :signing_key_filename
|
|
30
33
|
attr_reader :raw_key
|
|
31
34
|
attr_reader :attr_names
|
|
@@ -83,13 +86,69 @@ class Chef
|
|
|
83
86
|
@auth_credentials.client_name
|
|
84
87
|
end
|
|
85
88
|
|
|
89
|
+
def detect_certificate_key(client_name)
|
|
90
|
+
self.class.detect_certificate_key(client_name)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def check_certstore_for_key(client_name)
|
|
94
|
+
self.class.check_certstore_for_key(client_name)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def retrieve_certificate_key(client_name)
|
|
98
|
+
self.class.retrieve_certificate_key(client_name)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def get_cert_password
|
|
102
|
+
self.class.get_cert_password
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def encrypt_pfx_pass
|
|
106
|
+
self.class.encrypt_pfx_pass
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def decrypt_pfx_pass
|
|
110
|
+
self.class.decrypt_pfx_pass
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Detects if a private key exists in a certificate repository like Keychain (macOS) or Certificate Store (Windows)
|
|
114
|
+
#
|
|
115
|
+
# @param client_name - we're using the node name to store and retrieve any keys
|
|
116
|
+
# Returns true if a key is found, false if not. False will trigger a registration event which will lead to a certificate based key being created
|
|
117
|
+
#
|
|
118
|
+
def self.detect_certificate_key(client_name)
|
|
119
|
+
if ChefUtils.windows?
|
|
120
|
+
check_certstore_for_key(client_name)
|
|
121
|
+
else # generic return for Mac and LInux clients
|
|
122
|
+
false
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def self.check_certstore_for_key(client_name)
|
|
127
|
+
powershell_code = <<~CODE
|
|
128
|
+
$cert = Get-ChildItem -path cert:\\LocalMachine\\My -Recurse -Force | Where-Object { $_.Subject -Match "chef-#{client_name}" } -ErrorAction Stop
|
|
129
|
+
if (($cert.HasPrivateKey -eq $true) -and ($cert.PrivateKey.Key.ExportPolicy -ne "NonExportable")) {
|
|
130
|
+
return $true
|
|
131
|
+
}
|
|
132
|
+
else{
|
|
133
|
+
return $false
|
|
134
|
+
}
|
|
135
|
+
CODE
|
|
136
|
+
powershell_exec!(powershell_code).result
|
|
137
|
+
end
|
|
138
|
+
|
|
86
139
|
def load_signing_key(key_file, raw_key = nil)
|
|
87
|
-
|
|
140
|
+
results = retrieve_certificate_key(Chef::Config[:node_name])
|
|
141
|
+
|
|
142
|
+
if !!results
|
|
143
|
+
@raw_key = results
|
|
144
|
+
elsif key_file == nil? && raw_key == nil?
|
|
145
|
+
puts "\nNo key detected\n"
|
|
146
|
+
elsif !!key_file
|
|
88
147
|
@raw_key = IO.read(key_file).strip
|
|
89
148
|
elsif !!raw_key
|
|
90
149
|
@raw_key = raw_key.strip
|
|
91
150
|
else
|
|
92
|
-
return
|
|
151
|
+
return
|
|
93
152
|
end
|
|
94
153
|
# Pass in '' as the passphrase to avoid OpenSSL prompting on the TTY if
|
|
95
154
|
# given an encrypted key. This also helps if using a single file for
|
|
@@ -104,6 +163,114 @@ class Chef
|
|
|
104
163
|
raise Chef::Exceptions::InvalidPrivateKey, msg
|
|
105
164
|
end
|
|
106
165
|
|
|
166
|
+
def self.get_cert_password
|
|
167
|
+
@win32registry = Chef::Win32::Registry.new
|
|
168
|
+
path = "HKEY_LOCAL_MACHINE\\Software\\Progress\\Authentication"
|
|
169
|
+
# does the registry key even exist?
|
|
170
|
+
present = @win32registry.get_values(path)
|
|
171
|
+
if present.nil? || present.empty?
|
|
172
|
+
raise Chef::Exceptions::Win32RegKeyMissing
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
present.each do |secret|
|
|
176
|
+
if secret[:name] == "PfxPass"
|
|
177
|
+
password = decrypt_pfx_pass(secret[:data])
|
|
178
|
+
return password
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
raise Chef::Exceptions::Win32RegKeyMissing
|
|
183
|
+
|
|
184
|
+
rescue Chef::Exceptions::Win32RegKeyMissing
|
|
185
|
+
# if we don't have a password, log that and generate one
|
|
186
|
+
Chef::Log.warn "Authentication Hive and values not present in registry, creating them now"
|
|
187
|
+
new_path = "HKEY_LOCAL_MACHINE\\Software\\Progress\\Authentication"
|
|
188
|
+
unless @win32registry.key_exists?(new_path)
|
|
189
|
+
@win32registry.create_key(new_path, true)
|
|
190
|
+
end
|
|
191
|
+
require "securerandom" unless defined?(SecureRandom)
|
|
192
|
+
size = 14
|
|
193
|
+
password = SecureRandom.alphanumeric(size)
|
|
194
|
+
encrypted_pass = encrypt_pfx_pass(password)
|
|
195
|
+
values = { name: "PfxPass", type: :string, data: encrypted_pass }
|
|
196
|
+
@win32registry.set_value(new_path, values)
|
|
197
|
+
password
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def self.encrypt_pfx_pass(password)
|
|
201
|
+
powershell_code = <<~CODE
|
|
202
|
+
$encrypted_string = ConvertTo-SecureString "#{password}" -AsPlainText -Force
|
|
203
|
+
$secure_string = ConvertFrom-SecureString $encrypted_string
|
|
204
|
+
return $secure_string
|
|
205
|
+
CODE
|
|
206
|
+
powershell_exec!(powershell_code).result
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def self.decrypt_pfx_pass(password)
|
|
210
|
+
powershell_code = <<~CODE
|
|
211
|
+
$secure_string = "#{password}" | ConvertTo-SecureString
|
|
212
|
+
$string = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR((($secure_string))))
|
|
213
|
+
return $string
|
|
214
|
+
CODE
|
|
215
|
+
powershell_exec!(powershell_code).result
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
def self.retrieve_certificate_key(client_name)
|
|
219
|
+
require "openssl" unless defined?(OpenSSL)
|
|
220
|
+
|
|
221
|
+
if ChefUtils.windows?
|
|
222
|
+
password = get_cert_password
|
|
223
|
+
return false unless password
|
|
224
|
+
|
|
225
|
+
if check_certstore_for_key(client_name)
|
|
226
|
+
ps_blob = powershell_exec!(get_the_key_ps(client_name, password)).result
|
|
227
|
+
file_path = ps_blob["PSPath"].split("::")[1]
|
|
228
|
+
pkcs = OpenSSL::PKCS12.new(File.binread(file_path), password)
|
|
229
|
+
|
|
230
|
+
# We check the pfx we just extracted the private key from
|
|
231
|
+
# if that cert is expiring in 7 days or less we generate a new pfx/p12 object
|
|
232
|
+
# then we post the new public key from that to the client endpoint on
|
|
233
|
+
# chef server.
|
|
234
|
+
File.delete(file_path)
|
|
235
|
+
key_expiring = is_certificate_expiring?(pkcs)
|
|
236
|
+
if key_expiring
|
|
237
|
+
powershell_exec!(delete_old_key_ps(client_name))
|
|
238
|
+
::Chef::Client.update_key_and_register(Chef::Config[:client_name], pkcs)
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
return pkcs.key.private_to_pem
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
false
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def self.is_certificate_expiring?(pkcs)
|
|
249
|
+
today = Date.parse(Time.now.utc.iso8601)
|
|
250
|
+
future = Date.parse(pkcs.certificate.not_after.iso8601)
|
|
251
|
+
future.mjd - today.mjd <= 7
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
def self.get_the_key_ps(client_name, password)
|
|
255
|
+
powershell_code = <<~CODE
|
|
256
|
+
Try {
|
|
257
|
+
$my_pwd = ConvertTo-SecureString -String "#{password}" -Force -AsPlainText;
|
|
258
|
+
$cert = Get-ChildItem -path cert:\\LocalMachine\\My -Recurse | Where-Object { $_.Subject -match "chef-#{client_name}$" } -ErrorAction Stop;
|
|
259
|
+
$tempfile = [System.IO.Path]::GetTempPath() + "export_pfx.pfx";
|
|
260
|
+
Export-PfxCertificate -Cert $cert -Password $my_pwd -FilePath $tempfile;
|
|
261
|
+
}
|
|
262
|
+
Catch {
|
|
263
|
+
return $false
|
|
264
|
+
}
|
|
265
|
+
CODE
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
def self.delete_old_key_ps(client_name)
|
|
269
|
+
powershell_code = <<~CODE
|
|
270
|
+
Get-ChildItem -path cert:\\LocalMachine\\My -Recurse | Where-Object { $_.Subject -match "chef-#{client_name}$" } | Remove-Item -ErrorAction Stop;
|
|
271
|
+
CODE
|
|
272
|
+
end
|
|
273
|
+
|
|
107
274
|
def authentication_headers(method, url, json_body = nil, headers = nil)
|
|
108
275
|
request_params = {
|
|
109
276
|
http_method: method,
|
|
@@ -88,10 +88,10 @@ class Chef
|
|
|
88
88
|
certs = Dir.glob(::File.join(Chef::Util::PathHelper.escape_glob_dir(config.trusted_certs_dir), "*.{crt,pem}"))
|
|
89
89
|
certs.each do |cert_file|
|
|
90
90
|
cert = begin
|
|
91
|
-
|
|
91
|
+
OpenSSL::X509::Certificate.new(::File.binread(cert_file))
|
|
92
92
|
rescue OpenSSL::X509::CertificateError => e
|
|
93
93
|
raise Chef::Exceptions::ConfigurationError, "Error reading cert file '#{cert_file}', original error '#{e.class}: #{e.message}'"
|
|
94
|
-
|
|
94
|
+
end
|
|
95
95
|
add_trusted_cert(cert)
|
|
96
96
|
end
|
|
97
97
|
end
|
|
@@ -132,7 +132,7 @@ class Chef
|
|
|
132
132
|
def add_trusted_cert(cert)
|
|
133
133
|
http_client.cert_store.add_cert(cert)
|
|
134
134
|
rescue OpenSSL::X509::StoreError => e
|
|
135
|
-
raise e unless e.message
|
|
135
|
+
raise e unless e.message =~ /cert already in hash table/
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
end
|
|
@@ -15,9 +15,6 @@
|
|
|
15
15
|
# See the License for the specific language governing permissions and
|
|
16
16
|
# limitations under the License.
|
|
17
17
|
|
|
18
|
-
require_relative "../powershell"
|
|
19
|
-
require_relative "../pwsh"
|
|
20
|
-
|
|
21
18
|
# The powershell_exec mixin provides in-process access to the PowerShell engine.
|
|
22
19
|
#
|
|
23
20
|
# powershell_exec is initialized with a string that should be set to the script
|
|
@@ -94,35 +91,15 @@ require_relative "../pwsh"
|
|
|
94
91
|
# - It is not possible to impersonate another user running powershell, the
|
|
95
92
|
# credentials of the user running Chef Client are used.
|
|
96
93
|
#
|
|
94
|
+
if ChefUtils.windows?
|
|
95
|
+
require "chef-powershell"
|
|
96
|
+
end
|
|
97
97
|
|
|
98
98
|
class Chef
|
|
99
99
|
module Mixin
|
|
100
100
|
module PowershellExec
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
# Requires: .NET Framework 4.0 or higher on the target machine.
|
|
104
|
-
#
|
|
105
|
-
# @param script [String] script to run
|
|
106
|
-
# @param interpreter [Symbol] the interpreter type, `:powershell` or `:pwsh`
|
|
107
|
-
# @param timeout [Integer, nil] timeout in seconds.
|
|
108
|
-
# @return [Chef::PowerShell] output
|
|
109
|
-
def powershell_exec(script, interpreter = :powershell, timeout: -1)
|
|
110
|
-
case interpreter
|
|
111
|
-
when :powershell
|
|
112
|
-
Chef::PowerShell.new(script, timeout: timeout)
|
|
113
|
-
when :pwsh
|
|
114
|
-
Chef::Pwsh.new(script, timeout: timeout)
|
|
115
|
-
else
|
|
116
|
-
raise ArgumentError, "Expected interpreter of :powershell or :pwsh"
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
# The same as the #powershell_exec method except this will raise
|
|
121
|
-
# Chef::PowerShell::CommandFailed if the command fails
|
|
122
|
-
def powershell_exec!(script, interpreter = :powershell, **options)
|
|
123
|
-
cmd = powershell_exec(script, interpreter, **options)
|
|
124
|
-
cmd.error!
|
|
125
|
-
cmd
|
|
101
|
+
if ChefUtils.windows?
|
|
102
|
+
include ChefPowerShell::ChefPowerShellModule::PowerShellExec
|
|
126
103
|
end
|
|
127
104
|
end
|
|
128
105
|
end
|
data/lib/chef/property.rb
CHANGED
|
@@ -113,9 +113,11 @@ class Chef
|
|
|
113
113
|
# and the transformed value returned as output. Lazy values will *not*
|
|
114
114
|
# be passed to this method until after they are evaluated. Called in the
|
|
115
115
|
# context of the resource (meaning you can access other properties).
|
|
116
|
-
# @option options [Boolean] :required `true` if this property
|
|
117
|
-
# must be present; `false` otherwise.
|
|
118
|
-
# is
|
|
116
|
+
# @option options [Boolean, Array<Symbol>] :required `true` if this property
|
|
117
|
+
# must be present for *all* actions; `false` otherwise. Alternatively
|
|
118
|
+
# you may specify a list of actions the property is required for, when
|
|
119
|
+
# the property is only required for a subset of actions. This is checked
|
|
120
|
+
# after the resource is fully initialized.
|
|
119
121
|
# @option options [String] :deprecated If set, this property is deprecated and
|
|
120
122
|
# will create a deprecation warning.
|
|
121
123
|
#
|
|
@@ -305,7 +307,7 @@ class Chef
|
|
|
305
307
|
#
|
|
306
308
|
def required?(action = nil)
|
|
307
309
|
if !action.nil? && options[:required].is_a?(Array)
|
|
308
|
-
options[:required]
|
|
310
|
+
(options[:required] & Array(action)).any?
|
|
309
311
|
else
|
|
310
312
|
!!options[:required]
|
|
311
313
|
end
|
|
@@ -424,7 +426,7 @@ class Chef
|
|
|
424
426
|
end
|
|
425
427
|
end
|
|
426
428
|
|
|
427
|
-
if value.nil? && required?
|
|
429
|
+
if value.nil? && required?(resource_action(resource))
|
|
428
430
|
raise Chef::Exceptions::ValidationFailed, "#{name} is a required property"
|
|
429
431
|
else
|
|
430
432
|
value
|
|
@@ -453,7 +455,7 @@ class Chef
|
|
|
453
455
|
Chef.deprecated(:property, options[:deprecated])
|
|
454
456
|
end
|
|
455
457
|
|
|
456
|
-
if value.nil? && required?
|
|
458
|
+
if value.nil? && required?(resource_action(resource))
|
|
457
459
|
raise Chef::Exceptions::ValidationFailed, "#{name} is a required property"
|
|
458
460
|
else
|
|
459
461
|
value
|
|
@@ -766,5 +768,10 @@ class Chef
|
|
|
766
768
|
end
|
|
767
769
|
visitor.call(value)
|
|
768
770
|
end
|
|
771
|
+
|
|
772
|
+
# action from resource, if available
|
|
773
|
+
def resource_action(resource)
|
|
774
|
+
resource.action if resource.respond_to?(:action)
|
|
775
|
+
end
|
|
769
776
|
end
|
|
770
777
|
end
|
data/lib/chef/provider/cron.rb
CHANGED
|
@@ -88,7 +88,11 @@ class Chef
|
|
|
88
88
|
|
|
89
89
|
def cron_different?
|
|
90
90
|
CRON_ATTRIBUTES.any? do |cron_var|
|
|
91
|
-
new_resource.send(cron_var)
|
|
91
|
+
if new_resource.send(cron_var).class == current_resource.send(cron_var).class
|
|
92
|
+
new_resource.send(cron_var) != current_resource.send(cron_var)
|
|
93
|
+
else
|
|
94
|
+
new_resource.send(cron_var).to_s != current_resource.send(cron_var).to_s
|
|
95
|
+
end
|
|
92
96
|
end
|
|
93
97
|
end
|
|
94
98
|
|
|
@@ -25,18 +25,20 @@ class Chef
|
|
|
25
25
|
|
|
26
26
|
provides :http_request
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
attr_writer :http
|
|
29
29
|
|
|
30
|
-
def
|
|
31
|
-
@http
|
|
30
|
+
def http
|
|
31
|
+
@http ||= Chef::HTTP::Simple.new(new_resource.url)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
def load_current_resource; end
|
|
35
|
+
|
|
34
36
|
# Send a HEAD request to new_resource.url
|
|
35
37
|
action :head do
|
|
36
38
|
message = check_message(new_resource.message)
|
|
37
39
|
# CHEF-4762: we expect a nil return value from Chef::HTTP for a "200 Success" response
|
|
38
40
|
# and false for a "304 Not Modified" response
|
|
39
|
-
modified =
|
|
41
|
+
modified = http.head(
|
|
40
42
|
(new_resource.url).to_s,
|
|
41
43
|
new_resource.headers
|
|
42
44
|
)
|
|
@@ -53,7 +55,7 @@ class Chef
|
|
|
53
55
|
converge_by("#{new_resource} GET to #{new_resource.url}") do
|
|
54
56
|
|
|
55
57
|
message = check_message(new_resource.message)
|
|
56
|
-
body =
|
|
58
|
+
body = http.get(
|
|
57
59
|
(new_resource.url).to_s,
|
|
58
60
|
new_resource.headers
|
|
59
61
|
)
|
|
@@ -66,7 +68,7 @@ class Chef
|
|
|
66
68
|
action :patch do
|
|
67
69
|
converge_by("#{new_resource} PATCH to #{new_resource.url}") do
|
|
68
70
|
message = check_message(new_resource.message)
|
|
69
|
-
body =
|
|
71
|
+
body = http.patch(
|
|
70
72
|
(new_resource.url).to_s,
|
|
71
73
|
message,
|
|
72
74
|
new_resource.headers
|
|
@@ -80,7 +82,7 @@ class Chef
|
|
|
80
82
|
action :put do
|
|
81
83
|
converge_by("#{new_resource} PUT to #{new_resource.url}") do
|
|
82
84
|
message = check_message(new_resource.message)
|
|
83
|
-
body =
|
|
85
|
+
body = http.put(
|
|
84
86
|
(new_resource.url).to_s,
|
|
85
87
|
message,
|
|
86
88
|
new_resource.headers
|
|
@@ -94,7 +96,7 @@ class Chef
|
|
|
94
96
|
action :post do
|
|
95
97
|
converge_by("#{new_resource} POST to #{new_resource.url}") do
|
|
96
98
|
message = check_message(new_resource.message)
|
|
97
|
-
body =
|
|
99
|
+
body = http.post(
|
|
98
100
|
(new_resource.url).to_s,
|
|
99
101
|
message,
|
|
100
102
|
new_resource.headers
|
|
@@ -107,7 +109,7 @@ class Chef
|
|
|
107
109
|
# Send a DELETE request to new_resource.url
|
|
108
110
|
action :delete do
|
|
109
111
|
converge_by("#{new_resource} DELETE to #{new_resource.url}") do
|
|
110
|
-
body =
|
|
112
|
+
body = http.delete(
|
|
111
113
|
(new_resource.url).to_s,
|
|
112
114
|
new_resource.headers
|
|
113
115
|
)
|
|
@@ -153,6 +153,7 @@ class Chef
|
|
|
153
153
|
"program" => "Program",
|
|
154
154
|
"program_arguments" => "ProgramArguments",
|
|
155
155
|
"abandon_process_group" => "AbandonProcessGroup",
|
|
156
|
+
"associated_bundle_identifiers" => "AssociatedBundleIdentifiers",
|
|
156
157
|
"debug" => "Debug",
|
|
157
158
|
"disabled" => "Disabled",
|
|
158
159
|
"enable_globbing" => "EnableGlobbing",
|
|
@@ -71,6 +71,11 @@ class Chef
|
|
|
71
71
|
when /\A#{Regexp.escape(real_mount_point)}\s+#{device_mount_regex}\[/
|
|
72
72
|
mounted = true
|
|
73
73
|
logger.trace("Network device #{device_logstring} mounted as #{real_mount_point}")
|
|
74
|
+
# Permalink for network device mounted with a space in device name https://rubular.com/r/CK5zWWms96CRES
|
|
75
|
+
# See the comment in "device_with_space_escape" for an explanation what's going here.
|
|
76
|
+
when /\A#{Regexp.escape(real_mount_point)}\s+#{device_with_space_escape}\s/
|
|
77
|
+
mounted = true
|
|
78
|
+
logger.trace("Network device #{device_logstring} mounted as #{real_mount_point}")
|
|
74
79
|
end
|
|
75
80
|
end
|
|
76
81
|
@current_resource.mounted(mounted)
|
|
@@ -217,6 +217,14 @@ class Chef
|
|
|
217
217
|
end
|
|
218
218
|
end
|
|
219
219
|
|
|
220
|
+
def device_with_space_escape
|
|
221
|
+
# For CIFS (and perhaps other remote network mounts) when a space is in the "device name"
|
|
222
|
+
# It will appear with the space substituted with a special character. However, when mounting,
|
|
223
|
+
# The mount needs to be done with an actual space. This function provides the device name with
|
|
224
|
+
# The special character to determine if the device is mounted.
|
|
225
|
+
device_mount_regex.gsub(" ", "\\x20")
|
|
226
|
+
end
|
|
227
|
+
|
|
220
228
|
def device_mount_regex
|
|
221
229
|
if network_device?
|
|
222
230
|
# ignore trailing slash
|
|
@@ -130,21 +130,6 @@ class Chef
|
|
|
130
130
|
# install from, but like the rubygem provider's sources which are more like repos.
|
|
131
131
|
def check_resource_semantics!; end
|
|
132
132
|
|
|
133
|
-
def self.get_choco_version
|
|
134
|
-
@get_choco_version ||= powershell_exec!("choco --version").result
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
# Choco V2 uses 'Search' for remote repositories and 'List' for local packages
|
|
138
|
-
def self.query_command
|
|
139
|
-
return "list" if get_choco_version.match?(/^1/)
|
|
140
|
-
|
|
141
|
-
"search"
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
def query_command
|
|
145
|
-
self.class.query_command
|
|
146
|
-
end
|
|
147
|
-
|
|
148
133
|
private
|
|
149
134
|
|
|
150
135
|
def version_compare(v1, v2)
|
|
@@ -240,7 +225,7 @@ class Chef
|
|
|
240
225
|
package_name_array.each do |pkg|
|
|
241
226
|
available_versions =
|
|
242
227
|
begin
|
|
243
|
-
cmd = [
|
|
228
|
+
cmd = [ "list", "-r", pkg ]
|
|
244
229
|
cmd += common_options
|
|
245
230
|
cmd.push( new_resource.list_options ) if new_resource.list_options
|
|
246
231
|
|
|
@@ -257,8 +242,6 @@ class Chef
|
|
|
257
242
|
# Installed packages in chocolatey as a Hash of names mapped to versions
|
|
258
243
|
# (names are downcased for case-insensitive matching)
|
|
259
244
|
#
|
|
260
|
-
# Beginning with Choco 2.0, "list" returns local packages only while "search" returns packages from external package sources
|
|
261
|
-
#
|
|
262
245
|
# @return [Hash] name-to-version mapping of installed packages
|
|
263
246
|
def installed_packages
|
|
264
247
|
@installed_packages ||= Hash[*parse_list_output("list", "-l", "-r").flatten]
|
|
@@ -92,7 +92,7 @@ class Chef
|
|
|
92
92
|
#
|
|
93
93
|
def installed_versions(gem_dep)
|
|
94
94
|
rubygems_version = Gem::Version.new(Gem::VERSION)
|
|
95
|
-
if rubygems_version >= Gem::Version.new("
|
|
95
|
+
if rubygems_version >= Gem::Version.new("3.1")
|
|
96
96
|
# In newer Rubygems, bundler is now a "default gem" which means
|
|
97
97
|
# even with AlternateGemEnvironment when you try to get the
|
|
98
98
|
# installed versions, you get the one from Chef's Ruby's default
|