chef 15.11.3-universal-mingw32 → 16.1.16-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -7
- data/README.md +1 -1
- data/Rakefile +44 -16
- data/chef.gemspec +6 -4
- data/distro/powershell/chef/chef.psm1 +3 -3
- data/distro/templates/powershell/chef/chef.psm1.erb +3 -3
- data/lib/chef/action_collection.rb +16 -5
- data/lib/chef/application.rb +33 -54
- data/lib/chef/application/apply.rb +18 -1
- data/lib/chef/application/base.rb +8 -3
- data/lib/chef/application/knife.rb +1 -1
- data/lib/chef/chef_class.rb +4 -4
- data/lib/chef/chef_fs/file_system/chef_server/acls_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +6 -2
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +3 -3
- data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
- data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +1 -1
- data/lib/chef/chef_fs/path_utils.rb +3 -3
- data/lib/chef/client.rb +16 -14
- data/lib/chef/config.rb +1 -1
- data/lib/chef/cookbook/file_system_file_vendor.rb +1 -1
- data/lib/chef/cookbook/gem_installer.rb +1 -1
- data/lib/chef/cookbook/metadata.rb +45 -22
- data/lib/chef/cookbook_loader.rb +1 -1
- data/lib/chef/cookbook_manifest.rb +1 -1
- data/lib/chef/cookbook_site_streaming_uploader.rb +1 -1
- data/lib/chef/cookbook_version.rb +38 -3
- data/lib/chef/data_collector.rb +1 -1
- data/lib/chef/data_collector/error_handlers.rb +1 -1
- data/lib/chef/data_collector/run_end_message.rb +7 -1
- data/lib/chef/decorator/lazy_array.rb +2 -2
- data/lib/chef/deprecated.rb +4 -0
- data/lib/chef/digester.rb +4 -4
- data/lib/chef/dist.rb +8 -0
- data/lib/chef/dsl/chef_vault.rb +84 -0
- data/lib/chef/dsl/declare_resource.rb +7 -5
- data/lib/chef/dsl/platform_introspection.rb +3 -2
- data/lib/chef/dsl/recipe.rb +7 -12
- data/lib/chef/dsl/universal.rb +3 -7
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/encryptor.rb +1 -1
- data/lib/chef/event_dispatch/base.rb +3 -0
- data/lib/chef/formatters/base.rb +1 -1
- data/lib/chef/formatters/doc.rb +1 -1
- data/lib/chef/formatters/indentable_output_stream.rb +7 -16
- data/lib/chef/http.rb +1 -1
- data/lib/chef/http/decompressor.rb +1 -1
- data/lib/chef/http/http_request.rb +3 -2
- data/lib/chef/json_compat.rb +1 -1
- data/lib/chef/key.rb +1 -1
- data/lib/chef/knife.rb +2 -4
- data/lib/chef/knife/acl_add.rb +57 -0
- data/lib/chef/knife/acl_base.rb +183 -0
- data/lib/chef/knife/acl_bulk_add.rb +78 -0
- data/lib/chef/knife/acl_bulk_remove.rb +83 -0
- data/lib/chef/knife/acl_remove.rb +62 -0
- data/lib/chef/knife/acl_show.rb +56 -0
- data/lib/chef/knife/bootstrap.rb +84 -90
- data/lib/chef/knife/bootstrap/chef_vault_handler.rb +2 -2
- data/lib/chef/knife/bootstrap/client_builder.rb +2 -2
- data/lib/chef/knife/bootstrap/templates/chef-full.erb +11 -11
- data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +12 -12
- data/lib/chef/knife/core/bootstrap_context.rb +63 -60
- data/lib/chef/knife/core/generic_presenter.rb +4 -3
- data/lib/chef/knife/core/hashed_command_loader.rb +1 -1
- data/lib/chef/knife/core/node_presenter.rb +2 -2
- data/lib/chef/knife/core/status_presenter.rb +5 -5
- data/lib/chef/knife/core/subcommand_loader.rb +1 -1
- data/lib/chef/knife/core/ui.rb +17 -1
- data/lib/chef/knife/core/windows_bootstrap_context.rb +44 -42
- data/lib/chef/knife/data_bag_secret_options.rb +18 -45
- data/lib/chef/knife/group_add.rb +55 -0
- data/lib/chef/knife/{cookbook_site_download.rb → group_create.rb} +21 -12
- data/lib/chef/knife/group_destroy.rb +53 -0
- data/lib/chef/knife/{cookbook_site_list.rb → group_list.rb} +14 -11
- data/lib/chef/knife/group_remove.rb +56 -0
- data/lib/chef/knife/{cookbook_site_install.rb → group_show.rb} +21 -12
- data/lib/chef/knife/key_create_base.rb +1 -1
- data/lib/chef/knife/key_edit_base.rb +1 -1
- data/lib/chef/knife/ssh.rb +12 -31
- data/lib/chef/knife/status.rb +3 -3
- data/lib/chef/knife/supermarket_download.rb +1 -2
- data/lib/chef/knife/supermarket_install.rb +2 -3
- data/lib/chef/knife/supermarket_list.rb +1 -2
- data/lib/chef/knife/supermarket_search.rb +1 -2
- data/lib/chef/knife/supermarket_share.rb +1 -2
- data/lib/chef/knife/supermarket_show.rb +1 -2
- data/lib/chef/knife/supermarket_unshare.rb +1 -2
- data/lib/chef/knife/{cookbook_site_show.rb → user_dissociate.rb} +15 -13
- data/lib/chef/knife/{cookbook_site_search.rb → user_invite_add.rb} +16 -13
- data/lib/chef/knife/user_invite_list.rb +34 -0
- data/lib/chef/knife/user_invite_rescind.rb +63 -0
- data/lib/chef/knife/yaml_convert.rb +91 -0
- data/lib/chef/mixin/api_version_request_handling.rb +1 -1
- data/lib/chef/mixin/checksum.rb +0 -1
- data/lib/chef/mixin/openssl_helper.rb +4 -4
- data/lib/chef/mixin/powershell_exec.rb +10 -1
- data/lib/chef/mixin/powershell_out.rb +1 -1
- data/lib/chef/mixin/properties.rb +16 -2
- data/lib/chef/mixin/shell_out.rb +1 -5
- data/lib/chef/monkey_patches/net_http.rb +0 -4
- data/lib/chef/node.rb +18 -6
- data/lib/chef/node/attribute.rb +2 -2
- data/lib/chef/node/immutable_collections.rb +1 -1
- data/lib/chef/node/mixin/immutablize_array.rb +4 -0
- data/lib/chef/node/mixin/immutablize_hash.rb +3 -0
- data/lib/chef/node_map.rb +5 -31
- data/lib/chef/platform/priority_map.rb +4 -4
- data/lib/chef/platform/query_helpers.rb +6 -34
- data/lib/chef/policy_builder/policyfile.rb +1 -1
- data/lib/chef/powershell.rb +14 -0
- data/lib/chef/property.rb +24 -6
- data/lib/chef/provider.rb +40 -6
- data/lib/chef/provider/cron.rb +2 -2
- data/lib/chef/provider/directory.rb +3 -3
- data/lib/chef/provider/dsc_resource.rb +1 -1
- data/lib/chef/provider/dsc_script.rb +1 -1
- data/lib/chef/provider/execute.rb +3 -9
- data/lib/chef/provider/file.rb +6 -6
- data/lib/chef/provider/git.rb +84 -27
- data/lib/chef/provider/group.rb +4 -4
- data/lib/chef/provider/http_request.rb +6 -6
- data/lib/chef/provider/ifconfig.rb +4 -4
- data/lib/chef/provider/launchd.rb +45 -64
- data/lib/chef/provider/link.rb +2 -2
- data/lib/chef/provider/mount.rb +5 -5
- data/lib/chef/provider/osx_profile.rb +7 -3
- data/lib/chef/provider/package.rb +2 -2
- data/lib/chef/provider/package/cab.rb +5 -6
- data/lib/chef/provider/package/chocolatey.rb +1 -3
- data/lib/chef/provider/package/dnf.rb +66 -10
- data/lib/chef/provider/package/dnf/dnf_helper.py +85 -26
- data/lib/chef/provider/package/dnf/python_helper.rb +79 -36
- data/lib/chef/provider/package/dnf/version.rb +5 -1
- data/lib/chef/provider/package/dpkg.rb +1 -1
- data/lib/chef/provider/package/freebsd/base.rb +2 -1
- data/lib/chef/provider/package/homebrew.rb +107 -43
- data/lib/chef/provider/package/macports.rb +0 -2
- data/lib/chef/provider/package/msu.rb +4 -1
- data/lib/chef/provider/package/pacman.rb +25 -34
- data/lib/chef/provider/package/portage.rb +1 -0
- data/lib/chef/provider/package/powershell.rb +1 -1
- data/lib/chef/provider/package/rubygems.rb +30 -3
- data/lib/chef/provider/package/windows.rb +29 -53
- data/lib/chef/provider/package/windows/msi.rb +2 -2
- data/lib/chef/provider/package/yum.rb +1 -9
- data/lib/chef/provider/package/yum/yum_cache.rb +1 -1
- data/lib/chef/provider/package/zypper.rb +0 -1
- data/lib/chef/provider/powershell_script.rb +5 -11
- data/lib/chef/provider/registry_key.rb +4 -4
- data/lib/chef/provider/remote_directory.rb +5 -5
- data/lib/chef/provider/remote_file/ftp.rb +3 -2
- data/lib/chef/provider/remote_file/local_file.rb +2 -1
- data/lib/chef/provider/remote_file/sftp.rb +3 -2
- data/lib/chef/provider/route.rb +5 -3
- data/lib/chef/provider/ruby_block.rb +1 -1
- data/lib/chef/provider/script.rb +2 -2
- data/lib/chef/provider/service.rb +8 -8
- data/lib/chef/provider/service/aixinit.rb +1 -1
- data/lib/chef/provider/service/arch.rb +1 -1
- data/lib/chef/provider/service/debian.rb +30 -28
- data/lib/chef/provider/service/macosx.rb +16 -10
- data/lib/chef/provider/service/systemd.rb +12 -12
- data/lib/chef/provider/service/upstart.rb +1 -1
- data/lib/chef/provider/service/windows.rb +5 -11
- data/lib/chef/provider/subversion.rb +25 -5
- data/lib/chef/provider/systemd_unit.rb +26 -25
- data/lib/chef/provider/user.rb +6 -6
- data/lib/chef/provider/user/aix.rb +1 -1
- data/lib/chef/provider/user/dscl.rb +6 -6
- data/lib/chef/provider/user/mac.rb +20 -15
- data/lib/chef/provider/whyrun_safe_ruby_block.rb +1 -1
- data/lib/chef/provider/windows_env.rb +3 -3
- data/lib/chef/provider/windows_script.rb +2 -2
- data/lib/chef/provider/windows_task.rb +10 -10
- data/lib/chef/providers.rb +0 -6
- data/lib/chef/recipe.rb +36 -0
- data/lib/chef/resource.rb +44 -57
- data/lib/chef/resource/action_class.rb +24 -22
- data/lib/chef/resource/alternatives.rb +210 -0
- data/lib/chef/resource/apt_package.rb +33 -3
- data/lib/chef/resource/apt_preference.rb +103 -7
- data/lib/chef/resource/apt_repository.rb +357 -18
- data/lib/chef/resource/apt_update.rb +58 -5
- data/lib/chef/resource/archive_file.rb +6 -5
- data/lib/chef/resource/bash.rb +3 -1
- data/lib/chef/resource/batch.rb +1 -1
- data/lib/chef/resource/bff_package.rb +10 -2
- data/lib/chef/resource/breakpoint.rb +1 -2
- data/lib/chef/resource/build_essential.rb +49 -51
- data/lib/chef/resource/cab_package.rb +9 -2
- data/lib/chef/resource/chef_client_cron.rb +228 -0
- data/lib/chef/resource/chef_client_scheduled_task.rb +201 -0
- data/lib/chef/resource/chef_client_systemd_timer.rb +180 -0
- data/lib/chef/resource/chef_gem.rb +15 -18
- data/lib/chef/resource/chef_handler.rb +5 -4
- data/lib/chef/resource/chef_sleep.rb +7 -5
- data/lib/chef/resource/chef_vault_secret.rb +135 -0
- data/lib/chef/resource/chocolatey_config.rb +8 -4
- data/lib/chef/resource/chocolatey_feature.rb +7 -4
- data/lib/chef/resource/chocolatey_package.rb +7 -4
- data/lib/chef/resource/chocolatey_source.rb +7 -4
- data/lib/chef/resource/cookbook_file.rb +4 -3
- data/lib/chef/resource/cron.rb +34 -80
- data/lib/chef/resource/cron_access.rb +10 -6
- data/lib/chef/resource/cron_d.rb +44 -95
- data/lib/chef/resource/csh.rb +3 -1
- data/lib/chef/resource/directory.rb +3 -3
- data/lib/chef/resource/dmg_package.rb +22 -19
- data/lib/chef/resource/dnf_package.rb +3 -4
- data/lib/chef/resource/dpkg_package.rb +3 -2
- data/lib/chef/resource/dsc_resource.rb +6 -4
- data/lib/chef/resource/dsc_script.rb +3 -2
- data/lib/chef/resource/execute.rb +15 -14
- data/lib/chef/resource/file.rb +14 -9
- data/lib/chef/resource/freebsd_package.rb +3 -2
- data/lib/chef/resource/gem_package.rb +19 -11
- data/lib/chef/resource/group.rb +5 -2
- data/lib/chef/resource/helpers/cron_validations.rb +98 -0
- data/lib/chef/resource/homebrew_cask.rb +3 -2
- data/lib/chef/resource/homebrew_package.rb +5 -3
- data/lib/chef/resource/homebrew_tap.rb +3 -2
- data/lib/chef/resource/hostname.rb +26 -20
- data/lib/chef/resource/http_request.rb +1 -2
- data/lib/chef/resource/ifconfig.rb +8 -8
- data/lib/chef/resource/ips_package.rb +11 -3
- data/lib/chef/resource/kernel_module.rb +30 -30
- data/lib/chef/resource/ksh.rb +3 -1
- data/lib/chef/resource/launchd.rb +3 -3
- data/lib/chef/resource/link.rb +5 -27
- data/lib/chef/resource/locale.rb +60 -26
- data/lib/chef/resource/log.rb +13 -2
- data/lib/chef/resource/lwrp_base.rb +1 -1
- data/lib/chef/resource/macos_userdefaults.rb +18 -10
- data/lib/chef/resource/macosx_service.rb +3 -2
- data/lib/chef/resource/macports_package.rb +10 -2
- data/lib/chef/resource/mdadm.rb +63 -3
- data/lib/chef/resource/mount.rb +4 -1
- data/lib/chef/resource/msu_package.rb +19 -2
- data/lib/chef/resource/notify_group.rb +8 -3
- data/lib/chef/resource/ohai.rb +20 -4
- data/lib/chef/resource/ohai_hint.rb +4 -13
- data/lib/chef/resource/openbsd_package.rb +10 -2
- data/lib/chef/resource/openssl_dhparam.rb +11 -2
- data/lib/chef/resource/openssl_ec_private_key.rb +24 -2
- data/lib/chef/resource/openssl_ec_public_key.rb +22 -2
- data/lib/chef/resource/openssl_rsa_private_key.rb +21 -2
- data/lib/chef/resource/openssl_rsa_public_key.rb +23 -2
- data/lib/chef/resource/openssl_x509_certificate.rb +38 -2
- data/lib/chef/resource/openssl_x509_crl.rb +13 -2
- data/lib/chef/resource/openssl_x509_request.rb +38 -2
- data/lib/chef/resource/osx_profile.rb +4 -3
- data/lib/chef/resource/package.rb +3 -2
- data/lib/chef/resource/pacman_package.rb +3 -2
- data/lib/chef/resource/paludis_package.rb +13 -4
- data/lib/chef/resource/perl.rb +3 -1
- data/lib/chef/resource/plist.rb +207 -0
- data/lib/chef/resource/portage_package.rb +14 -4
- data/lib/chef/resource/powershell_package.rb +2 -4
- data/lib/chef/resource/powershell_package_source.rb +4 -2
- data/lib/chef/resource/powershell_script.rb +8 -18
- data/lib/chef/resource/python.rb +3 -1
- data/lib/chef/resource/reboot.rb +1 -2
- data/lib/chef/resource/registry_key.rb +2 -3
- data/lib/chef/resource/remote_directory.rb +3 -1
- data/lib/chef/resource/remote_file.rb +3 -2
- data/lib/chef/resource/rhsm_errata.rb +1 -4
- data/lib/chef/resource/rhsm_errata_level.rb +1 -2
- data/lib/chef/resource/rhsm_register.rb +3 -3
- data/lib/chef/resource/rhsm_repo.rb +4 -3
- data/lib/chef/resource/rhsm_subscription.rb +5 -4
- data/lib/chef/resource/route.rb +6 -2
- data/lib/chef/resource/rpm_package.rb +13 -3
- data/lib/chef/resource/ruby.rb +3 -1
- data/lib/chef/resource/ruby_block.rb +2 -5
- data/lib/chef/resource/scm/_scm.rb +49 -0
- data/lib/chef/resource/{scm.rb → scm/git.rb} +16 -30
- data/lib/chef/resource/{subversion.rb → scm/subversion.rb} +10 -7
- data/lib/chef/resource/script.rb +7 -4
- data/lib/chef/resource/service.rb +7 -8
- data/lib/chef/resource/smartos_package.rb +10 -2
- data/lib/chef/resource/snap_package.rb +4 -2
- data/lib/chef/resource/solaris_package.rb +10 -2
- data/lib/chef/resource/ssh_known_hosts_entry.rb +6 -3
- data/lib/chef/resource/sudo.rb +11 -11
- 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 -2
- data/lib/chef/resource/support/ulimit.erb +41 -0
- data/lib/chef/resource/swap_file.rb +7 -5
- data/lib/chef/resource/sysctl.rb +63 -4
- data/lib/chef/resource/systemd_unit.rb +6 -4
- data/lib/chef/resource/template.rb +0 -1
- data/lib/chef/resource/timezone.rb +8 -19
- data/lib/chef/resource/user.rb +3 -5
- data/lib/chef/resource/user/aix_user.rb +0 -2
- data/lib/chef/resource/user/dscl_user.rb +1 -1
- data/lib/chef/resource/user/linux_user.rb +0 -2
- data/lib/chef/resource/user/mac_user.rb +1 -1
- data/lib/chef/resource/user/pw_user.rb +0 -2
- data/lib/chef/resource/user/solaris_user.rb +0 -2
- data/lib/chef/resource/user/windows_user.rb +0 -2
- data/lib/chef/resource/user_ulimit.rb +116 -0
- data/lib/chef/resource/whyrun_safe_ruby_block.rb +1 -0
- data/lib/chef/resource/windows_ad_join.rb +20 -7
- data/lib/chef/resource/windows_auto_run.rb +2 -3
- data/lib/chef/resource/windows_certificate.rb +3 -3
- data/lib/chef/resource/windows_dfs_folder.rb +1 -2
- data/lib/chef/resource/windows_dfs_namespace.rb +1 -2
- data/lib/chef/resource/windows_dfs_server.rb +2 -3
- 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 +12 -4
- data/lib/chef/resource/windows_feature.rb +59 -4
- data/lib/chef/resource/windows_feature_dism.rb +24 -24
- data/lib/chef/resource/windows_feature_powershell.rb +44 -78
- data/lib/chef/resource/windows_firewall_rule.rb +121 -8
- data/lib/chef/resource/windows_font.rb +10 -2
- data/lib/chef/resource/windows_package.rb +76 -7
- data/lib/chef/resource/windows_pagefile.rb +31 -4
- data/lib/chef/resource/windows_path.rb +18 -2
- data/lib/chef/resource/windows_printer.rb +26 -7
- data/lib/chef/resource/windows_printer_port.rb +29 -2
- data/lib/chef/resource/windows_script.rb +3 -4
- data/lib/chef/resource/windows_security_policy.rb +119 -0
- data/lib/chef/resource/windows_service.rb +46 -32
- data/lib/chef/resource/windows_share.rb +22 -6
- data/lib/chef/resource/windows_shortcut.rb +13 -3
- data/lib/chef/resource/windows_task.rb +129 -16
- data/lib/chef/resource/windows_uac.rb +20 -2
- data/lib/chef/resource/windows_user_privilege.rb +199 -0
- data/lib/chef/resource/windows_workgroup.rb +19 -4
- data/lib/chef/resource/yum_package.rb +91 -7
- data/lib/chef/resource/yum_repository.rb +30 -12
- data/lib/chef/resource/zypper_package.rb +32 -5
- data/lib/chef/resource/zypper_repository.rb +19 -6
- data/lib/chef/resource_builder.rb +8 -0
- data/lib/chef/resource_inspector.rb +3 -2
- data/lib/chef/resource_resolver.rb +7 -14
- data/lib/chef/resources.rb +11 -3
- data/lib/chef/run_context/cookbook_compiler.rb +29 -5
- data/lib/chef/scan_access_control.rb +1 -1
- data/lib/chef/shell.rb +22 -0
- data/lib/chef/shell/ext.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api.rb +2 -2
- data/lib/chef/win32/api/error.rb +3 -1
- data/lib/chef/win32/api/file.rb +1 -1
- data/lib/chef/win32/api/net.rb +1 -0
- data/lib/chef/win32/api/security.rb +6 -0
- data/lib/chef/win32/file.rb +1 -9
- data/lib/chef/win32/mutex.rb +1 -1
- data/lib/chef/win32/net.rb +1 -0
- data/lib/chef/win32/security.rb +40 -2
- data/lib/chef/win32/security/sid.rb +4 -4
- data/spec/functional/assets/inittest +8 -7
- data/spec/functional/knife/ssh_spec.rb +23 -19
- data/spec/functional/resource/cron_spec.rb +10 -29
- data/spec/functional/resource/dnf_package_spec.rb +441 -156
- data/spec/functional/resource/git_spec.rb +184 -134
- data/spec/functional/resource/insserv_spec.rb +1 -1
- data/spec/functional/resource/launchd_spec.rb +232 -0
- data/spec/functional/resource/link_spec.rb +3 -3
- data/spec/functional/resource/locale_spec.rb +13 -2
- data/spec/functional/resource/msu_package_spec.rb +5 -2
- data/spec/functional/resource/powershell_script_spec.rb +7 -68
- data/spec/functional/resource/remote_file_spec.rb +1 -1
- data/spec/functional/resource/windows_security_policy_spec.rb +90 -0
- data/spec/functional/resource/windows_task_spec.rb +4 -4
- data/spec/functional/resource/windows_user_privilege_spec.rb +193 -0
- data/spec/functional/run_lock_spec.rb +1 -1
- data/spec/functional/shell_spec.rb +1 -1
- data/spec/functional/util/powershell/cmdlet_spec.rb +1 -1
- data/spec/functional/version_spec.rb +1 -1
- data/spec/functional/win32/registry_spec.rb +0 -6
- data/spec/functional/win32/security_spec.rb +22 -0
- data/spec/integration/client/client_spec.rb +123 -2
- data/spec/integration/knife/cookbook_show_spec.rb +28 -26
- data/spec/integration/knife/data_bag_show_spec.rb +1 -1
- data/spec/integration/knife/raw_spec.rb +34 -6
- data/spec/integration/knife/redirection_spec.rb +2 -2
- data/spec/integration/knife/show_spec.rb +32 -3
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +3 -3
- data/spec/integration/recipes/noop_resource_spec.rb +1 -1
- data/spec/integration/recipes/notifies_spec.rb +49 -20
- data/spec/integration/recipes/notifying_block_spec.rb +8 -5
- data/spec/integration/recipes/provider_choice.rb +2 -0
- data/spec/integration/recipes/recipe_dsl_spec.rb +45 -143
- data/spec/integration/recipes/resource_action_spec.rb +16 -11
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +1 -1
- data/spec/integration/recipes/resource_load_spec.rb +133 -12
- data/spec/integration/recipes/use_partial_spec.rb +112 -0
- data/spec/integration/solo/solo_spec.rb +3 -3
- data/spec/spec_helper.rb +18 -3
- data/spec/support/chef_helpers.rb +2 -2
- data/spec/support/lib/chef/resource/zen_follower.rb +2 -0
- data/spec/support/platform_helpers.rb +2 -20
- data/spec/support/recipe_dsl_helper.rb +83 -0
- data/spec/support/shared/functional/http.rb +2 -2
- data/spec/support/shared/functional/windows_script.rb +3 -16
- data/spec/support/shared/integration/knife_support.rb +9 -6
- data/spec/support/shared/unit/mock_shellout.rb +1 -1
- data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +4 -4
- data/spec/unit/application/apply_spec.rb +3 -0
- data/spec/unit/application/client_spec.rb +5 -1
- data/spec/unit/application_spec.rb +1 -2
- data/spec/unit/client_spec.rb +7 -5
- data/spec/unit/cookbook/gem_installer_spec.rb +2 -2
- data/spec/unit/cookbook/metadata_spec.rb +38 -19
- data/spec/unit/data_collector_spec.rb +39 -18
- data/spec/unit/file_access_control_spec.rb +1 -1
- data/spec/unit/json_compat_spec.rb +1 -1
- data/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb +15 -15
- data/spec/unit/knife/bootstrap/client_builder_spec.rb +9 -9
- data/spec/unit/knife/bootstrap_spec.rb +20 -38
- data/spec/unit/knife/cookbook_show_spec.rb +1 -0
- data/spec/unit/knife/core/bootstrap_context_spec.rb +23 -43
- data/spec/unit/knife/core/ui_spec.rb +16 -0
- data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +9 -63
- data/spec/unit/knife/data_bag_secret_options_spec.rb +22 -14
- data/spec/unit/knife/ssh_spec.rb +8 -111
- data/spec/unit/knife/status_spec.rb +1 -1
- data/spec/unit/knife_spec.rb +18 -0
- data/spec/unit/mixin/openssl_helper_spec.rb +4 -4
- data/spec/unit/mixin/powershell_exec_spec.rb +10 -0
- data/spec/unit/mixin/shell_out_spec.rb +25 -31
- data/spec/unit/node/attribute_spec.rb +3 -3
- data/spec/unit/node_spec.rb +24 -0
- data/spec/unit/platform/query_helpers_spec.rb +0 -143
- data/spec/unit/property/state_spec.rb +12 -7
- data/spec/unit/property/validation_spec.rb +25 -1
- data/spec/unit/property_spec.rb +12 -9
- data/spec/unit/provider/apt_preference_spec.rb +14 -10
- data/spec/unit/provider/apt_repository_spec.rb +34 -36
- data/spec/unit/provider/apt_update_spec.rb +12 -11
- data/spec/unit/provider/cookbook_file_spec.rb +4 -4
- data/spec/unit/provider/cron_spec.rb +2 -2
- data/spec/unit/provider/directory_spec.rb +4 -15
- data/spec/unit/provider/file_spec.rb +4 -4
- data/spec/unit/provider/git_spec.rb +41 -1
- data/spec/unit/provider/group/groupadd_spec.rb +1 -1
- data/spec/unit/provider/launchd_spec.rb +8 -50
- data/spec/unit/provider/link_spec.rb +0 -1
- data/spec/unit/provider/log_spec.rb +3 -3
- data/spec/unit/provider/mdadm_spec.rb +3 -3
- data/spec/unit/provider/package/dnf/python_helper_spec.rb +1 -1
- data/spec/unit/provider/package/homebrew_spec.rb +280 -174
- data/spec/unit/provider/package/pacman_spec.rb +65 -147
- data/spec/unit/provider/package/portage_spec.rb +2 -2
- data/spec/unit/provider/package/powershell_spec.rb +3 -2
- data/spec/unit/provider/package/rubygems_spec.rb +211 -26
- data/spec/unit/provider/package/windows/exe_spec.rb +1 -1
- data/spec/unit/provider/powershell_script_spec.rb +21 -61
- data/spec/unit/provider/remote_file_spec.rb +3 -4
- data/spec/unit/provider/service/debian_service_spec.rb +34 -13
- data/spec/unit/provider/service/macosx_spec.rb +210 -214
- data/spec/unit/provider/service/systemd_service_spec.rb +23 -23
- data/spec/unit/provider/subversion_spec.rb +4 -2
- data/spec/unit/provider/template_spec.rb +3 -4
- data/spec/unit/provider/zypper_repository_spec.rb +17 -17
- data/spec/unit/provider_resolver_spec.rb +4 -4
- data/spec/unit/recipe_spec.rb +68 -0
- data/spec/unit/resource/alternatives_spec.rb +120 -0
- data/spec/unit/resource/apt_preference_spec.rb +0 -18
- data/spec/unit/resource/apt_repository_spec.rb +0 -18
- data/spec/unit/resource/apt_update_spec.rb +0 -18
- data/spec/unit/resource/chef_client_cron_spec.rb +119 -0
- data/spec/unit/resource/chef_client_scheduled_task_spec.rb +102 -0
- data/spec/unit/resource/chef_client_systemd_timer_spec.rb +70 -0
- data/spec/unit/resource/chef_vault_secret_spec.rb +40 -0
- data/spec/unit/resource/chocolatey_source_spec.rb +2 -1
- data/spec/unit/resource/cron_d_spec.rb +6 -48
- data/spec/unit/resource/cron_spec.rb +4 -10
- data/spec/unit/resource/gem_package_spec.rb +3 -3
- data/spec/unit/resource/helpers/cron_validations_spec.rb +77 -0
- data/spec/unit/resource/link_spec.rb +0 -4
- data/spec/unit/resource/locale_spec.rb +0 -34
- data/spec/unit/resource/msu_package_spec.rb +4 -0
- data/spec/unit/resource/ohai_spec.rb +56 -2
- data/spec/unit/resource/plist_spec.rb +130 -0
- data/spec/unit/resource/powershell_script_spec.rb +0 -5
- data/spec/unit/resource/{git_spec.rb → scm/git_spec.rb} +50 -2
- data/spec/unit/resource/{scm_spec.rb → scm/scm.rb} +1 -52
- data/spec/unit/resource/{subversion_spec.rb → scm/subversion_spec.rb} +2 -3
- data/spec/unit/resource/service_spec.rb +4 -0
- data/spec/unit/resource/user_spec.rb +2 -2
- data/spec/unit/resource/user_ulimit_spec.rb +53 -0
- data/spec/unit/resource/windows_feature_dism_spec.rb +2 -17
- data/spec/unit/resource/windows_feature_powershell_spec.rb +2 -17
- data/spec/unit/resource/windows_firewall_rule_spec.rb +88 -41
- data/spec/unit/resource/windows_package_spec.rb +14 -0
- data/spec/unit/resource/windows_service_spec.rb +9 -0
- data/spec/unit/resource_reporter_spec.rb +2 -6
- data/spec/unit/resource_spec.rb +10 -3
- data/spec/unit/run_lock_spec.rb +1 -1
- data/spec/unit/scan_access_control_spec.rb +1 -1
- data/spec/unit/search/query_spec.rb +1 -1
- data/spec/unit/win32/registry_spec.rb +1 -1
- data/tasks/rspec.rb +6 -14
- metadata +92 -37
- data/lib/chef/dsl/core.rb +0 -52
- data/lib/chef/knife/cookbook_site_share.rb +0 -41
- data/lib/chef/knife/cookbook_site_unshare.rb +0 -41
- data/lib/chef/provider/apt_preference.rb +0 -93
- data/lib/chef/provider/apt_repository.rb +0 -358
- data/lib/chef/provider/apt_update.rb +0 -79
- data/lib/chef/provider/log.rb +0 -43
- data/lib/chef/provider/mdadm.rb +0 -85
- data/lib/chef/provider/ohai.rb +0 -45
- data/lib/chef/resource/git.rb +0 -37
- data/spec/unit/provider/ohai_spec.rb +0 -84
@@ -21,7 +21,6 @@ require_relative "../resource"
|
|
21
21
|
class Chef
|
22
22
|
class Resource
|
23
23
|
class WindowsDnsRecord < Chef::Resource
|
24
|
-
resource_name :windows_dns_record
|
25
24
|
provides :windows_dns_record
|
26
25
|
|
27
26
|
description "The windows_dns_record resource creates a DNS record for the given domain."
|
@@ -21,7 +21,6 @@ require_relative "../resource"
|
|
21
21
|
class Chef
|
22
22
|
class Resource
|
23
23
|
class WindowsDnsZone < Chef::Resource
|
24
|
-
resource_name :windows_dns_zone
|
25
24
|
provides :windows_dns_zone
|
26
25
|
|
27
26
|
description "The windows_dns_zone resource creates an Active Directory Integrated DNS Zone on the local server."
|
@@ -22,22 +22,30 @@ require_relative "../resource"
|
|
22
22
|
class Chef
|
23
23
|
class Resource
|
24
24
|
class WindowsEnv < Chef::Resource
|
25
|
-
resource_name :windows_env
|
26
25
|
provides :windows_env
|
27
26
|
provides :env # backwards compat with the pre-Chef 14 resource name
|
28
27
|
|
29
|
-
description "Use the windows_env resource to manage environment keys in Microsoft Windows. After an environment key is set, Microsoft Windows must be restarted before the environment key will be available to the Task Scheduler."
|
28
|
+
description "Use the **windows_env** resource to manage environment keys in Microsoft Windows. After an environment key is set, Microsoft Windows must be restarted before the environment key will be available to the Task Scheduler."
|
29
|
+
examples <<~DOC
|
30
|
+
**Set an environment variable**:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
windows_env 'ComSpec' do
|
34
|
+
value 'C:\\Windows\\system32\\cmd.exe'
|
35
|
+
end
|
36
|
+
```
|
37
|
+
DOC
|
30
38
|
|
31
39
|
default_action :create
|
32
40
|
allowed_actions :create, :delete, :modify
|
33
41
|
|
34
42
|
property :key_name, String,
|
35
43
|
description: "An optional property to set the name of the key that is to be created, deleted, or modified if it differs from the resource block's name.",
|
36
|
-
|
44
|
+
name_property: true
|
37
45
|
|
38
46
|
property :value, String,
|
39
47
|
description: "The value of the environmental variable to set.",
|
40
|
-
required:
|
48
|
+
required: %i{create modify}
|
41
49
|
|
42
50
|
property :delim, [ String, nil, false ],
|
43
51
|
description: "The delimiter that is used to separate multiple values for a single key.",
|
@@ -21,11 +21,65 @@ require_relative "../resource"
|
|
21
21
|
class Chef
|
22
22
|
class Resource
|
23
23
|
class WindowsFeature < Chef::Resource
|
24
|
-
resource_name :windows_feature
|
25
24
|
provides(:windows_feature) { true }
|
26
25
|
|
27
|
-
description "Use the windows_feature resource to add, remove or entirely delete Windows features and roles. This resource calls the 'windows_feature_dism' or 'windows_feature_powershell' resources depending on the specified installation method, and defaults to DISM, which is available on both Workstation and Server editions of Windows."
|
26
|
+
description "Use the **windows_feature** resource to add, remove or entirely delete Windows features and roles. This resource calls the 'windows_feature_dism' or 'windows_feature_powershell' resources depending on the specified installation method, and defaults to DISM, which is available on both Workstation and Server editions of Windows."
|
28
27
|
introduced "14.0"
|
28
|
+
examples <<~DOC
|
29
|
+
**Install the DHCP Server feature**:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
windows_feature 'DHCPServer' do
|
33
|
+
action :install
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
**Install the .Net 3.5.1 feature using repository files on DVD**:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
windows_feature "NetFx3" do
|
41
|
+
action :install
|
42
|
+
source 'd:\\sources\\sxs'
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
**Remove Telnet Server and Client features**:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
windows_feature %w(TelnetServer TelnetClient) do
|
50
|
+
action :remove
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
**Add the SMTP Server feature using the PowerShell provider**:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
windows_feature 'smtp-server' do
|
58
|
+
action :install
|
59
|
+
all true
|
60
|
+
install_method :windows_feature_powershell
|
61
|
+
end
|
62
|
+
```
|
63
|
+
|
64
|
+
**Install multiple features using one resource with the PowerShell provider**:
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
windows_feature %w(Web-Asp-Net45 Web-Net-Ext45) do
|
68
|
+
action :install
|
69
|
+
install_method :windows_feature_powershell
|
70
|
+
end
|
71
|
+
```
|
72
|
+
|
73
|
+
**Install the Network Policy and Access Service feature, including the management tools**:
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
windows_feature 'NPAS' do
|
77
|
+
action :install
|
78
|
+
management_tools true
|
79
|
+
install_method :windows_feature_powershell
|
80
|
+
end
|
81
|
+
```
|
82
|
+
DOC
|
29
83
|
|
30
84
|
property :feature_name, [Array, String],
|
31
85
|
description: "The name of the feature(s) or role(s) to install if they differ from the resource block's name. The same feature may have different names depending on the underlying installation method being used (ie DHCPServer vs DHCP; DNS-Server-Full-Role vs DNS).",
|
@@ -43,13 +97,14 @@ class Chef
|
|
43
97
|
default: false
|
44
98
|
|
45
99
|
property :install_method, Symbol,
|
46
|
-
description: "The underlying installation method to use for feature installation. Specify
|
100
|
+
description: "The underlying installation method to use for feature installation. Specify `:windows_feature_dism` for DISM or `:windows_feature_powershell` for PowerShell.",
|
47
101
|
equal_to: %i{windows_feature_dism windows_feature_powershell windows_feature_servermanagercmd},
|
48
102
|
default: :windows_feature_dism
|
49
103
|
|
50
104
|
property :timeout, Integer,
|
51
105
|
description: "Specifies a timeout (in seconds) for the feature installation.",
|
52
|
-
default: 600
|
106
|
+
default: 600,
|
107
|
+
desired_state: false
|
53
108
|
|
54
109
|
action :install do
|
55
110
|
description "Install a Windows role/feature"
|
@@ -22,11 +22,23 @@ require_relative "../platform/query_helpers"
|
|
22
22
|
class Chef
|
23
23
|
class Resource
|
24
24
|
class WindowsFeatureDism < Chef::Resource
|
25
|
-
resource_name :windows_feature_dism
|
26
25
|
provides(:windows_feature_dism) { true }
|
27
26
|
|
28
|
-
description "Use the windows_feature_dism resource to add, remove, or entirely delete Windows features and roles using DISM."
|
27
|
+
description "Use the **windows_feature_dism** resource to add, remove, or entirely delete Windows features and roles using DISM."
|
29
28
|
introduced "14.0"
|
29
|
+
examples <<~DOC
|
30
|
+
**Installing the TelnetClient service**:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
windows_feature_dism "TelnetClient"
|
34
|
+
```
|
35
|
+
|
36
|
+
**Installing two features by using an array**:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
windows_feature_dism %w(TelnetClient TFTP)
|
40
|
+
```
|
41
|
+
DOC
|
30
42
|
|
31
43
|
property :feature_name, [Array, String],
|
32
44
|
description: "The name of the feature(s) or role(s) to install if they differ from the resource name.",
|
@@ -37,19 +49,18 @@ class Chef
|
|
37
49
|
description: "Specify a local repository for the feature install."
|
38
50
|
|
39
51
|
property :all, [TrueClass, FalseClass],
|
40
|
-
description: "Install all sub-features. When set to
|
52
|
+
description: "Install all sub-features. When set to `true`, this is the equivalent of specifying the `/All` switch to `dism.exe`",
|
41
53
|
default: false
|
42
54
|
|
43
55
|
property :timeout, Integer,
|
44
56
|
description: "Specifies a timeout (in seconds) for the feature installation.",
|
45
|
-
default: 600
|
57
|
+
default: 600,
|
58
|
+
desired_state: false
|
46
59
|
|
47
|
-
# @return [Array] lowercase the array
|
60
|
+
# @return [Array] lowercase the array
|
48
61
|
def to_formatted_array(x)
|
49
62
|
x = x.split(/\s*,\s*/) if x.is_a?(String) # split multiple forms of a comma separated list
|
50
|
-
|
51
|
-
# feature installs on windows < 2012 are case sensitive so only downcase when on 2012+
|
52
|
-
older_than_win_2012_or_8? ? x : x.map(&:downcase)
|
63
|
+
x.map(&:downcase)
|
53
64
|
end
|
54
65
|
|
55
66
|
action :install do
|
@@ -98,8 +109,6 @@ class Chef
|
|
98
109
|
action :delete do
|
99
110
|
description "Remove a Windows role/feature from the image using DISM"
|
100
111
|
|
101
|
-
raise_if_delete_unsupported
|
102
|
-
|
103
112
|
reload_cached_dism_data unless node["dism_features_cache"]
|
104
113
|
|
105
114
|
fail_if_unavailable # fail if the features don't exist
|
@@ -193,27 +202,18 @@ class Chef
|
|
193
202
|
logger.trace("The cache contains\n#{node["dism_features_cache"]}")
|
194
203
|
end
|
195
204
|
|
196
|
-
# parse the feature string and add the values to the appropriate array
|
197
|
-
#
|
198
|
-
# strips trailing whitespace characters then split on n number of spaces
|
199
|
-
# + | + n number of spaces
|
205
|
+
# parse the feature string and add the values to the appropriate array in the strips
|
206
|
+
# trailing whitespace characters then split on n number of spaces + | + n number of spaces
|
200
207
|
# @return [void]
|
201
208
|
def add_to_feature_mash(feature_type, feature_string)
|
202
209
|
feature_details = feature_string.strip.split(/\s+[|]\s+/).first
|
203
210
|
|
204
|
-
# dism
|
205
|
-
#
|
206
|
-
|
207
|
-
feature_details.downcase! unless older_than_win_2012_or_8?
|
211
|
+
# dism isn't case sensitive so it's best to compare lowercase lists so the
|
212
|
+
# user input doesn't need to be case sensitive
|
213
|
+
feature_details.downcase!
|
208
214
|
node.override["dism_features_cache"][feature_type] << feature_details
|
209
215
|
end
|
210
216
|
|
211
|
-
# Fail unless we're on windows 8+ / 2012+ where deleting a feature is supported
|
212
|
-
# @return [void]
|
213
|
-
def raise_if_delete_unsupported
|
214
|
-
raise Chef::Exceptions::UnsupportedAction, "#{self} :delete action not supported on Windows releases before Windows 8/2012. Cannot continue!" if older_than_win_2012_or_8?
|
215
|
-
end
|
216
|
-
|
217
217
|
def required_parent_feature?(error_message)
|
218
218
|
error_message.include?("Error: 50") && error_message.include?("required parent feature")
|
219
219
|
end
|
@@ -16,7 +16,6 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require_relative "../mixin/powershell_out"
|
20
19
|
require_relative "../json_compat"
|
21
20
|
require_relative "../resource"
|
22
21
|
require_relative "../platform/query_helpers"
|
@@ -24,11 +23,37 @@ require_relative "../platform/query_helpers"
|
|
24
23
|
class Chef
|
25
24
|
class Resource
|
26
25
|
class WindowsFeaturePowershell < Chef::Resource
|
27
|
-
resource_name :windows_feature_powershell
|
28
26
|
provides(:windows_feature_powershell) { true }
|
29
27
|
|
30
|
-
description "Use the windows_feature_powershell resource to add, remove, or entirely delete Windows features and roles using PowerShell. This resource offers significant speed benefits over the windows_feature_dism resource, but requires installation of the Remote Server Administration Tools on non-server releases of Windows."
|
28
|
+
description "Use the **windows_feature_powershell** resource to add, remove, or entirely delete Windows features and roles using PowerShell. This resource offers significant speed benefits over the windows_feature_dism resource, but requires installation of the Remote Server Administration Tools on non-server releases of Windows."
|
31
29
|
introduced "14.0"
|
30
|
+
examples <<~DOC
|
31
|
+
**Add the SMTP Server feature**:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
windows_feature_powershell "smtp-server" do
|
35
|
+
action :install
|
36
|
+
all true
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
**Install multiple features using one resource**:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
windows_feature_powershell ['Web-Asp-Net45', 'Web-Net-Ext45'] do
|
44
|
+
action :install
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
48
|
+
**Install the Network Policy and Access Service feature**:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
windows_feature_powershell 'NPAS' do
|
52
|
+
action :install
|
53
|
+
management_tools true
|
54
|
+
end
|
55
|
+
```
|
56
|
+
DOC
|
32
57
|
|
33
58
|
property :feature_name, [Array, String],
|
34
59
|
description: "The name of the feature(s) or role(s) to install if they differ from the resource block's name.",
|
@@ -39,31 +64,28 @@ class Chef
|
|
39
64
|
description: "Specify a local repository for the feature install."
|
40
65
|
|
41
66
|
property :all, [TrueClass, FalseClass],
|
42
|
-
description: "Install all subfeatures. When set to
|
67
|
+
description: "Install all subfeatures. When set to `true`, this is the equivalent of specifying the `-InstallAllSubFeatures` switch with `Add-WindowsFeature`.",
|
43
68
|
default: false
|
44
69
|
|
45
70
|
property :timeout, Integer,
|
46
71
|
description: "Specifies a timeout (in seconds) for the feature installation.",
|
47
|
-
default: 600
|
72
|
+
default: 600,
|
73
|
+
desired_state: false
|
48
74
|
|
49
75
|
property :management_tools, [TrueClass, FalseClass],
|
50
76
|
description: "Install all applicable management tools for the roles, role services, or features.",
|
51
77
|
default: false
|
52
78
|
|
53
|
-
# Converts strings of features into an Array. Array objects are lowercased
|
79
|
+
# Converts strings of features into an Array. Array objects are lowercased
|
54
80
|
# @return [Array] array of features
|
55
81
|
def to_formatted_array(x)
|
56
82
|
x = x.split(/\s*,\s*/) if x.is_a?(String) # split multiple forms of a comma separated list
|
57
83
|
|
58
|
-
#
|
59
|
-
|
84
|
+
# features aren't case sensitive so let's compare in lowercase
|
85
|
+
x.map(&:downcase)
|
60
86
|
end
|
61
87
|
|
62
|
-
include Chef::Mixin::PowershellOut
|
63
|
-
|
64
88
|
action :install do
|
65
|
-
raise_on_old_powershell
|
66
|
-
|
67
89
|
reload_cached_powershell_data unless node["powershell_features_cache"]
|
68
90
|
fail_if_unavailable # fail if the features don't exist
|
69
91
|
fail_if_removed # fail if the features are in removed state
|
@@ -71,14 +93,10 @@ class Chef
|
|
71
93
|
Chef::Log.debug("Windows features needing installation: #{features_to_install.empty? ? "none" : features_to_install.join(",")}")
|
72
94
|
unless features_to_install.empty?
|
73
95
|
converge_by("install Windows feature#{"s" if features_to_install.count > 1} #{features_to_install.join(",")}") do
|
74
|
-
install_command = "
|
75
|
-
install_command << " -IncludeAllSubFeature"
|
76
|
-
|
77
|
-
|
78
|
-
else
|
79
|
-
install_command << " -Source \"#{new_resource.source}\"" if new_resource.source
|
80
|
-
install_command << " -IncludeManagementTools" if new_resource.management_tools
|
81
|
-
end
|
96
|
+
install_command = "Install-WindowsFeature #{features_to_install.join(",")}"
|
97
|
+
install_command << " -IncludeAllSubFeature" if new_resource.all
|
98
|
+
install_command << " -Source \"#{new_resource.source}\"" if new_resource.source
|
99
|
+
install_command << " -IncludeManagementTools" if new_resource.management_tools
|
82
100
|
|
83
101
|
cmd = powershell_out!(install_command, timeout: new_resource.timeout)
|
84
102
|
Chef::Log.info(cmd.stdout)
|
@@ -89,15 +107,13 @@ class Chef
|
|
89
107
|
end
|
90
108
|
|
91
109
|
action :remove do
|
92
|
-
raise_on_old_powershell
|
93
|
-
|
94
110
|
reload_cached_powershell_data unless node["powershell_features_cache"]
|
95
111
|
|
96
112
|
Chef::Log.debug("Windows features needing removal: #{features_to_remove.empty? ? "none" : features_to_remove.join(",")}")
|
97
113
|
|
98
114
|
unless features_to_remove.empty?
|
99
115
|
converge_by("remove Windows feature#{"s" if features_to_remove.count > 1} #{features_to_remove.join(",")}") do
|
100
|
-
cmd = powershell_out!("
|
116
|
+
cmd = powershell_out!("Uninstall-WindowsFeature #{features_to_remove.join(",")}", timeout: new_resource.timeout)
|
101
117
|
Chef::Log.info(cmd.stdout)
|
102
118
|
|
103
119
|
reload_cached_powershell_data # Reload cached powershell feature state
|
@@ -106,9 +122,6 @@ class Chef
|
|
106
122
|
end
|
107
123
|
|
108
124
|
action :delete do
|
109
|
-
raise_on_old_powershell
|
110
|
-
raise_if_delete_unsupported
|
111
|
-
|
112
125
|
reload_cached_powershell_data unless node["powershell_features_cache"]
|
113
126
|
|
114
127
|
fail_if_unavailable # fail if the features don't exist
|
@@ -126,41 +139,6 @@ class Chef
|
|
126
139
|
end
|
127
140
|
|
128
141
|
action_class do
|
129
|
-
# shellout to determine the actively installed version of powershell
|
130
|
-
# we have this same data in ohai, but it doesn't get updated if powershell is installed mid run
|
131
|
-
# @return [Integer] the powershell version or 0 for nothing
|
132
|
-
def powershell_version
|
133
|
-
cmd = powershell_out("$PSVersionTable.psversion.major")
|
134
|
-
return 1 if cmd.stdout.empty? # PowerShell 1.0 doesn't have a $PSVersionTable
|
135
|
-
|
136
|
-
Regexp.last_match(1).to_i if cmd.stdout =~ /^(\d+)/
|
137
|
-
rescue Errno::ENOENT
|
138
|
-
0 # zero as in nothing is installed
|
139
|
-
end
|
140
|
-
|
141
|
-
# raise if we're running powershell less than 3.0 since we need convertto-json
|
142
|
-
# check the powershell version via ohai data and if we're < 3.0 also shellout to make sure as
|
143
|
-
# a newer version could be installed post ohai run. Yes we're double checking. It's fine.
|
144
|
-
# @todo this can go away when we fully remove support for Windows 2008 R2
|
145
|
-
# @raise [RuntimeError] Raise if powershell is < 3.0
|
146
|
-
def raise_on_old_powershell
|
147
|
-
# be super defensive about the powershell lang plugin not being there
|
148
|
-
return if node["languages"] && node["languages"]["powershell"] && node["languages"]["powershell"]["version"].to_i >= 3
|
149
|
-
raise "The windows_feature_powershell resource requires PowerShell 3.0 or later. Please install PowerShell 3.0+ before running this resource." if powershell_version < 3
|
150
|
-
end
|
151
|
-
|
152
|
-
# The appropriate cmdlet to install a windows feature based on windows release
|
153
|
-
# @return [String]
|
154
|
-
def install_feature_cmdlet
|
155
|
-
older_than_win_2012_or_8? ? "Add-WindowsFeature" : "Install-WindowsFeature"
|
156
|
-
end
|
157
|
-
|
158
|
-
# The appropriate cmdlet to remove a windows feature based on windows release
|
159
|
-
# @return [String]
|
160
|
-
def remove_feature_cmdlet
|
161
|
-
older_than_win_2012_or_8? ? "Remove-WindowsFeature" : "Uninstall-WindowsFeature"
|
162
|
-
end
|
163
|
-
|
164
142
|
# @return [Array] features the user has requested to install which need installation
|
165
143
|
def features_to_install
|
166
144
|
# the intersection of the features to install & disabled features are what needs installing
|
@@ -224,13 +202,8 @@ class Chef
|
|
224
202
|
|
225
203
|
# fetch the list of available feature names and state in JSON and parse the JSON
|
226
204
|
def parsed_feature_list
|
227
|
-
# Grab raw feature information from
|
228
|
-
|
229
|
-
raw_list_of_features = if older_than_win_2012_or_8? # make the older format look like the new format, warts and all
|
230
|
-
powershell_out!('Get-WindowsFeature | Select-Object -Property Name, @{Name="InstallState"; Expression = {If ($_.Installed) { 1 } Else { 0 }}} | ConvertTo-Json -Compress', timeout: new_resource.timeout).stdout
|
231
|
-
else
|
232
|
-
powershell_out!("Get-WindowsFeature | Select-Object -Property Name,InstallState | ConvertTo-Json -Compress", timeout: new_resource.timeout).stdout
|
233
|
-
end
|
205
|
+
# Grab raw feature information from WindowsFeature
|
206
|
+
raw_list_of_features = powershell_out!("Get-WindowsFeature | Select-Object -Property Name,InstallState | ConvertTo-Json -Compress", timeout: new_resource.timeout).stdout
|
234
207
|
|
235
208
|
Chef::JSONCompat.from_json(raw_list_of_features)
|
236
209
|
end
|
@@ -238,26 +211,19 @@ class Chef
|
|
238
211
|
# add the features values to the appropriate array
|
239
212
|
# @return [void]
|
240
213
|
def add_to_feature_mash(feature_type, feature_details)
|
241
|
-
# add the lowercase feature name to the mash
|
242
|
-
node.override["powershell_features_cache"][feature_type] <<
|
214
|
+
# add the lowercase feature name to the mash so we can compare it lowercase later
|
215
|
+
node.override["powershell_features_cache"][feature_type] << feature_details.downcase
|
243
216
|
end
|
244
217
|
|
245
218
|
# Fail if any of the packages are in a removed state
|
246
219
|
# @return [void]
|
247
220
|
def fail_if_removed
|
248
221
|
return if new_resource.source # if someone provides a source then all is well
|
222
|
+
return if registry_key_exists?('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Servicing') && registry_value_exists?('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Servicing', name: "LocalSourcePath") # if source is defined in the registry, still fine
|
249
223
|
|
250
|
-
if node["platform_version"].to_f > 6.2 # 2012R2 or later
|
251
|
-
return if registry_key_exists?('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Servicing') && registry_value_exists?('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Servicing', name: "LocalSourcePath") # if source is defined in the registry, still fine
|
252
|
-
end
|
253
224
|
removed = new_resource.feature_name & node["powershell_features_cache"]["removed"]
|
254
225
|
raise "The Windows feature#{"s" if removed.count > 1} #{removed.join(",")} #{removed.count > 1 ? "are" : "is"} removed from the host and cannot be installed." unless removed.empty?
|
255
226
|
end
|
256
|
-
|
257
|
-
# Fail unless we're on windows 8+ / 2012+ where deleting a feature is supported
|
258
|
-
def raise_if_delete_unsupported
|
259
|
-
raise Chef::Exceptions::UnsupportedAction, "#{self} :delete action not supported on Windows releases before Windows 8/2012. Cannot continue!" if older_than_win_2012_or_8?
|
260
|
-
end
|
261
227
|
end
|
262
228
|
end
|
263
229
|
end
|
@@ -24,19 +24,71 @@ require_relative "../json_compat"
|
|
24
24
|
class Chef
|
25
25
|
class Resource
|
26
26
|
class WindowsFirewallRule < Chef::Resource
|
27
|
-
|
27
|
+
provides :windows_firewall_rule
|
28
28
|
|
29
|
-
description "Use the windows_firewall_rule resource to create, change or remove
|
29
|
+
description "Use the **windows_firewall_rule** resource to create, change or remove Windows firewall rules."
|
30
30
|
introduced "14.7"
|
31
|
+
examples <<~DOC
|
32
|
+
**Allowing port 80 access**:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
windows_firewall_rule 'IIS' do
|
36
|
+
local_port '80'
|
37
|
+
protocol 'TCP'
|
38
|
+
firewall_action :allow
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
**Allow protocol ICMPv6 with ICMP Type**:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
windows_firewall_rule 'CoreNet-Rule' do
|
46
|
+
rule_name 'CoreNet-ICMP6-LR2-In'
|
47
|
+
display_name 'Core Networking - Multicast Listener Report v2 (ICMPv6-In)'
|
48
|
+
local_port 'RPC'
|
49
|
+
protocol 'ICMPv6'
|
50
|
+
icmp_type '8'
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
**Blocking WinRM over HTTP on a particular IP**:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
windows_firewall_rule 'Disable WinRM over HTTP' do
|
58
|
+
local_port '5985'
|
59
|
+
protocol 'TCP'
|
60
|
+
firewall_action :block
|
61
|
+
local_address '192.168.1.1'
|
62
|
+
end
|
63
|
+
```
|
64
|
+
|
65
|
+
**Deleting an existing rule**
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
windows_firewall_rule 'Remove the SSH rule' do
|
69
|
+
rule_name 'ssh'
|
70
|
+
action :delete
|
71
|
+
end
|
72
|
+
```
|
73
|
+
DOC
|
31
74
|
|
32
75
|
property :rule_name, String,
|
33
76
|
name_property: true,
|
34
77
|
description: "An optional property to set the name of the firewall rule to assign if it differs from the resource block's name."
|
35
78
|
|
36
79
|
property :description, String,
|
37
|
-
default: "Firewall rule",
|
38
80
|
description: "The description to assign to the firewall rule."
|
39
81
|
|
82
|
+
property :displayname, String,
|
83
|
+
description: "The displayname to assign to the firewall rule.",
|
84
|
+
default: lazy { rule_name },
|
85
|
+
default_description: "The rule_name property value.",
|
86
|
+
introduced: "16.0"
|
87
|
+
|
88
|
+
property :group, String,
|
89
|
+
description: "Specifies that only matching firewall rules of the indicated group association are copied.",
|
90
|
+
introduced: "16.0"
|
91
|
+
|
40
92
|
property :local_address, String,
|
41
93
|
description: "The local address the firewall rule applies to."
|
42
94
|
|
@@ -62,6 +114,11 @@ class Chef
|
|
62
114
|
default: "TCP",
|
63
115
|
description: "The protocol the firewall rule applies to."
|
64
116
|
|
117
|
+
property :icmp_type, [String, Integer],
|
118
|
+
description: "Specifies the ICMP Type parameter for using a protocol starting with ICMP",
|
119
|
+
default: "Any",
|
120
|
+
introduced: "16.0"
|
121
|
+
|
65
122
|
property :firewall_action, [Symbol, String],
|
66
123
|
default: :allow, equal_to: %i{allow block notconfigured},
|
67
124
|
description: "The action of the firewall rule.",
|
@@ -110,12 +167,16 @@ class Chef
|
|
110
167
|
# Need to reverse `$rule.Profile.ToString()` in powershell command
|
111
168
|
current_profiles = state["profile"].split(", ").map(&:to_sym)
|
112
169
|
|
170
|
+
description state["description"]
|
171
|
+
displayname state["displayname"]
|
172
|
+
group state["group"]
|
113
173
|
local_address state["local_address"]
|
114
174
|
local_port Array(state["local_port"]).sort
|
115
175
|
remote_address state["remote_address"]
|
116
176
|
remote_port Array(state["remote_port"]).sort
|
117
177
|
direction state["direction"]
|
118
178
|
protocol state["protocol"]
|
179
|
+
icmp_type state["icmp_type"]
|
119
180
|
firewall_action state["firewall_action"]
|
120
181
|
profile current_profiles
|
121
182
|
program state["program"]
|
@@ -126,13 +187,18 @@ class Chef
|
|
126
187
|
|
127
188
|
action :create do
|
128
189
|
description "Create a Windows firewall entry."
|
129
|
-
|
130
190
|
if current_resource
|
131
|
-
converge_if_changed :rule_name, :
|
132
|
-
:
|
191
|
+
converge_if_changed :rule_name, :description, :displayname, :local_address, :local_port, :remote_address,
|
192
|
+
:remote_port, :direction, :protocol, :icmp_type, :firewall_action, :profile, :program, :service,
|
193
|
+
:interface_type, :enabled do
|
133
194
|
cmd = firewall_command("Set")
|
134
195
|
powershell_out!(cmd)
|
135
196
|
end
|
197
|
+
converge_if_changed :group do
|
198
|
+
powershell_out!("Remove-NetFirewallRule -Name '#{new_resource.rule_name}'")
|
199
|
+
cmd = firewall_command("New")
|
200
|
+
powershell_out!(cmd)
|
201
|
+
end
|
136
202
|
else
|
137
203
|
converge_by("create firewall rule #{new_resource.rule_name}") do
|
138
204
|
cmd = firewall_command("New")
|
@@ -158,7 +224,9 @@ class Chef
|
|
158
224
|
# @return [String] firewall create command
|
159
225
|
def firewall_command(cmdlet_type)
|
160
226
|
cmd = "#{cmdlet_type}-NetFirewallRule -Name '#{new_resource.rule_name}'"
|
161
|
-
cmd << " -DisplayName '#{new_resource.
|
227
|
+
cmd << " -DisplayName '#{new_resource.displayname}'" if new_resource.displayname && cmdlet_type == "New"
|
228
|
+
cmd << " -NewDisplayName '#{new_resource.displayname}'" if new_resource.displayname && cmdlet_type == "Set"
|
229
|
+
cmd << " -Group '#{new_resource.group}'" if new_resource.group && cmdlet_type == "New"
|
162
230
|
cmd << " -Description '#{new_resource.description}'" if new_resource.description
|
163
231
|
cmd << " -LocalAddress '#{new_resource.local_address}'" if new_resource.local_address
|
164
232
|
cmd << " -LocalPort '#{new_resource.local_port.join("', '")}'" if new_resource.local_port
|
@@ -166,6 +234,7 @@ class Chef
|
|
166
234
|
cmd << " -RemotePort '#{new_resource.remote_port.join("', '")}'" if new_resource.remote_port
|
167
235
|
cmd << " -Direction '#{new_resource.direction}'" if new_resource.direction
|
168
236
|
cmd << " -Protocol '#{new_resource.protocol}'" if new_resource.protocol
|
237
|
+
cmd << " -IcmpType '#{new_resource.icmp_type}'"
|
169
238
|
cmd << " -Action '#{new_resource.firewall_action}'" if new_resource.firewall_action
|
170
239
|
cmd << " -Profile '#{new_resource.profile.join("', '")}'" if new_resource.profile
|
171
240
|
cmd << " -Program '#{new_resource.program}'" if new_resource.program
|
@@ -175,12 +244,53 @@ class Chef
|
|
175
244
|
|
176
245
|
cmd
|
177
246
|
end
|
247
|
+
|
248
|
+
def define_resource_requirements
|
249
|
+
requirements.assert(:create) do |a|
|
250
|
+
a.assertion do
|
251
|
+
if new_resource.icmp_type.is_a?(String)
|
252
|
+
!new_resource.icmp_type.empty?
|
253
|
+
elsif new_resource.icmp_type.is_a?(Integer)
|
254
|
+
!new_resource.icmp_type.nil?
|
255
|
+
end
|
256
|
+
end
|
257
|
+
a.failure_message("The :icmp_type property can not be empty in #{new_resource.rule_name}")
|
258
|
+
end
|
259
|
+
|
260
|
+
requirements.assert(:create) do |a|
|
261
|
+
a.assertion do
|
262
|
+
if new_resource.icmp_type.is_a?(Integer)
|
263
|
+
new_resource.protocol.start_with?("ICMP")
|
264
|
+
elsif new_resource.icmp_type.is_a?(String) && !new_resource.protocol.start_with?("ICMP")
|
265
|
+
new_resource.icmp_type == "Any"
|
266
|
+
else
|
267
|
+
true
|
268
|
+
end
|
269
|
+
end
|
270
|
+
a.failure_message("The :icmp_type property has a value of #{new_resource.icmp_type} set, but is not allowed for :protocol #{new_resource.protocol} in #{new_resource.rule_name}")
|
271
|
+
end
|
272
|
+
|
273
|
+
requirements.assert(:create) do |a|
|
274
|
+
a.assertion do
|
275
|
+
if new_resource.icmp_type.is_a?(Integer)
|
276
|
+
(0..255).include?(new_resource.icmp_type)
|
277
|
+
elsif new_resource.icmp_type.is_a?(String) && !new_resource.icmp_type.include?(":") && new_resource.protocol.start_with?("ICMP")
|
278
|
+
(0..255).include?(new_resource.icmp_type.to_i)
|
279
|
+
elsif new_resource.icmp_type.is_a?(String) && new_resource.icmp_type.include?(":") && new_resource.protocol.start_with?("ICMP")
|
280
|
+
new_resource.icmp_type.split(":").all? { |type| (0..255).include?(type.to_i) }
|
281
|
+
else
|
282
|
+
true
|
283
|
+
end
|
284
|
+
end
|
285
|
+
a.failure_message("Can not set :icmp_type to #{new_resource.icmp_type} as one value is out of range (0 to 255) in #{new_resource.rule_name}")
|
286
|
+
end
|
287
|
+
end
|
178
288
|
end
|
179
289
|
|
180
290
|
private
|
181
291
|
|
182
292
|
# build the command to load the current resource
|
183
|
-
#
|
293
|
+
# @return [String] current firewall state
|
184
294
|
def load_firewall_state(rule_name)
|
185
295
|
<<-EOH
|
186
296
|
Remove-TypeData System.Array # workaround for PS bug here: https://bit.ly/2SRMQ8M
|
@@ -193,12 +303,15 @@ class Chef
|
|
193
303
|
([PSCustomObject]@{
|
194
304
|
rule_name = $rule.Name
|
195
305
|
description = $rule.Description
|
306
|
+
displayname = $rule.DisplayName
|
307
|
+
group = $rule.Group
|
196
308
|
local_address = $addressFilter.LocalAddress
|
197
309
|
local_port = $portFilter.LocalPort
|
198
310
|
remote_address = $addressFilter.RemoteAddress
|
199
311
|
remote_port = $portFilter.RemotePort
|
200
312
|
direction = $rule.Direction.ToString()
|
201
313
|
protocol = $portFilter.Protocol
|
314
|
+
icmp_type = $portFilter.IcmpType
|
202
315
|
firewall_action = $rule.Action.ToString()
|
203
316
|
profile = $rule.Profile.ToString()
|
204
317
|
program = $applicationFilter.Program
|