chef 17.10.163 → 18.7.10
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 +25 -21
- data/README.md +7 -7
- data/Rakefile +3 -22
- data/{chef-universal-mingw32.gemspec → chef-universal-mingw-ucrt.gemspec} +7 -6
- data/chef.gemspec +33 -27
- data/lib/chef/api_client_v1.rb +9 -1
- data/lib/chef/application/base.rb +20 -2
- data/lib/chef/application/exit_code.rb +3 -3
- data/lib/chef/chef_fs/file_pattern.rb +1 -1
- data/lib/chef/chef_fs/file_system.rb +21 -7
- data/lib/chef/chef_fs/path_utils.rb +7 -9
- data/lib/chef/client.rb +186 -2
- data/lib/chef/compliance/default_attributes.rb +2 -2
- 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/runner.rb +6 -1
- data/lib/chef/compliance/waiver.rb +1 -1
- data/lib/chef/cookbook/chefignore.rb +4 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
- data/lib/chef/cookbook/metadata.rb +1 -1
- data/lib/chef/cookbook/remote_file_vendor.rb +1 -3
- data/lib/chef/cookbook/synchronizer.rb +21 -3
- data/lib/chef/cookbook/syntax_check.rb +2 -2
- data/lib/chef/cookbook_manifest.rb +2 -2
- data/lib/chef/cookbook_version.rb +1 -1
- data/lib/chef/data_collector.rb +14 -0
- data/lib/chef/delayed_evaluator.rb +4 -0
- 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/event_dispatch/dispatcher.rb +0 -1
- data/lib/chef/exceptions.rb +9 -1
- data/lib/chef/file_access_control/windows.rb +4 -1
- data/lib/chef/file_cache.rb +17 -2
- data/lib/chef/formatters/doc.rb +1 -1
- data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +2 -0
- data/lib/chef/http/authenticator.rb +253 -3
- data/lib/chef/http/ssl_policies.rb +2 -2
- data/lib/chef/mixin/{homebrew_user.rb → homebrew.rb} +13 -16
- data/lib/chef/mixin/openssl_helper.rb +1 -16
- data/lib/chef/mixin/powershell_exec.rb +5 -28
- data/lib/chef/monkey_patches/net-http.rb +127 -0
- data/lib/chef/node/attribute.rb +3 -11
- data/lib/chef/node/attribute_collections.rb +10 -1
- data/lib/chef/node/immutable_collections.rb +17 -6
- data/lib/chef/node/mixin/immutablize_array.rb +1 -0
- data/lib/chef/node/mixin/state_tracking.rb +7 -4
- data/lib/chef/node/mixin/state_tracking_array.rb +41 -0
- data/lib/chef/node.rb +23 -1
- data/lib/chef/platform/query_helpers.rb +4 -2
- data/lib/chef/policy_builder/policyfile.rb +8 -0
- data/lib/chef/property.rb +13 -6
- data/lib/chef/provider/group/windows.rb +1 -1
- data/lib/chef/provider/http_request.rb +11 -9
- data/lib/chef/provider/launchd.rb +2 -1
- data/lib/chef/provider/mount/linux.rb +6 -1
- data/lib/chef/provider/mount/mount.rb +13 -5
- data/lib/chef/provider/mount/windows.rb +1 -1
- data/lib/chef/provider/package/apt.rb +11 -2
- data/lib/chef/provider/package/chocolatey.rb +260 -22
- data/lib/chef/provider/package/dnf/dnf_helper.py +7 -0
- data/lib/chef/provider/package/homebrew.rb +6 -9
- data/lib/chef/provider/package/powershell.rb +1 -0
- data/lib/chef/provider/package/rubygems.rb +5 -1
- data/lib/chef/provider/package/snap.rb +3 -2
- 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 +3 -3
- data/lib/chef/provider/package/zypper/version.rb +60 -0
- data/lib/chef/provider/package/zypper.rb +47 -3
- data/lib/chef/provider/powershell_script.rb +96 -6
- data/lib/chef/provider/registry_key.rb +2 -0
- data/lib/chef/provider/remote_file/http.rb +1 -1
- data/lib/chef/provider/service/systemd.rb +23 -8
- data/lib/chef/provider/service/windows.rb +1 -1
- data/lib/chef/provider/service.rb +14 -0
- 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/windows.rb +5 -0
- data/lib/chef/provider/user.rb +45 -9
- data/lib/chef/provider/yum_repository.rb +13 -1
- data/lib/chef/provider.rb +1 -1
- data/lib/chef/recipe.rb +4 -12
- data/lib/chef/resource/_rest_resource.rb +389 -0
- data/lib/chef/resource/alternatives.rb +0 -1
- data/lib/chef/resource/apt_package.rb +21 -1
- data/lib/chef/resource/apt_preference.rb +0 -1
- data/lib/chef/resource/apt_repository.rb +138 -18
- data/lib/chef/resource/apt_update.rb +0 -1
- data/lib/chef/resource/archive_file.rb +0 -1
- data/lib/chef/resource/bash.rb +13 -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 +5 -1
- data/lib/chef/resource/chef_client_trusted_certificate.rb +0 -1
- data/lib/chef/resource/chef_gem.rb +1 -2
- 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_installer.rb +207 -0
- data/lib/chef/resource/chocolatey_package.rb +8 -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 +1 -2
- data/lib/chef/resource/execute.rb +8 -7
- 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 +2 -2
- 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 +21 -33
- data/lib/chef/resource/homebrew_package.rb +3 -2
- data/lib/chef/resource/homebrew_tap.rb +32 -18
- data/lib/chef/resource/homebrew_update.rb +4 -6
- 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 +9 -3
- data/lib/chef/resource/link.rb +0 -1
- data/lib/chef/resource/locale.rb +0 -1
- data/lib/chef/resource/log.rb +0 -1
- data/lib/chef/resource/lwrp_base.rb +0 -4
- data/lib/chef/resource/macos_pkg.rb +111 -0
- data/lib/chef/resource/macos_userdefaults.rb +3 -4
- 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 +4 -1
- data/lib/chef/resource/powershell_package_source.rb +0 -1
- data/lib/chef/resource/powershell_script.rb +5 -2
- data/lib/chef/resource/python.rb +0 -1
- data/lib/chef/resource/reboot.rb +0 -1
- data/lib/chef/resource/registry_key.rb +6 -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_login.rb +129 -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/selinux_user.rb +137 -0
- data/lib/chef/resource/service.rb +4 -2
- data/lib/chef/resource/smartos_package.rb +2 -1
- data/lib/chef/resource/snap_package.rb +25 -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 +37 -3
- data/lib/chef/resource/support/client.erb +2 -2
- data/lib/chef/resource/support/ulimit.erb +40 -0
- data/lib/chef/resource/swap_file.rb +0 -1
- data/lib/chef/resource/sysctl.rb +2 -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 +38 -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_certificate.rb +1 -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 +2 -3
- 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 +14 -11
- 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 +23 -5
- data/lib/chef/resource_inspector.rb +25 -7
- data/lib/chef/resource_reporter.rb +4 -0
- data/lib/chef/resources.rb +11 -0
- data/lib/chef/run_context.rb +3 -3
- data/lib/chef/secret_fetcher/azure_key_vault.rb +1 -1
- data/lib/chef/util/powershell/ps_credential.rb +10 -0
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/handle.rb +6 -7
- data/lib/chef/win32/registry.rb +12 -4
- data/lib/chef/win32/security.rb +16 -1
- data/spec/data/rubygems.org/sexp_processor-info +2 -1
- data/spec/data/trusted_certs/intermediate.pem +38 -27
- data/spec/functional/resource/cookbook_file_spec.rb +1 -1
- data/spec/functional/resource/dsc_script_spec.rb +1 -1
- data/spec/functional/resource/execute_spec.rb +1 -1
- data/spec/functional/resource/group_spec.rb +26 -42
- data/spec/functional/resource/link_spec.rb +8 -8
- data/spec/functional/resource/plist_spec.rb +25 -0
- data/spec/functional/resource/registry_spec.rb +233 -609
- data/spec/functional/resource/remote_file_spec.rb +1 -1
- data/spec/functional/resource/user/linux_user_spec.rb +127 -0
- data/spec/functional/resource/windows_certificate_spec.rb +1 -1
- data/spec/functional/resource/windows_font_spec.rb +12 -9
- data/spec/functional/resource/yum_package_spec.rb +1 -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/functional/win32/registry_spec.rb +0 -3
- data/spec/integration/client/client_spec.rb +88 -3
- data/spec/integration/client/exit_code_spec.rb +1 -1
- data/spec/integration/client/fips_spec.rb +5 -5
- data/spec/integration/client/ipv6_spec.rb +1 -1
- data/spec/integration/client/open_ssl_spec.rb +3 -3
- 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 +7 -4
- data/spec/support/chef_helpers.rb +2 -2
- data/spec/support/platform_helpers.rb +28 -7
- data/spec/support/ruby_installer.rb +1 -1
- data/spec/support/shared/functional/file_resource.rb +3 -3
- data/spec/support/shared/functional/windows_script.rb +2 -2
- data/spec/tiny_server.rb +5 -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 +80 -4
- data/spec/unit/compliance/runner_spec.rb +8 -0
- data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
- data/spec/unit/data_collector_spec.rb +106 -2
- data/spec/unit/delayed_evaluator_spec.rb +35 -0
- data/spec/unit/file_cache_spec.rb +64 -0
- data/spec/unit/http/authenticator_spec.rb +121 -0
- data/spec/unit/mixin/homebrew_spec.rb +118 -0
- data/spec/unit/mixin/openssl_helper_spec.rb +5 -0
- data/spec/unit/mixin/powershell_exec_spec.rb +5 -5
- data/spec/unit/node/vivid_mash_spec.rb +42 -0
- data/spec/unit/node_spec.rb +6 -0
- data/spec/unit/platform/query_helpers_spec.rb +2 -17
- data/spec/unit/property/validation_spec.rb +30 -0
- data/spec/unit/provider/apt_repository_spec.rb +48 -12
- data/spec/unit/provider/cron_spec.rb +2 -0
- data/spec/unit/provider/http_request_spec.rb +60 -72
- data/spec/unit/provider/launchd_spec.rb +2 -2
- data/spec/unit/provider/mount/aix_spec.rb +2 -2
- data/spec/unit/provider/mount/linux_spec.rb +15 -4
- data/spec/unit/provider/mount/mount_spec.rb +8 -8
- data/spec/unit/provider/package/apt_spec.rb +18 -13
- data/spec/unit/provider/package/chocolatey_spec.rb +41 -9
- data/spec/unit/provider/package/homebrew_spec.rb +4 -1
- data/spec/unit/provider/package/rpm_spec.rb +2 -2
- data/spec/unit/provider/package/rubygems_spec.rb +1 -1
- data/spec/unit/provider/package/windows_spec.rb +5 -5
- data/spec/unit/provider/package/zypper_spec.rb +32 -0
- data/spec/unit/provider/powershell_script_spec.rb +100 -4
- data/spec/unit/provider/registry_key_spec.rb +17 -17
- data/spec/unit/provider/remote_file/http_spec.rb +4 -4
- data/spec/unit/provider/service/systemd_service_spec.rb +1 -0
- data/spec/unit/provider/user/linux_spec.rb +51 -1
- data/spec/unit/provider/user/windows_spec.rb +1 -0
- data/spec/unit/provider/user_spec.rb +24 -6
- data/spec/unit/resource/apt_repository_spec.rb +5 -0
- 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/chocolatey_installer_spec.rb +151 -0
- data/spec/unit/resource/cron_d_spec.rb +37 -1
- data/spec/unit/resource/macos_pkg_spec.rb +38 -0
- data/spec/unit/resource/powershell_script_spec.rb +2 -2
- 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_login_spec.rb +73 -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/selinux_user_spec.rb +92 -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_inspector_spec.rb +36 -0
- data/spec/unit/resource_reporter_spec.rb +57 -3
- data/spec/unit/resource_spec.rb +94 -2
- data/spec/unit/util/dsc/local_configuration_manager_spec.rb +1 -1
- data/spec/unit/util/powershell/ps_credential_spec.rb +6 -0
- data/tasks/rspec.rb +1 -1
- metadata +126 -44
- data/lib/chef/powershell.rb +0 -81
- data/spec/unit/mixin/homebrew_user_spec.rb +0 -119
- /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
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
require_relative "common_api"
|
|
19
19
|
require_relative "mixin/state_tracking"
|
|
20
|
+
require_relative "mixin/state_tracking_array"
|
|
20
21
|
require_relative "mixin/immutablize_array"
|
|
21
22
|
require_relative "mixin/immutablize_hash"
|
|
22
23
|
require_relative "../delayed_evaluator"
|
|
@@ -34,13 +35,23 @@ class Chef
|
|
|
34
35
|
def convert_value(value)
|
|
35
36
|
case value
|
|
36
37
|
when Hash
|
|
37
|
-
ImmutableMash
|
|
38
|
+
if ImmutableMash === value
|
|
39
|
+
# Save an object creation
|
|
40
|
+
value
|
|
41
|
+
else
|
|
42
|
+
ImmutableMash.new(value, __root__, __node__, __precedence__)
|
|
43
|
+
end
|
|
38
44
|
when Array
|
|
39
|
-
ImmutableArray
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
if ImmutableArray === value
|
|
46
|
+
# Save an object creation
|
|
47
|
+
value
|
|
48
|
+
else
|
|
49
|
+
ImmutableArray.new(value, __root__, __node__, __precedence__)
|
|
50
|
+
end
|
|
42
51
|
else
|
|
43
|
-
|
|
52
|
+
# We return any already frozen strings, since that's common over the course of a run.
|
|
53
|
+
# Check `frozen?` first since that's faster than a Class comparison
|
|
54
|
+
value.frozen? && String === value ? value : safe_dup(value).freeze
|
|
44
55
|
end
|
|
45
56
|
end
|
|
46
57
|
|
|
@@ -116,7 +127,7 @@ class Chef
|
|
|
116
127
|
value
|
|
117
128
|
end
|
|
118
129
|
|
|
119
|
-
prepend Chef::Node::Mixin::
|
|
130
|
+
prepend Chef::Node::Mixin::StateTrackingArray
|
|
120
131
|
prepend Chef::Node::Mixin::ImmutablizeArray
|
|
121
132
|
end
|
|
122
133
|
|
|
@@ -37,7 +37,8 @@ class Chef
|
|
|
37
37
|
def [](*args)
|
|
38
38
|
ret = super
|
|
39
39
|
key = args.first
|
|
40
|
-
next_path = [ __path__, convert_key(key) ].flatten
|
|
40
|
+
next_path = [ __path__, convert_key(key) ].flatten
|
|
41
|
+
next_path.compact!
|
|
41
42
|
copy_state_to(ret, next_path)
|
|
42
43
|
end
|
|
43
44
|
|
|
@@ -45,7 +46,8 @@ class Chef
|
|
|
45
46
|
ret = super
|
|
46
47
|
key = args.first
|
|
47
48
|
value = args.last
|
|
48
|
-
next_path = [ __path__, convert_key(key) ].flatten
|
|
49
|
+
next_path = [ __path__, convert_key(key) ].flatten
|
|
50
|
+
next_path.compact!
|
|
49
51
|
send_attribute_changed_event(next_path, value)
|
|
50
52
|
copy_state_to(ret, next_path)
|
|
51
53
|
end
|
|
@@ -77,8 +79,9 @@ class Chef
|
|
|
77
79
|
end
|
|
78
80
|
|
|
79
81
|
def send_reset_cache(path = nil, key = nil)
|
|
80
|
-
next_path = [ path, key ].flatten
|
|
81
|
-
|
|
82
|
+
next_path = [ path, key ].flatten
|
|
83
|
+
next_path.compact!
|
|
84
|
+
__root__.reset_cache(next_path.first) if !__root__.nil? && __root__.respond_to?(:reset_cache)
|
|
82
85
|
end
|
|
83
86
|
|
|
84
87
|
def copy_state_to(ret, next_path)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# Copyright:: Copyright (c) Chef Software 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_relative "immutablize_array"
|
|
19
|
+
require_relative "state_tracking"
|
|
20
|
+
|
|
21
|
+
class Chef
|
|
22
|
+
class Node
|
|
23
|
+
module Mixin
|
|
24
|
+
module StateTrackingArray
|
|
25
|
+
include ::Chef::Node::Mixin::StateTracking
|
|
26
|
+
|
|
27
|
+
MUTATOR_METHODS = Chef::Node::Mixin::ImmutablizeArray::DISALLOWED_MUTATOR_METHODS
|
|
28
|
+
|
|
29
|
+
# For all of the methods that may mutate an Array, we override them to
|
|
30
|
+
# also track the state and trigger attribute_changed event.
|
|
31
|
+
MUTATOR_METHODS.each do |mutator|
|
|
32
|
+
define_method(mutator) do |*args, &block|
|
|
33
|
+
ret = super(*args, &block)
|
|
34
|
+
send_attribute_changed_event(__path__, self)
|
|
35
|
+
ret
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
data/lib/chef/node.rb
CHANGED
|
@@ -285,7 +285,7 @@ class Chef
|
|
|
285
285
|
def loaded_recipe(cookbook, recipe)
|
|
286
286
|
fully_qualified_recipe = "#{cookbook}::#{recipe}"
|
|
287
287
|
|
|
288
|
-
automatic_attrs[:recipes] << fully_qualified_recipe unless Array(
|
|
288
|
+
automatic_attrs[:recipes] << fully_qualified_recipe unless Array(automatic_attrs[:recipes]).include?(fully_qualified_recipe)
|
|
289
289
|
end
|
|
290
290
|
|
|
291
291
|
# Returns true if this Node expects a given role, false if not.
|
|
@@ -401,6 +401,13 @@ class Chef
|
|
|
401
401
|
normal[:tags]
|
|
402
402
|
end
|
|
403
403
|
|
|
404
|
+
# Add the list of tags to the node.
|
|
405
|
+
#
|
|
406
|
+
# === Parameters
|
|
407
|
+
# tags<Array>:: A list of tags
|
|
408
|
+
#
|
|
409
|
+
# === Returns
|
|
410
|
+
# tags<Array>:: The current list of run_context.node.tags
|
|
404
411
|
def tag(*args)
|
|
405
412
|
args.each do |tag|
|
|
406
413
|
tags.push(tag.to_s) unless tags.include? tag.to_s
|
|
@@ -409,6 +416,21 @@ class Chef
|
|
|
409
416
|
tags
|
|
410
417
|
end
|
|
411
418
|
|
|
419
|
+
# Removes the list of tags from the node.
|
|
420
|
+
#
|
|
421
|
+
# === Parameters
|
|
422
|
+
# tags<Array>:: A list of tags
|
|
423
|
+
#
|
|
424
|
+
# === Returns
|
|
425
|
+
# tags<Array>:: The current list of run_context.node.tags
|
|
426
|
+
def untag(*args)
|
|
427
|
+
args.each do |tag|
|
|
428
|
+
tags.delete(tag.to_s)
|
|
429
|
+
end
|
|
430
|
+
|
|
431
|
+
tags
|
|
432
|
+
end
|
|
433
|
+
|
|
412
434
|
# Extracts the run list from +attrs+ and applies it. Returns the remaining attributes
|
|
413
435
|
def consume_run_list(attrs)
|
|
414
436
|
attrs = attrs ? attrs.dup : {}
|
|
@@ -17,11 +17,14 @@
|
|
|
17
17
|
#
|
|
18
18
|
|
|
19
19
|
require "chef-utils" unless defined?(ChefUtils::CANARY)
|
|
20
|
+
require_relative "../mixin/powershell_exec"
|
|
20
21
|
|
|
21
22
|
class Chef
|
|
22
23
|
class Platform
|
|
23
24
|
|
|
24
25
|
class << self
|
|
26
|
+
include Chef::Mixin::PowershellExec
|
|
27
|
+
|
|
25
28
|
def windows?
|
|
26
29
|
ChefUtils.windows?
|
|
27
30
|
end
|
|
@@ -58,8 +61,7 @@ class Chef
|
|
|
58
61
|
end
|
|
59
62
|
|
|
60
63
|
def dsc_refresh_mode_disabled?(node)
|
|
61
|
-
|
|
62
|
-
exec = Chef::PowerShell.new("Get-DscLocalConfigurationManager")
|
|
64
|
+
exec = powershell_exec!("Get-DscLocalConfigurationManager")
|
|
63
65
|
exec.error!
|
|
64
66
|
exec.result["RefreshMode"] == "Disabled"
|
|
65
67
|
end
|
|
@@ -132,6 +132,9 @@ class Chef
|
|
|
132
132
|
|
|
133
133
|
node.consume_external_attrs(ohai_data, json_attribs)
|
|
134
134
|
|
|
135
|
+
# Preserve the fall back to loading an unencrypted data bag item if the item we're trying to load isn't actually a vault item.
|
|
136
|
+
set_databag_fallback
|
|
137
|
+
|
|
135
138
|
setup_run_list_override
|
|
136
139
|
|
|
137
140
|
expand_run_list
|
|
@@ -191,6 +194,11 @@ class Chef
|
|
|
191
194
|
run_context
|
|
192
195
|
end
|
|
193
196
|
|
|
197
|
+
# Preserve the fall back to loading an unencrypted data bag item if the item we're trying to load isn't actually a vault item.
|
|
198
|
+
def set_databag_fallback
|
|
199
|
+
node.default["chef-vault"]["databag_fallback"] = ChefUtils.kitchen?(node)
|
|
200
|
+
end
|
|
201
|
+
|
|
194
202
|
# Sets `run_list` on the node from the policy, sets `roles` and `recipes`
|
|
195
203
|
# attributes on the node accordingly.
|
|
196
204
|
#
|
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
|
|
@@ -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
|
)
|
|
@@ -52,7 +52,7 @@ class Chef
|
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
action :delete, description: "Delete a launchd property list. This will unload a daemon or agent, if loaded." do
|
|
55
|
-
if ::File.
|
|
55
|
+
if ::File.exist?(path)
|
|
56
56
|
manage_service(:disable)
|
|
57
57
|
end
|
|
58
58
|
manage_plist(:delete)
|
|
@@ -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",
|
|
@@ -39,7 +39,7 @@ class Chef
|
|
|
39
39
|
|
|
40
40
|
def mounted?
|
|
41
41
|
mounted = false
|
|
42
|
-
real_mount_point = if ::File.
|
|
42
|
+
real_mount_point = if ::File.exist? @new_resource.mount_point
|
|
43
43
|
::File.realpath(@new_resource.mount_point)
|
|
44
44
|
else
|
|
45
45
|
@new_resource.mount_point
|
|
@@ -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)
|
|
@@ -42,9 +42,9 @@ class Chef
|
|
|
42
42
|
|
|
43
43
|
def mountable?
|
|
44
44
|
# only check for existence of non-remote devices
|
|
45
|
-
if device_should_exist? && !::File.
|
|
45
|
+
if device_should_exist? && !::File.exist?(device_real)
|
|
46
46
|
raise Chef::Exceptions::Mount, "Device #{@new_resource.device} does not exist"
|
|
47
|
-
elsif @new_resource.mount_point != "none" && !::File.
|
|
47
|
+
elsif @new_resource.mount_point != "none" && !::File.exist?(@new_resource.mount_point)
|
|
48
48
|
raise Chef::Exceptions::Mount, "Mount point #{@new_resource.mount_point} does not exist"
|
|
49
49
|
end
|
|
50
50
|
|
|
@@ -81,7 +81,7 @@ class Chef
|
|
|
81
81
|
# "mount" outputs the mount points as real paths. Convert
|
|
82
82
|
# the mount_point of the resource to a real path in case it
|
|
83
83
|
# contains symlinks in its parents dirs.
|
|
84
|
-
real_mount_point = if ::File.
|
|
84
|
+
real_mount_point = if ::File.exist? @new_resource.mount_point
|
|
85
85
|
::File.realpath(@new_resource.mount_point)
|
|
86
86
|
else
|
|
87
87
|
@new_resource.mount_point
|
|
@@ -186,7 +186,7 @@ class Chef
|
|
|
186
186
|
def device_should_exist?
|
|
187
187
|
( @new_resource.device != "none" ) &&
|
|
188
188
|
( not network_device? ) &&
|
|
189
|
-
( not %w{ cgroup tmpfs fuse vboxsf zfs }.include? @new_resource.fstype )
|
|
189
|
+
( not %w{ cgroup tmpfs fuse vboxsf zfs efivarfs }.include? @new_resource.fstype )
|
|
190
190
|
end
|
|
191
191
|
|
|
192
192
|
private
|
|
@@ -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
|
|
@@ -279,4 +287,4 @@ class Chef
|
|
|
279
287
|
end
|
|
280
288
|
end
|
|
281
289
|
end
|
|
282
|
-
end
|
|
290
|
+
end
|
|
@@ -124,6 +124,11 @@ class Chef
|
|
|
124
124
|
|
|
125
125
|
private
|
|
126
126
|
|
|
127
|
+
# @return [String] package name with or without anchors attached to it.
|
|
128
|
+
def resolve_package(pkg)
|
|
129
|
+
new_resource.anchor_package_regex ? "^#{pkg}$" : pkg
|
|
130
|
+
end
|
|
131
|
+
|
|
127
132
|
# @return [String] version of apt-get which is installed
|
|
128
133
|
def apt_version
|
|
129
134
|
@apt_version ||= shell_out("apt-get --version").stdout.match(/^apt (\S+)/)[1]
|
|
@@ -174,10 +179,12 @@ class Chef
|
|
|
174
179
|
end
|
|
175
180
|
|
|
176
181
|
def resolve_package_versions(pkg)
|
|
182
|
+
# apt-cache considers package names as regex by default. The anchor_package_regex flag will decide whether to match name exact string or not
|
|
183
|
+
pkg_name = resolve_package(pkg)
|
|
177
184
|
current_version = nil
|
|
178
185
|
candidate_version = nil
|
|
179
186
|
all_versions = []
|
|
180
|
-
run_noninteractive("apt-cache", default_release_options, "policy",
|
|
187
|
+
run_noninteractive("apt-cache", default_release_options, "policy", pkg_name).stdout.each_line do |line|
|
|
181
188
|
case line
|
|
182
189
|
when /^\s{2}Installed: (.+)$/
|
|
183
190
|
current_version = ( $1 != "(none)" ) ? $1 : nil
|
|
@@ -216,7 +223,9 @@ class Chef
|
|
|
216
223
|
end
|
|
217
224
|
|
|
218
225
|
def resolve_virtual_package_name(pkg)
|
|
219
|
-
|
|
226
|
+
# apt-cache considers package names as regex by default. The anchor_package_regex flag will decide whether to match name exact string or not
|
|
227
|
+
pkg_name = resolve_package(pkg)
|
|
228
|
+
showpkg = run_noninteractive("apt-cache", "showpkg", pkg_name).stdout
|
|
220
229
|
partitions = showpkg.rpartition(/Reverse Provides: ?#{$/}/)
|
|
221
230
|
return nil if partitions[0] == "" && partitions[1] == "" # not found in output
|
|
222
231
|
|