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