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
|
@@ -20,17 +20,28 @@
|
|
|
20
20
|
|
|
21
21
|
require_relative "../package"
|
|
22
22
|
require_relative "../../resource/zypper_package"
|
|
23
|
+
require_relative "zypper/version"
|
|
23
24
|
|
|
24
25
|
class Chef
|
|
25
26
|
class Provider
|
|
26
27
|
class Package
|
|
27
28
|
class Zypper < Chef::Provider::Package
|
|
28
29
|
use_multipackage_api
|
|
30
|
+
use_package_name_for_source
|
|
29
31
|
allow_nils
|
|
30
32
|
|
|
31
33
|
provides :package, platform_family: "suse"
|
|
32
34
|
provides :zypper_package
|
|
33
35
|
|
|
36
|
+
def define_resource_requirements
|
|
37
|
+
super
|
|
38
|
+
requirements.assert(:install, :upgrade) do |a|
|
|
39
|
+
a.assertion { source_files_exist? }
|
|
40
|
+
a.failure_message Chef::Exceptions::Package, "#{new_resource} source file(s) do not exist: #{missing_sources}"
|
|
41
|
+
a.whyrun "Assuming they would have been previously created."
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
34
45
|
def load_current_resource
|
|
35
46
|
@current_resource = Chef::Resource::ZypperPackage.new(new_resource.name)
|
|
36
47
|
current_resource.package_name(new_resource.package_name)
|
|
@@ -70,7 +81,35 @@ class Chef
|
|
|
70
81
|
end
|
|
71
82
|
|
|
72
83
|
def candidate_version
|
|
73
|
-
|
|
84
|
+
package_name_array.each_with_index.map do |pkg, i|
|
|
85
|
+
available_version(i)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# returns true if all sources exist. Returns false if any do not, or if no
|
|
90
|
+
# sources were specified.
|
|
91
|
+
# @return [Boolean] True if all sources exist
|
|
92
|
+
def source_files_exist?
|
|
93
|
+
if !new_resource.source.nil?
|
|
94
|
+
resolved_source_array.all? { |s| s && ::File.exist?(s) }
|
|
95
|
+
else
|
|
96
|
+
true
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Helper to return all the names of the missing sources for error messages.
|
|
101
|
+
# @return [Array<String>] Array of missing sources
|
|
102
|
+
def missing_sources
|
|
103
|
+
resolved_source_array.select { |s| s.nil? || !::File.exist?(s) }
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def resolve_source_to_version
|
|
107
|
+
shell_out!("rpm -qp --queryformat '%{NAME} %{EPOCH} %{VERSION} %{RELEASE} %{ARCH}\n' #{new_resource.source}").stdout.each_line do |line|
|
|
108
|
+
case line
|
|
109
|
+
when /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)$/
|
|
110
|
+
return Version.new($1, "#{$2 == "(none)" ? "0" : $2}:#{$3}-#{$4}", $5)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
74
113
|
end
|
|
75
114
|
|
|
76
115
|
def resolve_current_version(package_name)
|
|
@@ -124,7 +163,12 @@ class Chef
|
|
|
124
163
|
|
|
125
164
|
def available_version(index)
|
|
126
165
|
@available_version ||= []
|
|
127
|
-
|
|
166
|
+
|
|
167
|
+
@available_version[index] ||= if new_resource.source
|
|
168
|
+
resolve_source_to_version
|
|
169
|
+
else
|
|
170
|
+
resolve_available_version(package_name_array[index], safe_version_array[index])
|
|
171
|
+
end
|
|
128
172
|
@available_version[index]
|
|
129
173
|
end
|
|
130
174
|
|
|
@@ -146,7 +190,7 @@ class Chef
|
|
|
146
190
|
end
|
|
147
191
|
|
|
148
192
|
def zypper_package(command, global_options, *options, names, versions)
|
|
149
|
-
zipped_names = zip(names, versions)
|
|
193
|
+
zipped_names = new_resource.source || zip(names, versions)
|
|
150
194
|
if zypper_version < 1.0
|
|
151
195
|
shell_out!("zypper", global_options, gpg_checks, command, *options, "-y", names)
|
|
152
196
|
else
|
|
@@ -27,8 +27,13 @@ class Chef
|
|
|
27
27
|
provides :powershell_script
|
|
28
28
|
|
|
29
29
|
action :run do
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
Chef::Log.debug("using inline impl: #{new_resource.use_inline_powershell}")
|
|
31
|
+
if new_resource.use_inline_powershell
|
|
32
|
+
run_using_powershell_exec
|
|
33
|
+
else
|
|
34
|
+
validate_script_syntax!
|
|
35
|
+
super()
|
|
36
|
+
end
|
|
32
37
|
end
|
|
33
38
|
|
|
34
39
|
# Set InputFormat to None as PowerShell will hang if STDIN is redirected
|
|
@@ -38,6 +43,7 @@ class Chef
|
|
|
38
43
|
def command
|
|
39
44
|
# Must use -File rather than -Command to launch the script
|
|
40
45
|
# file created by the base class that contains the script
|
|
46
|
+
|
|
41
47
|
# code -- otherwise, powershell.exe does not propagate the
|
|
42
48
|
# error status of a failed Windows process that ran at the
|
|
43
49
|
# end of the script, it gets changed to '1'.
|
|
@@ -52,6 +58,69 @@ class Chef
|
|
|
52
58
|
|
|
53
59
|
protected
|
|
54
60
|
|
|
61
|
+
# Run the inline version of powershell, using powershell_exec rather than powershell_out - this should
|
|
62
|
+
# hopefully
|
|
63
|
+
def run_using_powershell_exec
|
|
64
|
+
# Because of the nature of powershell_exec, we can't easily stream data to the shell, so we just flat out
|
|
65
|
+
# disallow this combination
|
|
66
|
+
if new_resource.live_stream
|
|
67
|
+
raise "powershell_script does not support live_stream when inline powershell is enabled - please choose one or the other"
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# This comes from the execute super resource - since we want to limit the scope of this to powershell,
|
|
71
|
+
# we use this here
|
|
72
|
+
if creates && sentinel_file.exist?
|
|
73
|
+
logger.debug("#{new_resource} sentinel file #{sentinel_file} exists - nothing to do")
|
|
74
|
+
return false
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
converge_by("execute direct powershell #{new_resource.name}") do
|
|
78
|
+
# For scoping - otherwise, we lose return_code/stdout/stderr when the timeout block is over
|
|
79
|
+
return_code = nil
|
|
80
|
+
stdout = nil
|
|
81
|
+
stderr = nil
|
|
82
|
+
|
|
83
|
+
r = powershell_exec!(powershell_wrapper_script, new_resource.interpreter.to_sym, timeout: new_resource.timeout)
|
|
84
|
+
# Split out the stdout/return code format if needed
|
|
85
|
+
return_code = r.result
|
|
86
|
+
|
|
87
|
+
# The script returns an array if there is stdout, or just a plain return value if
|
|
88
|
+
# there is not - we need to handle both of these cases for full coverage
|
|
89
|
+
if return_code.is_a?(Array)
|
|
90
|
+
# Why to_s? Because if the only powershell output is an object,
|
|
91
|
+
# it'll be returned here
|
|
92
|
+
stdout = return_code[0].to_s
|
|
93
|
+
stderr = r.errors.join("\n")
|
|
94
|
+
return_code = return_code[-1]
|
|
95
|
+
else
|
|
96
|
+
stdout = ""
|
|
97
|
+
stderr = r.errors.join("\n")
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
Chef::Log.info("Powershell output: #{stdout}") unless stdout.empty?
|
|
101
|
+
Chef::Log.info("Powershell error: #{stderr}") unless stderr.empty?
|
|
102
|
+
|
|
103
|
+
# Check the return code, and validate. This code is cribbed from execute.rb, and does exactly the same
|
|
104
|
+
# thing as it does there
|
|
105
|
+
valid_returns = new_resource.returns
|
|
106
|
+
valid_returns = [valid_returns] if valid_returns.is_a?(Integer)
|
|
107
|
+
unless valid_returns.include?(return_code)
|
|
108
|
+
# Handle sensitive results
|
|
109
|
+
if sensitive?
|
|
110
|
+
ex = ChefPowerShell::PowerShellExceptions::PowerShellCommandFailed.new("Command execution failed. STDOUT/STDERR suppressed for sensitive resource")
|
|
111
|
+
# Forcibly hide the exception cause chain here so we don't log the unredacted version
|
|
112
|
+
def ex.cause
|
|
113
|
+
nil
|
|
114
|
+
end
|
|
115
|
+
raise ex
|
|
116
|
+
else
|
|
117
|
+
raise ChefPowerShell::PowerShellExceptions::PowerShellCommandFailed.new("Powershell command returned #{return_code} - output was \"#{stdout}\", error output was \"#{stderr}\"")
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
true
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
55
124
|
def interpreter_path
|
|
56
125
|
# Powershell.exe is always in "v1.0" folder (for backwards compatibility)
|
|
57
126
|
# pwsh is the other interpreter and we will assume that it is on the path.
|
|
@@ -69,7 +138,7 @@ class Chef
|
|
|
69
138
|
end
|
|
70
139
|
|
|
71
140
|
def code
|
|
72
|
-
code =
|
|
141
|
+
code = powershell_wrapper_script
|
|
73
142
|
logger.trace("powershell_script provider called with script code:\n\n#{new_resource.code}\n")
|
|
74
143
|
logger.trace("powershell_script provider will execute transformed code:\n\n#{code}\n")
|
|
75
144
|
code
|
|
@@ -129,7 +198,11 @@ class Chef
|
|
|
129
198
|
# last process run in the script if it is the last command
|
|
130
199
|
# executed, otherwise 0 or 1 based on whether $? is set to true
|
|
131
200
|
# (success, where we return 0) or false (where we return 1).
|
|
132
|
-
|
|
201
|
+
#
|
|
202
|
+
# This is the regular powershell version of the above script - the difference
|
|
203
|
+
# is that regular powershell allows for hidden visibility variables, due to the
|
|
204
|
+
# very slightly different semantics.
|
|
205
|
+
def powershell_wrapper_script
|
|
133
206
|
<<~EOH
|
|
134
207
|
# Chef Client wrapper for powershell_script resources
|
|
135
208
|
|
|
@@ -148,12 +221,23 @@ class Chef
|
|
|
148
221
|
# Catch any exceptions -- without this, exceptions will result
|
|
149
222
|
# In a zero return code instead of the desired non-zero code
|
|
150
223
|
# that indicates a failure
|
|
224
|
+
|
|
225
|
+
#{if new_resource.use_inline_powershell
|
|
226
|
+
# Inline powershell doesn't allow for private visibility variables,
|
|
227
|
+
# and uses return instead of exit
|
|
228
|
+
<<-EOI
|
|
229
|
+
trap [Exception] {write-error ($_.Exception.Message);return 1}
|
|
230
|
+
$interpolatedexitcode = $#{new_resource.convert_boolean_return}
|
|
231
|
+
EOI
|
|
232
|
+
else
|
|
233
|
+
<<-EOI
|
|
151
234
|
trap [Exception] {write-error ($_.Exception.Message);exit 1}
|
|
152
235
|
|
|
153
236
|
# Variable state that should not be accessible to the user code
|
|
154
237
|
new-variable -name interpolatedexitcode -visibility private -value $#{new_resource.convert_boolean_return}
|
|
155
238
|
new-variable -name chefscriptresult -visibility private
|
|
156
|
-
|
|
239
|
+
EOI
|
|
240
|
+
end}
|
|
157
241
|
# Initialize a variable we use to capture $? inside a block
|
|
158
242
|
$global:lastcmdlet = $null
|
|
159
243
|
|
|
@@ -198,7 +282,13 @@ class Chef
|
|
|
198
282
|
# status of PowerShell.exe will be $exitstatus. If it was
|
|
199
283
|
# launched with -Command, it will be 0 if $exitstatus was 0,
|
|
200
284
|
# 1 (i.e. failed) otherwise.
|
|
201
|
-
|
|
285
|
+
#{if new_resource.use_inline_powershell
|
|
286
|
+
# Inline powershell needs return, not exit
|
|
287
|
+
"return $exitstatus\n"
|
|
288
|
+
else
|
|
289
|
+
"exit $exitstatus\n"
|
|
290
|
+
end
|
|
291
|
+
}
|
|
202
292
|
EOH
|
|
203
293
|
end
|
|
204
294
|
|
|
@@ -54,6 +54,7 @@ class Chef
|
|
|
54
54
|
current_resource.values(current_registry_values)
|
|
55
55
|
end
|
|
56
56
|
values_to_hash(current_resource.unscrubbed_values)
|
|
57
|
+
|
|
57
58
|
current_resource
|
|
58
59
|
end
|
|
59
60
|
|
|
@@ -122,6 +123,7 @@ class Chef
|
|
|
122
123
|
registry.create_key(new_resource.key, new_resource.recursive)
|
|
123
124
|
end
|
|
124
125
|
end
|
|
126
|
+
|
|
125
127
|
new_resource.unscrubbed_values.each do |value|
|
|
126
128
|
if @name_hash.key?(value[:name].downcase)
|
|
127
129
|
current_value = @name_hash[value[:name].downcase]
|
|
@@ -51,6 +51,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
|
|
|
51
51
|
current_resource.running(false)
|
|
52
52
|
current_resource.enabled(false)
|
|
53
53
|
current_resource.masked(false)
|
|
54
|
+
current_resource.static(false)
|
|
54
55
|
current_resource.indirect(false)
|
|
55
56
|
end
|
|
56
57
|
else
|
|
@@ -59,6 +60,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
|
|
|
59
60
|
|
|
60
61
|
current_resource.enabled(is_enabled?)
|
|
61
62
|
current_resource.masked(is_masked?)
|
|
63
|
+
current_resource.static(is_static?)
|
|
62
64
|
current_resource.indirect(is_indirect?)
|
|
63
65
|
current_resource
|
|
64
66
|
end
|
|
@@ -168,20 +170,29 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
|
|
|
168
170
|
end
|
|
169
171
|
end
|
|
170
172
|
|
|
171
|
-
def
|
|
172
|
-
if current_resource.masked
|
|
173
|
-
logger.debug("#{new_resource} cannot be
|
|
174
|
-
return
|
|
173
|
+
def enableable?(action)
|
|
174
|
+
if current_resource.masked
|
|
175
|
+
logger.debug("#{new_resource} cannot be #{action}d: it is masked")
|
|
176
|
+
return false
|
|
177
|
+
end
|
|
178
|
+
if current_resource.static
|
|
179
|
+
logger.debug("#{new_resource} cannot be #{action}d: it is static")
|
|
180
|
+
return false
|
|
181
|
+
end
|
|
182
|
+
if current_resource.indirect
|
|
183
|
+
logger.debug("#{new_resource} cannot be #{action}d: it is indirect")
|
|
184
|
+
return false
|
|
175
185
|
end
|
|
186
|
+
true
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def enable_service
|
|
190
|
+
# This function can safely assume that enableable? is true
|
|
176
191
|
options, args = get_systemctl_options_args
|
|
177
192
|
shell_out!(systemctl_path, args, "enable", new_resource.service_name, **options)
|
|
178
193
|
end
|
|
179
194
|
|
|
180
195
|
def disable_service
|
|
181
|
-
if current_resource.masked || current_resource.indirect
|
|
182
|
-
logger.debug("#{new_resource} cannot be disabled: it is masked or indirect")
|
|
183
|
-
return
|
|
184
|
-
end
|
|
185
196
|
options, args = get_systemctl_options_args
|
|
186
197
|
shell_out!(systemctl_path, args, "disable", new_resource.service_name, **options)
|
|
187
198
|
end
|
|
@@ -217,6 +228,10 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
|
|
|
217
228
|
systemd_service_status["UnitFileState"] == "indirect"
|
|
218
229
|
end
|
|
219
230
|
|
|
231
|
+
def is_static?
|
|
232
|
+
systemd_service_status["UnitFileState"] == "static"
|
|
233
|
+
end
|
|
234
|
+
|
|
220
235
|
def is_masked?
|
|
221
236
|
# Note: masked-runtime is excluded, because runtime is volatile, and
|
|
222
237
|
# because masked-runtime is not masked.
|
|
@@ -80,7 +80,19 @@ class Chef
|
|
|
80
80
|
end
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
+
# This is a hook for subclasses to be able to tell the super class that a
|
|
84
|
+
# service is or is not enable-able. For example, on systemd, static and
|
|
85
|
+
# indirect units are not enable-able.
|
|
86
|
+
#
|
|
87
|
+
# In addition, this method offloads the messaging to the user. If the
|
|
88
|
+
# method returns `false`, it should say why `action` couldn't be taken
|
|
89
|
+
def enableable?(action)
|
|
90
|
+
true
|
|
91
|
+
end
|
|
92
|
+
|
|
83
93
|
action :enable do
|
|
94
|
+
return unless enableable?(:enable)
|
|
95
|
+
|
|
84
96
|
if current_resource.enabled
|
|
85
97
|
logger.debug("#{new_resource} already enabled - nothing to do")
|
|
86
98
|
else
|
|
@@ -94,6 +106,8 @@ class Chef
|
|
|
94
106
|
end
|
|
95
107
|
|
|
96
108
|
action :disable do
|
|
109
|
+
return unless enableable?(:disable)
|
|
110
|
+
|
|
97
111
|
if current_resource.enabled
|
|
98
112
|
converge_by("disable service #{new_resource}") do
|
|
99
113
|
disable_service
|
|
@@ -23,6 +23,11 @@ class Chef
|
|
|
23
23
|
provides :user, os: "aix"
|
|
24
24
|
provides :aix_user
|
|
25
25
|
|
|
26
|
+
# The ruby-shadow gem is not supported on aix.
|
|
27
|
+
def supports_ruby_shadow?
|
|
28
|
+
false
|
|
29
|
+
end
|
|
30
|
+
|
|
26
31
|
def create_user
|
|
27
32
|
shell_out!("useradd", universal_options, useradd_options, new_resource.username)
|
|
28
33
|
add_password
|
|
@@ -23,6 +23,27 @@ class Chef
|
|
|
23
23
|
provides :linux_user
|
|
24
24
|
provides :user, os: "linux"
|
|
25
25
|
|
|
26
|
+
def load_current_resource
|
|
27
|
+
super
|
|
28
|
+
load_shadow_options
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def compare_user
|
|
32
|
+
user_changed = super
|
|
33
|
+
|
|
34
|
+
@change_desc ||= []
|
|
35
|
+
|
|
36
|
+
%i{expire_date inactive}.each do |user_attrib|
|
|
37
|
+
new_val = new_resource.send(user_attrib)
|
|
38
|
+
cur_val = current_resource.send(user_attrib)
|
|
39
|
+
if !new_val.nil? && new_val.to_s != cur_val.to_s
|
|
40
|
+
@change_desc << "change #{user_attrib} from #{cur_val} to #{new_val}"
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
user_changed || !@change_desc.empty?
|
|
45
|
+
end
|
|
46
|
+
|
|
26
47
|
def create_user
|
|
27
48
|
shell_out!("useradd", universal_options, useradd_options, new_resource.username)
|
|
28
49
|
end
|
|
@@ -52,7 +73,9 @@ class Chef
|
|
|
52
73
|
def universal_options
|
|
53
74
|
opts = []
|
|
54
75
|
opts << "-c" << new_resource.comment if should_set?(:comment)
|
|
76
|
+
opts << "-e" << new_resource.expire_date if prop_is_set?(:expire_date)
|
|
55
77
|
opts << "-g" << new_resource.gid if should_set?(:gid)
|
|
78
|
+
opts << "-f" << new_resource.inactive if prop_is_set?(:inactive)
|
|
56
79
|
opts << "-p" << new_resource.password if should_set?(:password)
|
|
57
80
|
opts << "-s" << new_resource.shell if should_set?(:shell)
|
|
58
81
|
opts << "-u" << new_resource.uid if should_set?(:uid)
|
|
@@ -116,6 +139,12 @@ class Chef
|
|
|
116
139
|
# FIXME: should probably go on the current_resource
|
|
117
140
|
@locked
|
|
118
141
|
end
|
|
142
|
+
|
|
143
|
+
def prop_is_set?(prop)
|
|
144
|
+
v = new_resource.send(prop.to_sym)
|
|
145
|
+
|
|
146
|
+
!v.nil? && v != ""
|
|
147
|
+
end
|
|
119
148
|
end
|
|
120
149
|
end
|
|
121
150
|
end
|
|
@@ -48,7 +48,7 @@ class Chef
|
|
|
48
48
|
if user_plist
|
|
49
49
|
current_resource.uid(user_plist[:uid][0])
|
|
50
50
|
current_resource.gid(user_plist[:gid][0])
|
|
51
|
-
current_resource.home(user_plist[:home]
|
|
51
|
+
current_resource.home(user_plist[:home]&.first) # use &.first since home can be nil
|
|
52
52
|
current_resource.shell(user_plist[:shell]&.first) # use &.first since shell can be nil
|
|
53
53
|
current_resource.comment(user_plist[:comment][0])
|
|
54
54
|
|
|
@@ -85,7 +85,12 @@ class Chef
|
|
|
85
85
|
@net_user.update(**set_options)
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
+
def clear_account_rights(name)
|
|
89
|
+
Chef::ReservedNames::Win32::Security.clear_account_rights(name)
|
|
90
|
+
end
|
|
91
|
+
|
|
88
92
|
def remove_user
|
|
93
|
+
clear_account_rights(new_resource.username)
|
|
89
94
|
@net_user.delete
|
|
90
95
|
end
|
|
91
96
|
|
data/lib/chef/provider/user.rb
CHANGED
|
@@ -66,14 +66,23 @@ class Chef
|
|
|
66
66
|
end
|
|
67
67
|
current_resource.comment(user_info.gecos)
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
begin
|
|
70
|
+
require "shadow"
|
|
71
|
+
rescue LoadError
|
|
72
|
+
@shadow_lib_ok = false
|
|
73
|
+
else
|
|
74
|
+
@shadow_info = Shadow::Passwd.getspnam(new_resource.username)
|
|
75
|
+
# This conditional remains in place until we can sort out whether we need it.
|
|
76
|
+
# Currently removing it causes tests to fail, but that /seems/ to be mocking/setup issues.
|
|
77
|
+
# Some notes for context:
|
|
78
|
+
# 1. Ruby's ETC.getpwnam makes use of /etc/passwd file (https://github.com/ruby/etc/blob/master/ext/etc/etc.c),
|
|
79
|
+
# which returns "x" for a nil password. on AIX it returns a "*"
|
|
80
|
+
# (https://www.ibm.com/docs/bg/aix/7.2?topic=passwords-using-etcpasswd-file)
|
|
81
|
+
# 2. On AIX platforms ruby_shadow does not work as it does not
|
|
82
|
+
# store encrypted passwords in the /etc/passwd file but in /etc/security/passwd file.
|
|
83
|
+
# The AIX provider for user currently declares it does not support ruby-shadow.
|
|
84
|
+
if new_resource.password && current_resource.password == "x"
|
|
85
|
+
current_resource.password(@shadow_info.sp_pwdp)
|
|
77
86
|
end
|
|
78
87
|
end
|
|
79
88
|
|
|
@@ -83,6 +92,27 @@ class Chef
|
|
|
83
92
|
current_resource
|
|
84
93
|
end
|
|
85
94
|
|
|
95
|
+
# An overridable for platforms that do not support ruby shadow. This way we
|
|
96
|
+
# can verify that the platform supports ruby shadow before requiring that
|
|
97
|
+
# it be available.
|
|
98
|
+
def supports_ruby_shadow?
|
|
99
|
+
true
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def load_shadow_options
|
|
103
|
+
unless @shadow_info.nil?
|
|
104
|
+
current_resource.inactive(@shadow_info.sp_inact&.to_i)
|
|
105
|
+
# sp_expire gives time since epoch in days till expiration. Need to convert that
|
|
106
|
+
# to time in seconds since epoch and output date format for comparison
|
|
107
|
+
expire_date = if @shadow_info.sp_expire.nil?
|
|
108
|
+
@shadow_info.sp_expire
|
|
109
|
+
else
|
|
110
|
+
Time.at(@shadow_info.sp_expire * 60 * 60 * 24).strftime("%Y-%m-%d")
|
|
111
|
+
end
|
|
112
|
+
current_resource.expire_date(expire_date)
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
86
116
|
def define_resource_requirements
|
|
87
117
|
requirements.assert(:create, :modify, :manage, :lock, :unlock) do |a|
|
|
88
118
|
a.assertion { @group_name_resolved }
|
|
@@ -90,11 +120,17 @@ class Chef
|
|
|
90
120
|
a.whyrun "group name #{new_resource.gid} does not exist. This will cause group assignment to fail. Assuming this group will have been created previously."
|
|
91
121
|
end
|
|
92
122
|
requirements.assert(:all_actions) do |a|
|
|
93
|
-
a.assertion { @shadow_lib_ok }
|
|
123
|
+
a.assertion { !supports_ruby_shadow? || @shadow_lib_ok }
|
|
94
124
|
a.failure_message Chef::Exceptions::MissingLibrary, "You must have ruby-shadow installed for password support!"
|
|
95
125
|
a.whyrun "ruby-shadow is not installed. Attempts to set user password will cause failure. Assuming that this gem will have been previously installed." \
|
|
96
126
|
"Note that user update converge may report false-positive on the basis of mismatched password. "
|
|
97
127
|
end
|
|
128
|
+
requirements.assert(:all_actions) do |a|
|
|
129
|
+
# either neither linux-only value is set, or we need to be on Linux.
|
|
130
|
+
a.assertion { (!new_resource.expire_date && !new_resource.inactive) || linux? }
|
|
131
|
+
a.failure_message Chef::Exceptions::User, "Properties expire_date and inactive are not supported by this OS or have not been implemented for this OS yet."
|
|
132
|
+
a.whyrun "Properties expire_date and inactive are ignored as they are not supported by this OS or have not been implemented yet for this OS"
|
|
133
|
+
end
|
|
98
134
|
requirements.assert(:modify, :lock, :unlock) do |a|
|
|
99
135
|
a.assertion { @user_exists }
|
|
100
136
|
a.failure_message(Chef::Exceptions::User, "Cannot modify user #{new_resource.username} - does not exist!")
|
|
@@ -44,7 +44,12 @@ class Chef
|
|
|
44
44
|
mode new_resource.mode
|
|
45
45
|
if new_resource.make_cache
|
|
46
46
|
notifies :run, "execute[yum clean metadata #{new_resource.repositoryid}]", :immediately if new_resource.clean_metadata || new_resource.clean_headers
|
|
47
|
-
|
|
47
|
+
# makecache fast only works on non-dnf systems.
|
|
48
|
+
if !which("dnf") && new_resource.makecache_fast
|
|
49
|
+
notifies :run, "execute[yum-makecache-fast-#{new_resource.repositoryid}]", :immediately
|
|
50
|
+
else
|
|
51
|
+
notifies :run, "execute[yum-makecache-#{new_resource.repositoryid}]", :immediately
|
|
52
|
+
end
|
|
48
53
|
notifies :flush_cache, "package[package-cache-reload-#{new_resource.repositoryid}]", :immediately
|
|
49
54
|
end
|
|
50
55
|
end
|
|
@@ -63,6 +68,13 @@ class Chef
|
|
|
63
68
|
only_if { new_resource.enabled }
|
|
64
69
|
end
|
|
65
70
|
|
|
71
|
+
# download only the minimum required metadata
|
|
72
|
+
execute "yum-makecache-fast-#{new_resource.repositoryid}" do
|
|
73
|
+
command "yum -q -y makecache fast --disablerepo=* --enablerepo=#{new_resource.repositoryid}"
|
|
74
|
+
action :nothing
|
|
75
|
+
only_if { new_resource.enabled }
|
|
76
|
+
end
|
|
77
|
+
|
|
66
78
|
package "package-cache-reload-#{new_resource.repositoryid}" do
|
|
67
79
|
action :nothing
|
|
68
80
|
end
|
data/lib/chef/provider.rb
CHANGED
|
@@ -113,7 +113,7 @@ class Chef
|
|
|
113
113
|
dirname = ::File.dirname(partial)
|
|
114
114
|
basename = ::File.basename(partial, ".rb")
|
|
115
115
|
basename = basename[1..] if basename.start_with?("_")
|
|
116
|
-
class_eval IO.read(::File.expand_path("#{dirname}/_#{basename}.rb", ::File.dirname(caller_locations.first.
|
|
116
|
+
class_eval IO.read(::File.expand_path("#{dirname}/_#{basename}.rb", ::File.dirname(caller_locations.first.path)))
|
|
117
117
|
end
|
|
118
118
|
|
|
119
119
|
# delegate to the resource
|
data/lib/chef/recipe.rb
CHANGED
|
@@ -70,20 +70,12 @@ class Chef
|
|
|
70
70
|
|
|
71
71
|
# This was moved to Chef::Node#tag, redirecting here for compatibility
|
|
72
72
|
def tag(*tags)
|
|
73
|
-
|
|
73
|
+
node.tag(*tags)
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
#
|
|
77
|
-
#
|
|
78
|
-
# === Parameters
|
|
79
|
-
# tags<Array>:: A list of tags
|
|
80
|
-
#
|
|
81
|
-
# === Returns
|
|
82
|
-
# tags<Array>:: The current list of run_context.node.tags
|
|
76
|
+
# This was moved to Chef::Node#untag, redirecting here for compatibility
|
|
83
77
|
def untag(*tags)
|
|
84
|
-
tags
|
|
85
|
-
run_context.node.tags.delete(tag)
|
|
86
|
-
end
|
|
78
|
+
node.untag(*tags)
|
|
87
79
|
end
|
|
88
80
|
|
|
89
81
|
def from_yaml_file(filename)
|
|
@@ -101,7 +93,7 @@ class Chef
|
|
|
101
93
|
end
|
|
102
94
|
|
|
103
95
|
def from_yaml(string)
|
|
104
|
-
res = ::YAML.safe_load(string)
|
|
96
|
+
res = ::YAML.safe_load(string, permitted_classes: [Date])
|
|
105
97
|
unless res.is_a?(Hash) && res.key?("resources")
|
|
106
98
|
raise ArgumentError, "YAML recipe '#{source_file}' must contain a top-level 'resources' hash (YAML sequence), i.e. 'resources:'"
|
|
107
99
|
end
|