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
|
@@ -26,7 +26,6 @@ end
|
|
|
26
26
|
class Chef
|
|
27
27
|
class Resource
|
|
28
28
|
class AptRepository < Chef::Resource
|
|
29
|
-
unified_mode true
|
|
30
29
|
|
|
31
30
|
provides(:apt_repository) { true }
|
|
32
31
|
|
|
@@ -99,6 +98,19 @@ class Chef
|
|
|
99
98
|
end
|
|
100
99
|
```
|
|
101
100
|
|
|
101
|
+
**Add repository that needs custom options**:
|
|
102
|
+
|
|
103
|
+
```ruby
|
|
104
|
+
apt_repository 'corretto' do
|
|
105
|
+
uri 'https://apt.corretto.aws'
|
|
106
|
+
arch 'amd64'
|
|
107
|
+
distribution 'stable'
|
|
108
|
+
components ['main']
|
|
109
|
+
options ['target-=Contents-deb']
|
|
110
|
+
key 'https://apt.corretto.aws/corretto.key'
|
|
111
|
+
end
|
|
112
|
+
```
|
|
113
|
+
|
|
102
114
|
**Remove a repository from the list**:
|
|
103
115
|
|
|
104
116
|
```ruby
|
|
@@ -152,6 +164,10 @@ class Chef
|
|
|
152
164
|
property :key_proxy, [String, nil, FalseClass],
|
|
153
165
|
description: "If set, a specified proxy is passed to GPG via `http-proxy=`."
|
|
154
166
|
|
|
167
|
+
property :signed_by, [String, true, false, nil],
|
|
168
|
+
description: "If a string, specify the file and/or fingerprint the repo is signed with. If true, set Signed-With to use the specified key",
|
|
169
|
+
default: true
|
|
170
|
+
|
|
155
171
|
property :cookbook, [String, nil, FalseClass],
|
|
156
172
|
description: "If key should be a cookbook_file, specify a cookbook where the key is located for files/default. Default value is nil, so it will use the cookbook where the resource is used.",
|
|
157
173
|
desired_state: false
|
|
@@ -160,6 +176,10 @@ class Chef
|
|
|
160
176
|
description: "Determines whether to rebuild the APT package cache.",
|
|
161
177
|
default: true, desired_state: false
|
|
162
178
|
|
|
179
|
+
property :options, [String, Array],
|
|
180
|
+
description: "Additional options to set for the repository.",
|
|
181
|
+
default: [], coerce: proc { |x| Array(x) }
|
|
182
|
+
|
|
163
183
|
default_action :add
|
|
164
184
|
allowed_actions :add, :remove
|
|
165
185
|
|
|
@@ -188,6 +208,24 @@ class Chef
|
|
|
188
208
|
end.compact
|
|
189
209
|
end
|
|
190
210
|
|
|
211
|
+
# run the specified command and extract the public key ids
|
|
212
|
+
# accepts the command so it can be used to extract both the current keys
|
|
213
|
+
# and the new keys
|
|
214
|
+
# @param [Array<String>] cmd the command to run
|
|
215
|
+
#
|
|
216
|
+
# @return [Array] an array of key ids
|
|
217
|
+
def extract_public_keys_from_cmd(*cmd)
|
|
218
|
+
so = shell_out(*cmd)
|
|
219
|
+
# Sample output
|
|
220
|
+
# pub:-:4096:1:D94AA3F0EFE21092:1336774248:::-:::scSC::::::23::0:
|
|
221
|
+
so.stdout.split(/\n/).map do |t|
|
|
222
|
+
if t.match(/^pub:/)
|
|
223
|
+
f = t.split(":")
|
|
224
|
+
f.slice(0, 6).join(":")
|
|
225
|
+
end
|
|
226
|
+
end.compact
|
|
227
|
+
end
|
|
228
|
+
|
|
191
229
|
# validate the key against the apt keystore to see if that version is expired
|
|
192
230
|
# @param [String] key
|
|
193
231
|
#
|
|
@@ -199,6 +237,17 @@ class Chef
|
|
|
199
237
|
valid
|
|
200
238
|
end
|
|
201
239
|
|
|
240
|
+
# validate the key against the a gpg keyring to see if that version is expired
|
|
241
|
+
# @param [String] key
|
|
242
|
+
#
|
|
243
|
+
# @return [Boolean] is the key valid or not
|
|
244
|
+
def keyring_key_is_valid?(keyring, key)
|
|
245
|
+
valid = shell_out("gpg", "--no-default-keyring", "--keyring", keyring, "--list-public-keys", key).stdout.each_line.none?(/\[(expired|revoked):/)
|
|
246
|
+
|
|
247
|
+
logger.debug "key #{key} #{valid ? "is valid" : "is not valid"}"
|
|
248
|
+
valid
|
|
249
|
+
end
|
|
250
|
+
|
|
202
251
|
# return the specified cookbook name or the cookbook containing the
|
|
203
252
|
# resource.
|
|
204
253
|
#
|
|
@@ -223,8 +272,8 @@ class Chef
|
|
|
223
272
|
def no_new_keys?(file)
|
|
224
273
|
# Now we are using the option --with-colons that works across old os versions
|
|
225
274
|
# as well as the latest (16.10). This for both `apt-key` and `gpg` commands
|
|
226
|
-
installed_keys =
|
|
227
|
-
proposed_keys =
|
|
275
|
+
installed_keys = extract_public_keys_from_cmd(*LIST_APT_KEY_FINGERPRINTS)
|
|
276
|
+
proposed_keys = extract_public_keys_from_cmd("gpg", "--with-fingerprint", "--with-colons", file)
|
|
228
277
|
(installed_keys & proposed_keys).sort == proposed_keys.sort
|
|
229
278
|
end
|
|
230
279
|
|
|
@@ -245,6 +294,10 @@ class Chef
|
|
|
245
294
|
end
|
|
246
295
|
end
|
|
247
296
|
|
|
297
|
+
def keyring_path
|
|
298
|
+
"/etc/apt/keyrings/#{new_resource.repo_name}.gpg"
|
|
299
|
+
end
|
|
300
|
+
|
|
248
301
|
# Fetch the key using either cookbook_file or remote_file, validate it,
|
|
249
302
|
# and install it with apt-key add
|
|
250
303
|
# @param [String] key the key to install
|
|
@@ -254,11 +307,19 @@ class Chef
|
|
|
254
307
|
# @return [void]
|
|
255
308
|
def install_key_from_uri(key)
|
|
256
309
|
key_name = key.gsub(/[^0-9A-Za-z\-]/, "_")
|
|
257
|
-
|
|
310
|
+
keyfile_path = ::File.join(Chef::Config[:file_cache_path], key_name)
|
|
258
311
|
tmp_dir = Dir.mktmpdir(".gpg")
|
|
259
312
|
at_exit { FileUtils.remove_entry(tmp_dir) }
|
|
260
313
|
|
|
261
|
-
|
|
314
|
+
if new_resource.signed_by
|
|
315
|
+
keyfile_path = keyring_path
|
|
316
|
+
|
|
317
|
+
directory "/etc/apt/keyrings" do
|
|
318
|
+
mode "0755"
|
|
319
|
+
end
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
declare_resource(key_type(key), keyfile_path) do
|
|
262
323
|
source key
|
|
263
324
|
mode "0644"
|
|
264
325
|
sensitive new_resource.sensitive
|
|
@@ -266,13 +327,27 @@ class Chef
|
|
|
266
327
|
verify "gpg --homedir #{tmp_dir} %{path}"
|
|
267
328
|
end
|
|
268
329
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
330
|
+
# If signed by is true, then we don't need to
|
|
331
|
+
# add to the default keyring. Instead make sure it's dearmored
|
|
332
|
+
if new_resource.signed_by
|
|
333
|
+
execute "gpg dearmor key" do
|
|
334
|
+
input ::File.read(keyfile_path)
|
|
335
|
+
command [ "gpg", "--batch", "--yes", "--dearmor", "-o", keyfile_path ]
|
|
336
|
+
default_env true
|
|
337
|
+
sensitive new_resource.sensitive
|
|
338
|
+
action :run
|
|
339
|
+
only_if { ::File.read(keyfile_path).include?("-----BEGIN PGP PUBLIC KEY BLOCK-----") }
|
|
340
|
+
notifies :run, "execute[apt-cache gencaches]", :immediately
|
|
341
|
+
end
|
|
342
|
+
else
|
|
343
|
+
execute "apt-key add #{keyfile_path}" do
|
|
344
|
+
command [ "apt-key", "add", keyfile_path ]
|
|
345
|
+
default_env true
|
|
346
|
+
sensitive new_resource.sensitive
|
|
347
|
+
action :run
|
|
348
|
+
not_if { no_new_keys?(keyfile_path) }
|
|
349
|
+
notifies :run, "execute[apt-cache gencaches]", :immediately
|
|
350
|
+
end
|
|
276
351
|
end
|
|
277
352
|
end
|
|
278
353
|
|
|
@@ -302,6 +377,10 @@ class Chef
|
|
|
302
377
|
#
|
|
303
378
|
# @return [void]
|
|
304
379
|
def install_key_from_keyserver(key, keyserver = new_resource.keyserver)
|
|
380
|
+
if new_resource.signed_by
|
|
381
|
+
install_key_from_keyserver_to_keyring(key, keyserver, keyring_path)
|
|
382
|
+
return
|
|
383
|
+
end
|
|
305
384
|
execute "install-key #{key}" do
|
|
306
385
|
command keyserver_install_cmd(key, keyserver)
|
|
307
386
|
default_env true
|
|
@@ -318,6 +397,31 @@ class Chef
|
|
|
318
397
|
raise "The key #{key} is invalid and cannot be used to verify an apt repository." unless key_is_valid?(key.upcase)
|
|
319
398
|
end
|
|
320
399
|
|
|
400
|
+
# @param [String] key
|
|
401
|
+
# @param [String] keyserver
|
|
402
|
+
# @param [String] keyring
|
|
403
|
+
def install_key_from_keyserver_to_keyring(key, keyserver, keyring)
|
|
404
|
+
keyserver = "hkp://#{keyserver}:80" unless keyserver.start_with?("hkp://")
|
|
405
|
+
|
|
406
|
+
cmd = "gpg --no-default-keyring --keyring #{keyring}"
|
|
407
|
+
cmd << " --keyserver-options http-proxy=#{new_resource.key_proxy}" if new_resource.key_proxy
|
|
408
|
+
cmd << " --keyserver #{keyserver}"
|
|
409
|
+
cmd << " --recv #{key}"
|
|
410
|
+
|
|
411
|
+
execute "install-key #{key}" do
|
|
412
|
+
command cmd
|
|
413
|
+
default_env true
|
|
414
|
+
sensitive new_resource.sensitive
|
|
415
|
+
not_if do
|
|
416
|
+
present = shell_out(*%W{gpg --no-default-keyring --keyring #{keyring} --list-public-keys --with-fingerprint --with-colons #{key}}).exitstatus != 0
|
|
417
|
+
present && keyring_key_is_valid?(keyring, key.upcase)
|
|
418
|
+
end
|
|
419
|
+
notifies :run, "execute[apt-cache gencaches]", :immediately
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
raise "The key #{key} is invalid and cannot be used to verify an apt repository." unless keyring_key_is_valid?(keyring, key.upcase)
|
|
423
|
+
end
|
|
424
|
+
|
|
321
425
|
# @param [String] owner
|
|
322
426
|
# @param [String] repo
|
|
323
427
|
#
|
|
@@ -371,19 +475,23 @@ class Chef
|
|
|
371
475
|
# @param [Array] components
|
|
372
476
|
# @param [Boolean] trusted
|
|
373
477
|
# @param [String] arch
|
|
478
|
+
# @param [String] signed_by
|
|
479
|
+
# @param [Array] options
|
|
374
480
|
# @param [Boolean] add_src
|
|
375
481
|
#
|
|
376
482
|
# @return [String] complete repo config text
|
|
377
|
-
def build_repo(uri, distribution, components, trusted, arch, add_src = false)
|
|
483
|
+
def build_repo(uri, distribution, components, trusted, arch, signed_by, options, add_src = false)
|
|
378
484
|
uri = make_ppa_url(uri) if is_ppa_url?(uri)
|
|
379
485
|
|
|
380
486
|
uri = Addressable::URI.parse(uri)
|
|
381
487
|
components = Array(components).join(" ")
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
488
|
+
options_list = []
|
|
489
|
+
options_list << "arch=#{arch}" if arch
|
|
490
|
+
options_list << "trusted=yes" if trusted
|
|
491
|
+
options_list << "signed-by=#{signed_by}" if signed_by
|
|
492
|
+
options_list += options
|
|
493
|
+
optstr = unless options_list.empty?
|
|
494
|
+
"[" + options_list.join(" ") + "]"
|
|
387
495
|
end
|
|
388
496
|
info = [ optstr, uri.normalize.to_s, distribution, components ].compact.join(" ")
|
|
389
497
|
repo = "deb #{info}\n"
|
|
@@ -438,12 +546,19 @@ class Chef
|
|
|
438
546
|
|
|
439
547
|
cleanup_legacy_file!
|
|
440
548
|
|
|
549
|
+
signed_by = new_resource.signed_by
|
|
550
|
+
if signed_by == true
|
|
551
|
+
signed_by = keyring_path
|
|
552
|
+
end
|
|
553
|
+
|
|
441
554
|
repo = build_repo(
|
|
442
555
|
new_resource.uri,
|
|
443
556
|
new_resource.distribution,
|
|
444
557
|
repo_components,
|
|
445
558
|
new_resource.trusted,
|
|
446
559
|
new_resource.arch,
|
|
560
|
+
signed_by,
|
|
561
|
+
new_resource.options,
|
|
447
562
|
new_resource.deb_src
|
|
448
563
|
)
|
|
449
564
|
|
|
@@ -470,6 +585,11 @@ class Chef
|
|
|
470
585
|
action :nothing
|
|
471
586
|
end
|
|
472
587
|
|
|
588
|
+
file keyring_path do
|
|
589
|
+
sensitive new_resource.sensitive
|
|
590
|
+
action :delete
|
|
591
|
+
end
|
|
592
|
+
|
|
473
593
|
file "/etc/apt/sources.list.d/#{new_resource.repo_name}.list" do
|
|
474
594
|
sensitive new_resource.sensitive
|
|
475
595
|
action :delete
|
data/lib/chef/resource/bash.rb
CHANGED
|
@@ -21,7 +21,6 @@ require_relative "script"
|
|
|
21
21
|
class Chef
|
|
22
22
|
class Resource
|
|
23
23
|
class Bash < Chef::Resource::Script
|
|
24
|
-
unified_mode true
|
|
25
24
|
|
|
26
25
|
provides :bash
|
|
27
26
|
|
|
@@ -44,6 +43,19 @@ class Chef
|
|
|
44
43
|
end
|
|
45
44
|
```
|
|
46
45
|
|
|
46
|
+
**Using escape characters in a string of code**
|
|
47
|
+
|
|
48
|
+
In the following example, the `find` command uses an escape character (`\`). Use a second escape character (`\\`) to preserve the escape character in the code string:
|
|
49
|
+
|
|
50
|
+
```ruby
|
|
51
|
+
bash 'delete some archives ' do
|
|
52
|
+
code <<-EOH
|
|
53
|
+
find ./ -name "*.tar.Z" -mtime +180 -exec rm -f {} \\;
|
|
54
|
+
EOH
|
|
55
|
+
ignore_failure true
|
|
56
|
+
end
|
|
57
|
+
```
|
|
58
|
+
|
|
47
59
|
**Install a file from a remote location**
|
|
48
60
|
|
|
49
61
|
The following is an example of how to install the foo123 module for Nginx. This module adds shell-style functionality to an Nginx configuration file and does the following:
|
data/lib/chef/resource/batch.rb
CHANGED
|
@@ -20,7 +20,6 @@ require "chef-utils/dist" unless defined?(ChefUtils::Dist)
|
|
|
20
20
|
class Chef
|
|
21
21
|
class Resource
|
|
22
22
|
class ChefClientConfig < Chef::Resource
|
|
23
|
-
unified_mode true
|
|
24
23
|
|
|
25
24
|
provides :chef_client_config
|
|
26
25
|
|
|
@@ -255,21 +254,20 @@ class Chef
|
|
|
255
254
|
description: "The data collector token to interact with the data collector server URL (Automate). Note: If possible, use Chef Infra Server to do all data collection reporting, as this removes the need to distribute tokens to individual nodes.",
|
|
256
255
|
introduced: "17.8"
|
|
257
256
|
|
|
258
|
-
action :create, description: "Create a client.rb config file for configuring #{ChefUtils::Dist::Infra::PRODUCT}." do
|
|
259
|
-
|
|
260
|
-
|
|
257
|
+
action :create, description: "Create a client.rb config file and folders for configuring #{ChefUtils::Dist::Infra::PRODUCT}." do
|
|
258
|
+
[
|
|
259
|
+
new_resource.config_directory,
|
|
260
|
+
(::File.dirname(new_resource.log_location) if new_resource.log_location.is_a?(String) && !%w{STDOUT STDERR}.include?(new_resource.log_location) && !new_resource.log_location.empty?),
|
|
261
|
+
new_resource.file_backup_path,
|
|
262
|
+
new_resource.file_cache_path,
|
|
263
|
+
::File.join(new_resource.config_directory, "client.d"),
|
|
264
|
+
(::File.dirname(new_resource.pid_file) unless new_resource.pid_file.nil?),
|
|
265
|
+
].compact.each do |dir_path|
|
|
266
|
+
|
|
267
|
+
directory dir_path do
|
|
261
268
|
user new_resource.user unless new_resource.user.nil?
|
|
262
269
|
group new_resource.group unless new_resource.group.nil?
|
|
263
|
-
mode "0750"
|
|
264
|
-
recursive true
|
|
265
|
-
end
|
|
266
|
-
end
|
|
267
|
-
|
|
268
|
-
unless ::Dir.exist?(::File.join(new_resource.config_directory, "client.d"))
|
|
269
|
-
directory ::File.join(new_resource.config_directory, "client.d") do
|
|
270
|
-
user new_resource.user unless new_resource.user.nil?
|
|
271
|
-
group new_resource.group unless new_resource.group.nil?
|
|
272
|
-
mode "0750"
|
|
270
|
+
mode dir_path == ::File.dirname(new_resource.log_location.to_s) ? "0755" : "0750"
|
|
273
271
|
recursive true
|
|
274
272
|
end
|
|
275
273
|
end
|
|
@@ -22,7 +22,6 @@ require "digest/md5" unless defined?(Digest::MD5)
|
|
|
22
22
|
class Chef
|
|
23
23
|
class Resource
|
|
24
24
|
class ChefClientCron < Chef::Resource
|
|
25
|
-
unified_mode true
|
|
26
25
|
|
|
27
26
|
provides :chef_client_cron
|
|
28
27
|
|
|
@@ -99,7 +98,7 @@ class Chef
|
|
|
99
98
|
property :splay, [Integer, String],
|
|
100
99
|
default: 300,
|
|
101
100
|
coerce: proc { |x| Integer(x) },
|
|
102
|
-
callbacks: { "should be a positive number" => proc { |v| v
|
|
101
|
+
callbacks: { "should be a positive number" => proc { |v| v >= 0 } },
|
|
103
102
|
description: "A random number of seconds between 0 and X to add to interval so that all #{ChefUtils::Dist::Infra::CLIENT} commands don't execute at the same time."
|
|
104
103
|
|
|
105
104
|
property :mailto, String,
|
|
@@ -19,7 +19,6 @@ require "chef-utils/dist" unless defined?(ChefUtils::Dist)
|
|
|
19
19
|
class Chef
|
|
20
20
|
class Resource
|
|
21
21
|
class ChefClientLaunchd < Chef::Resource
|
|
22
|
-
unified_mode true
|
|
23
22
|
|
|
24
23
|
provides :chef_client_launchd
|
|
25
24
|
|
|
@@ -61,7 +60,7 @@ class Chef
|
|
|
61
60
|
property :splay, [Integer, String],
|
|
62
61
|
default: 300,
|
|
63
62
|
coerce: proc { |x| Integer(x) },
|
|
64
|
-
callbacks: { "should be a positive number" => proc { |v| v
|
|
63
|
+
callbacks: { "should be a positive number" => proc { |v| v >= 0 } },
|
|
65
64
|
description: "A random number of seconds between 0 and X to add to interval so that all #{ChefUtils::Dist::Infra::CLIENT} commands don't execute at the same time."
|
|
66
65
|
|
|
67
66
|
property :accept_chef_license, [true, false],
|
|
@@ -135,6 +134,7 @@ class Chef
|
|
|
135
134
|
program_arguments ["/bin/bash",
|
|
136
135
|
"-c",
|
|
137
136
|
"echo; echo #{ChefUtils::Dist::Infra::PRODUCT} launchd daemon config has been updated. Manually unloading and reloading the daemon; echo Now unloading the daemon; sudo /bin/launchctl unload /Library/LaunchDaemons/com.#{ChefUtils::Dist::Infra::SHORT}.#{ChefUtils::Dist::Infra::CLIENT}.plist; sleep 2; echo Now loading the daemon; sudo /bin/launchctl load /Library/LaunchDaemons/com.#{ChefUtils::Dist::Infra::SHORT}.#{ChefUtils::Dist::Infra::CLIENT}.plist"]
|
|
137
|
+
run_at_load true
|
|
138
138
|
action :enable # enable creates the plist & triggers service restarts on change
|
|
139
139
|
end
|
|
140
140
|
|
|
@@ -20,7 +20,6 @@ require "chef-utils/dist" unless defined?(ChefUtils::Dist)
|
|
|
20
20
|
class Chef
|
|
21
21
|
class Resource
|
|
22
22
|
class ChefClientScheduledTask < Chef::Resource
|
|
23
|
-
unified_mode true
|
|
24
23
|
|
|
25
24
|
provides :chef_client_scheduled_task
|
|
26
25
|
|
|
@@ -108,7 +107,7 @@ class Chef
|
|
|
108
107
|
|
|
109
108
|
property :splay, [Integer, String],
|
|
110
109
|
coerce: proc { |x| Integer(x) },
|
|
111
|
-
callbacks: { "should be a positive number" => proc { |v| v
|
|
110
|
+
callbacks: { "should be a positive number" => proc { |v| v >= 0 } },
|
|
112
111
|
description: "A random number of seconds between 0 and X to add to interval so that all #{ChefUtils::Dist::Infra::CLIENT} commands don't execute at the same time.",
|
|
113
112
|
default: 300
|
|
114
113
|
|
|
@@ -123,7 +122,8 @@ class Chef
|
|
|
123
122
|
|
|
124
123
|
property :config_directory, String,
|
|
125
124
|
description: "The path of the config directory.",
|
|
126
|
-
default: ChefConfig::Config.etc_chef_dir
|
|
125
|
+
default: ChefConfig::Config.etc_chef_dir,
|
|
126
|
+
default_description: ChefConfig::Config.c_chef_dir
|
|
127
127
|
|
|
128
128
|
property :log_directory, String,
|
|
129
129
|
description: "The path of the directory to create the log file in.",
|
|
@@ -20,7 +20,6 @@ require "chef-utils/dist" unless defined?(ChefUtils::Dist)
|
|
|
20
20
|
class Chef
|
|
21
21
|
class Resource
|
|
22
22
|
class ChefClientSystemdTimer < Chef::Resource
|
|
23
|
-
unified_mode true
|
|
24
23
|
|
|
25
24
|
provides :chef_client_systemd_timer
|
|
26
25
|
|
|
@@ -104,6 +103,10 @@ class Chef
|
|
|
104
103
|
coerce: proc { |x| Integer(x) },
|
|
105
104
|
callbacks: { "should be a positive Integer" => proc { |v| v > 0 } }
|
|
106
105
|
|
|
106
|
+
property :service_umask, [Integer, String],
|
|
107
|
+
description: "Fix umask for hardened systems that have a changed default umask. This changes the chef-client umask so any files or folders are created with new umask. Recommend setting to stand install default of 0022.",
|
|
108
|
+
introduced: "18.5"
|
|
109
|
+
|
|
107
110
|
action :add, description: "Add a systemd timer that runs #{ChefUtils::Dist::Infra::PRODUCT}." do
|
|
108
111
|
systemd_unit "#{new_resource.job_name}.service" do
|
|
109
112
|
content service_content
|
|
@@ -176,6 +179,7 @@ class Chef
|
|
|
176
179
|
"Install" => { "WantedBy" => "multi-user.target" },
|
|
177
180
|
}
|
|
178
181
|
|
|
182
|
+
unit["Service"]["UMask"] = new_resource.service_umask if new_resource.service_umask
|
|
179
183
|
unit["Service"]["ConditionACPower"] = "true" unless new_resource.run_on_battery
|
|
180
184
|
unit["Service"]["CPUQuota"] = "#{new_resource.cpu_quota}%" if new_resource.cpu_quota
|
|
181
185
|
unit["Service"]["Environment"] = new_resource.environment.collect { |k, v| "\"#{k}=#{v}\"" } unless new_resource.environment.empty?
|
|
@@ -23,7 +23,6 @@ require "chef-utils/dist" unless defined?(ChefUtils::Dist)
|
|
|
23
23
|
class Chef
|
|
24
24
|
class Resource
|
|
25
25
|
class ChefGem < Chef::Resource::Package::GemPackage
|
|
26
|
-
unified_mode true
|
|
27
26
|
provides :chef_gem
|
|
28
27
|
|
|
29
28
|
description <<~DESC
|
|
@@ -63,7 +62,7 @@ class Chef
|
|
|
63
62
|
end
|
|
64
63
|
```
|
|
65
64
|
|
|
66
|
-
**Install MySQL gem into #{ChefUtils::Dist::Infra::PRODUCT}
|
|
65
|
+
**Install MySQL gem into #{ChefUtils::Dist::Infra::PRODUCT}**
|
|
67
66
|
```ruby
|
|
68
67
|
apt_update
|
|
69
68
|
|
|
@@ -22,8 +22,6 @@ class Chef
|
|
|
22
22
|
class ChefSleep < Chef::Resource
|
|
23
23
|
provides :chef_sleep
|
|
24
24
|
|
|
25
|
-
unified_mode true
|
|
26
|
-
|
|
27
25
|
description "Use the **chef_sleep** resource to pause (sleep) for a number of seconds during a #{ChefUtils::Dist::Infra::PRODUCT} run. Only use this resource when a command or service exits successfully but is not ready for the next step in a recipe."
|
|
28
26
|
introduced "15.5"
|
|
29
27
|
examples <<~DOC
|
|
@@ -47,7 +45,7 @@ class Chef
|
|
|
47
45
|
service 'Service that is slow to start and reports as started' do
|
|
48
46
|
service_name 'my_database'
|
|
49
47
|
action :start
|
|
50
|
-
notifies :sleep, chef_sleep[
|
|
48
|
+
notifies :sleep, 'chef_sleep[wait for service start]'
|
|
51
49
|
end
|
|
52
50
|
|
|
53
51
|
chef_sleep 'wait for service start' do
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
class Chef
|
|
18
18
|
class Resource
|
|
19
19
|
class ChocolateyFeature < Chef::Resource
|
|
20
|
-
unified_mode true
|
|
21
20
|
provides :chocolatey_feature
|
|
22
21
|
|
|
23
22
|
description "Use the **chocolatey_feature** resource to enable and disable Chocolatey features. Note: The Chocolatey package manager is not installed on Windows by default. You will need to install it prior to using this resource by adding the [Chocolatey cookbook](https://supermarket.chef.io/cookbooks/chocolatey/) to your node's run list."
|