diff options
57 files changed, 310 insertions, 168 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 71f57ef3fb..e2fcb697e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,34 +1,54 @@ <!-- usage documentation: http://expeditor-docs.es.chef.io/configuration/changelog/ --> -<!-- latest_release 16.2.65 --> -## [v16.2.65](https://github.com/chef/chef/tree/v16.2.65) (2020-06-26) +<!-- latest_release 16.2.80 --> +## [v16.2.80](https://github.com/chef/chef/tree/v16.2.80) (2020-07-03) #### Merged Pull Requests -- Revert openssl digest update that broke FIPS [#10058](https://github.com/chef/chef/pull/10058) ([tas50](https://github.com/tas50)) +- update to powershell_out to be compatible with 32 bit windows [#10107](https://github.com/chef/chef/pull/10107) ([chef-davin](https://github.com/chef-davin)) <!-- latest_release --> -<!-- release_rollup since=16.2.50 --> +<!-- release_rollup since=16.2.73 --> ### Changes not yet released to stable #### Merged Pull Requests -- Revert openssl digest update that broke FIPS [#10058](https://github.com/chef/chef/pull/10058) ([tas50](https://github.com/tas50)) <!-- 16.2.65 --> -- Pick some of the unit test fixes from #10068 [#10074](https://github.com/chef/chef/pull/10074) ([lamont-granquist](https://github.com/lamont-granquist)) <!-- 16.2.64 --> -- Remove Azure private verify pipeline [#10019](https://github.com/chef/chef/pull/10019) ([christopher-snapp](https://github.com/christopher-snapp)) <!-- 16.2.63 --> -- Update ffi-libarchive for windows fixes / pin the dep [#10072](https://github.com/chef/chef/pull/10072) ([tas50](https://github.com/tas50)) <!-- 16.2.63 --> -- fix habitat based windows service tests [#10070](https://github.com/chef/chef/pull/10070) ([mwrock](https://github.com/mwrock)) <!-- 16.2.62 --> -- Update the windows_user_privilege resource to have a `:clear` action [#10063](https://github.com/chef/chef/pull/10063) ([chef-davin](https://github.com/chef-davin)) <!-- 16.2.61 --> -- specs: Remove more methods defined on the top-level scope [#10060](https://github.com/chef/chef/pull/10060) ([phiggins](https://github.com/phiggins)) <!-- 16.2.60 --> -- Bump the external tests to 2.7 [#10062](https://github.com/chef/chef/pull/10062) ([lamont-granquist](https://github.com/lamont-granquist)) <!-- 16.2.59 --> -- Bump train-core to 3.3.4 [#10067](https://github.com/chef/chef/pull/10067) ([chef-expeditor[bot]](https://github.com/chef-expeditor[bot])) <!-- 16.2.58 --> -- Fixed broken chef-apply with -j [#10066](https://github.com/chef/chef/pull/10066) ([komazarari](https://github.com/komazarari)) <!-- 16.2.57 --> -- consume powershell shim DLLs from hab package [#10022](https://github.com/chef/chef/pull/10022) ([mwrock](https://github.com/mwrock)) <!-- 16.2.56 --> -- Inline some constants to prevent redefenition warnings in tests. [#10047](https://github.com/chef/chef/pull/10047) ([phiggins](https://github.com/phiggins)) <!-- 16.2.55 --> -- Bump diff-lcs to get bugfix. [#10057](https://github.com/chef/chef/pull/10057) ([phiggins](https://github.com/phiggins)) <!-- 16.2.54 --> -- Setup cspell to pull from our common dictionary [#10021](https://github.com/chef/chef/pull/10021) ([tas50](https://github.com/tas50)) <!-- 16.2.53 --> -- Fix broken tests after updating diff-lcs dep [#10052](https://github.com/chef/chef/pull/10052) ([phiggins](https://github.com/phiggins)) <!-- 16.2.52 --> -- More aggressively deprecate config_value [#10025](https://github.com/chef/chef/pull/10025) ([lamont-granquist](https://github.com/lamont-granquist)) <!-- 16.2.51 --> +- update to powershell_out to be compatible with 32 bit windows [#10107](https://github.com/chef/chef/pull/10107) ([chef-davin](https://github.com/chef-davin)) <!-- 16.2.80 --> +- Update windows_security_policy for better idempotency [#10064](https://github.com/chef/chef/pull/10064) ([chef-davin](https://github.com/chef-davin)) <!-- 16.2.79 --> +- Bump train-core to 3.3.6 [#10104](https://github.com/chef/chef/pull/10104) ([chef-expeditor[bot]](https://github.com/chef-expeditor[bot])) <!-- 16.2.78 --> +- Use bash not execute in build_essential for better output [#10096](https://github.com/chef/chef/pull/10096) ([tas50](https://github.com/tas50)) <!-- 16.2.77 --> +- Bump inspec-core-bin to 4.21.3 [#10101](https://github.com/chef/chef/pull/10101) ([chef-expeditor[bot]](https://github.com/chef-expeditor[bot])) <!-- 16.2.76 --> +- Fix syslog logging on Chef-16 [#10097](https://github.com/chef/chef/pull/10097) ([lamont-granquist](https://github.com/lamont-granquist)) <!-- 16.2.75 --> +- Reserve deprecation ID that was used in Chef-15 [#10091](https://github.com/chef/chef/pull/10091) ([lamont-granquist](https://github.com/lamont-granquist)) <!-- 16.2.74 --> <!-- release_rollup --> <!-- latest_stable_release --> +## [v16.2.73](https://github.com/chef/chef/tree/v16.2.73) (2020-07-01) + +#### Merged Pull Requests +- More aggressively deprecate config_value [#10025](https://github.com/chef/chef/pull/10025) ([lamont-granquist](https://github.com/lamont-granquist)) +- Fix broken tests after updating diff-lcs dep [#10052](https://github.com/chef/chef/pull/10052) ([phiggins](https://github.com/phiggins)) +- Setup cspell to pull from our common dictionary [#10021](https://github.com/chef/chef/pull/10021) ([tas50](https://github.com/tas50)) +- Bump diff-lcs to get bugfix. [#10057](https://github.com/chef/chef/pull/10057) ([phiggins](https://github.com/phiggins)) +- Inline some constants to prevent redefenition warnings in tests. [#10047](https://github.com/chef/chef/pull/10047) ([phiggins](https://github.com/phiggins)) +- consume powershell shim DLLs from hab package [#10022](https://github.com/chef/chef/pull/10022) ([mwrock](https://github.com/mwrock)) +- Fixed broken chef-apply with -j [#10066](https://github.com/chef/chef/pull/10066) ([komazarari](https://github.com/komazarari)) +- Bump train-core to 3.3.4 [#10067](https://github.com/chef/chef/pull/10067) ([chef-expeditor[bot]](https://github.com/chef-expeditor[bot])) +- Bump the external tests to 2.7 [#10062](https://github.com/chef/chef/pull/10062) ([lamont-granquist](https://github.com/lamont-granquist)) +- specs: Remove more methods defined on the top-level scope [#10060](https://github.com/chef/chef/pull/10060) ([phiggins](https://github.com/phiggins)) +- Update the windows_user_privilege resource to have a `:clear` action [#10063](https://github.com/chef/chef/pull/10063) ([chef-davin](https://github.com/chef-davin)) +- fix habitat based windows service tests [#10070](https://github.com/chef/chef/pull/10070) ([mwrock](https://github.com/mwrock)) +- Update ffi-libarchive for windows fixes / pin the dep [#10072](https://github.com/chef/chef/pull/10072) ([tas50](https://github.com/tas50)) +- Remove Azure private verify pipeline [#10019](https://github.com/chef/chef/pull/10019) ([christopher-snapp](https://github.com/christopher-snapp)) +- Pick some of the unit test fixes from #10068 [#10074](https://github.com/chef/chef/pull/10074) ([lamont-granquist](https://github.com/lamont-granquist)) +- Revert openssl digest update that broke FIPS [#10058](https://github.com/chef/chef/pull/10058) ([tas50](https://github.com/tas50)) +- Update tests and docs for umask on Windows. [#10077](https://github.com/chef/chef/pull/10077) ([phiggins](https://github.com/phiggins)) +- Revert "Merge pull request #10052 from chef/fix-diff-tests" [#10078](https://github.com/chef/chef/pull/10078) ([phiggins](https://github.com/phiggins)) +- specs: Remove test file that added a method to top-level scope. [#10027](https://github.com/chef/chef/pull/10027) ([phiggins](https://github.com/phiggins)) +- Bump inspec-core-bin to 4.21.1 [#10081](https://github.com/chef/chef/pull/10081) ([chef-expeditor[bot]](https://github.com/chef-expeditor[bot])) +- Pin dff-lcs, bump ohai, & misc omnibus updates [#10085](https://github.com/chef/chef/pull/10085) ([tas50](https://github.com/tas50)) +- Fix release build tests [#10088](https://github.com/chef/chef/pull/10088) ([phiggins](https://github.com/phiggins)) +- Fix release build tests, part 2 [#10089](https://github.com/chef/chef/pull/10089) ([phiggins](https://github.com/phiggins)) +- Fix release build tests, part 3 [#10093](https://github.com/chef/chef/pull/10093) ([phiggins](https://github.com/phiggins)) +<!-- latest_stable_release --> + ## [v16.2.50](https://github.com/chef/chef/tree/v16.2.50) (2020-06-23) #### Merged Pull Requests @@ -38,7 +58,6 @@ - Add more examples to the resource code [#10020](https://github.com/chef/chef/pull/10020) ([tas50](https://github.com/tas50)) - Resource doc updates [#10024](https://github.com/chef/chef/pull/10024) ([phiggins](https://github.com/phiggins)) - Bump ohai to 16.2.1 [#10035](https://github.com/chef/chef/pull/10035) ([chef-expeditor[bot]](https://github.com/chef-expeditor[bot])) -<!-- latest_stable_release --> ## [v16.2.44](https://github.com/chef/chef/tree/v16.2.44) (2020-06-17) diff --git a/Dockerfile b/Dockerfile index 46ea6a4f14..fb92e9f904 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ LABEL maintainer="Chef Software, Inc. <docker@chef.io>" ARG EXPEDITOR_CHANNEL ARG CHANNEL=stable ARG EXPEDITOR_VERSION -ARG VERSION=16.2.50 +ARG VERSION=16.2.73 # Allow the build arg below to be controlled by either build arguments ENV VERSION ${EXPEDITOR_VERSION:-${VERSION}} diff --git a/Gemfile.lock b/Gemfile.lock index 5d665a20ae..6017b773a2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,10 +8,10 @@ GIT GIT remote: https://github.com/chef/ohai.git - revision: 7bd12469af0ba7227d77124dce4cdf7b9051e331 + revision: 8028951abb141fef97a9b2ddc5e2120f63fbc16a branch: master specs: - ohai (16.2.1) + ohai (16.2.3) chef-config (>= 12.8, < 17) chef-utils (>= 16.0, < 17) ffi (~> 1.9) @@ -28,15 +28,15 @@ GIT PATH remote: . specs: - chef (16.2.65) + chef (16.2.80) addressable bcrypt_pbkdf (= 1.1.0.rc1) bundler (>= 1.10) - chef-config (= 16.2.65) - chef-utils (= 16.2.65) + chef-config (= 16.2.80) + chef-utils (= 16.2.80) chef-vault chef-zero (>= 14.0.11) - diff-lcs (~> 1.2, >= 1.2.4) + diff-lcs (>= 1.2.4, < 1.4.0) ed25519 (~> 1.2) erubis (~> 2.7) ffi (>= 1.9.25) @@ -62,15 +62,15 @@ PATH train-winrm (>= 0.2.5) tty-screen (~> 0.6) uuidtools (~> 2.1.5) - chef (16.2.65-universal-mingw32) + chef (16.2.80-universal-mingw32) addressable bcrypt_pbkdf (= 1.1.0.rc1) bundler (>= 1.10) - chef-config (= 16.2.65) - chef-utils (= 16.2.65) + chef-config (= 16.2.80) + chef-utils (= 16.2.80) chef-vault chef-zero (>= 14.0.11) - diff-lcs (~> 1.2, >= 1.2.4) + diff-lcs (>= 1.2.4, < 1.4.0) ed25519 (~> 1.2) erubis (~> 2.7) ffi (>= 1.9.25) @@ -112,15 +112,15 @@ PATH PATH remote: chef-bin specs: - chef-bin (16.2.65) - chef (= 16.2.65) + chef-bin (16.2.80) + chef (= 16.2.80) PATH remote: chef-config specs: - chef-config (16.2.65) + chef-config (16.2.80) addressable - chef-utils (= 16.2.65) + chef-utils (= 16.2.80) fuzzyurl mixlib-config (>= 2.2.12, < 4.0) mixlib-shellout (>= 2.0, < 4.0) @@ -129,7 +129,7 @@ PATH PATH remote: chef-utils specs: - chef-utils (16.2.65) + chef-utils (16.2.80) GEM remote: https://rubygems.org/ @@ -166,7 +166,7 @@ GEM crack (0.4.3) safe_yaml (~> 1.0.0) debug_inspector (0.0.3) - diff-lcs (1.4.2) + diff-lcs (1.3) ecma-re-validator (0.2.1) regexp_parser (~> 1.2) ed25519 (1.2.4) @@ -198,7 +198,7 @@ GEM htmlentities (4.3.4) httpclient (2.8.3) iniparse (1.5.0) - inspec-core (4.20.10) + inspec-core (4.21.3) addressable (~> 2.4) chef-telemetry (~> 1.0) faraday (>= 0.9.0) @@ -223,11 +223,11 @@ GEM train-core (~> 3.0) tty-prompt (~> 0.17) tty-table (~> 0.10) - inspec-core-bin (4.20.10) - inspec-core (= 4.20.10) + inspec-core-bin (4.21.3) + inspec-core (= 4.21.3) ipaddress (0.8.3) iso8601 (0.12.2) - json (2.3.0) + json (2.3.1) json_schemer (0.2.11) ecma-re-validator (~> 0.2) hana (~> 1.3) @@ -327,7 +327,7 @@ GEM rubocop-ast (>= 0.0.3, < 1.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 2.0) - rubocop-ast (0.0.3) + rubocop-ast (0.1.0) parser (>= 2.7.0.1) ruby-prof (1.2.0) ruby-progressbar (1.10.1) @@ -353,7 +353,7 @@ GEM tins (1.25.0) sync tomlrb (1.2.9) - train-core (3.3.4) + train-core (3.3.6) addressable (~> 2.5) ffi (!= 1.13.0) json (>= 1.8, < 3.0) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 5ca8fda4bf..8744bb4dd4 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,17 @@ This file holds "in progress" release notes for the current release under development and is intended for consumption by the Chef Documentation team. Please see <https://docs.chef.io/release_notes/> for the official Chef release notes. +# What's New in 16.2.72 + +- Habitat packages for Chef Infra Client 16 are now published with full support for the `powershell_exec` helper now added. +- Added a new `clear` action to the `windows_user_privilege` resource. +- Resolved a regression in Chef Infra Client 16.1 and later that caused failures running on FIPS enabled systems. +- Resolved failures in the `archive_file` resource when running on Windows hosts. +- Resolved a failure when running `chef-apply` with the `-j` option. Thanks [@komazarari](https://github.com/komazarari). +- Chef Infra Client running within GitHub Actions is now properly identified as running in a Docker container. Thanks [@jaymzh](http://github.com/jaymzh). +- SSH connections are now reused, improving the speed of knife bootstrap and remote resources on slow network links. Thanks [@tecracer-theinen](https://github.com/tecracer-theinen). +- `node['network']['interfaces']` data now correctly identifies IPv6 next hops for IPv4 routes. Thanks [@cooperlees](https://github.com/cooperlees). +- Updated InSpec from 4.20.10 to 4.21.1. + # What's New in 16.2.50 - Correctly identify the new macOS Big Sur (11.0) beta as platform "mac_os_x". @@ -1 +1 @@ -16.2.65
\ No newline at end of file +16.2.80
\ No newline at end of file diff --git a/chef-bin/lib/chef-bin/version.rb b/chef-bin/lib/chef-bin/version.rb index 6eace93eb1..ed04ba2da8 100644 --- a/chef-bin/lib/chef-bin/version.rb +++ b/chef-bin/lib/chef-bin/version.rb @@ -21,7 +21,7 @@ module ChefBin CHEFBIN_ROOT = File.expand_path("../..", __FILE__) - VERSION = "16.2.65".freeze + VERSION = "16.2.80".freeze end # diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb index 02f9896fa1..498f4d77e2 100644 --- a/chef-config/lib/chef-config/version.rb +++ b/chef-config/lib/chef-config/version.rb @@ -15,5 +15,5 @@ module ChefConfig CHEFCONFIG_ROOT = File.expand_path("../..", __FILE__) - VERSION = "16.2.65".freeze + VERSION = "16.2.80".freeze end diff --git a/chef-utils/lib/chef-utils/version.rb b/chef-utils/lib/chef-utils/version.rb index 328237e087..bb2b82b04f 100644 --- a/chef-utils/lib/chef-utils/version.rb +++ b/chef-utils/lib/chef-utils/version.rb @@ -15,5 +15,5 @@ module ChefUtils CHEFUTILS_ROOT = File.expand_path("../..", __FILE__) - VERSION = "16.2.65".freeze + VERSION = "16.2.80".freeze end diff --git a/chef.gemspec b/chef.gemspec index b2fc6cf5e3..42b7e16522 100644 --- a/chef.gemspec +++ b/chef.gemspec @@ -39,7 +39,7 @@ Gem::Specification.new do |s| s.add_dependency "tty-screen", "~> 0.6" # knife list s.add_dependency "pastel" # knife ui.color s.add_dependency "erubis", "~> 2.7" - s.add_dependency "diff-lcs", "~> 1.2", ">= 1.2.4" + s.add_dependency "diff-lcs", ">= 1.2.4", "< 1.4.0" # 1.4 breaks output s.add_dependency "ffi-libarchive", "~> 1.0", ">= 1.0.3" s.add_dependency "chef-zero", ">= 14.0.11" s.add_dependency "chef-vault" diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/macos.rb b/kitchen-tests/cookbooks/end_to_end/recipes/macos.rb index 30b674620b..c6be1ef249 100644 --- a/kitchen-tests/cookbooks/end_to_end/recipes/macos.rb +++ b/kitchen-tests/cookbooks/end_to_end/recipes/macos.rb @@ -56,6 +56,8 @@ include_recipe "git" end end +build_essential + launchd "io.chef.testing.fake" do source "io.chef.testing.fake.plist" action "enable" diff --git a/lib/chef/application.rb b/lib/chef/application.rb index 0d80123bda..1e3b72e1ad 100644 --- a/lib/chef/application.rb +++ b/lib/chef/application.rb @@ -194,8 +194,10 @@ class Chef chef_config[:log_location].map! do |log_location| case log_location when :syslog, "syslog" + force_force_logger logger::Syslog.new when :win_evt, "win_evt" + force_force_logger logger::WinEvt.new else # should be a path or STDOUT @@ -204,6 +206,16 @@ class Chef end end + # Force the logger by default for the :winevt and :syslog loggers. Since we do not and cannot + # support multiple log levels in a mix-and-match situation with formatters and loggers, and the + # formatters do not support syslog, we force the formatter off by default and the log level is + # thus info by default. Users can add `--force-formatter -l info` to get back formatter output + # on STDOUT along with syslog logging. + # + def force_force_logger + chef_config[:force_logger] = true unless chef_config[:force_formatter] + end + # Use of output formatters is assumed if `force_formatter` is set or if `force_logger` is not set def using_output_formatter? chef_config[:force_formatter] || !chef_config[:force_logger] diff --git a/lib/chef/client.rb b/lib/chef/client.rb index a43740258d..b6f9958d64 100644 --- a/lib/chef/client.rb +++ b/lib/chef/client.rb @@ -343,7 +343,7 @@ class Chef formatters_for_run.map do |formatter_name, output_path| if output_path.nil? Chef::Formatters.new(formatter_name, STDOUT_FD, STDERR_FD) - else + elsif output_path.is_a?(String) io = File.open(output_path, "a+") io.sync = true Chef::Formatters.new(formatter_name, io, io) diff --git a/lib/chef/deprecated.rb b/lib/chef/deprecated.rb index d67cee8153..4a2ac69b04 100644 --- a/lib/chef/deprecated.rb +++ b/lib/chef/deprecated.rb @@ -241,6 +241,10 @@ class Chef target 30 end + class ResourceNameWithoutProvides < Base + target 31 + end + class Generic < Base def url "https://docs.chef.io/chef_deprecations_client/" diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index 37e964a243..bd6757c6f7 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -460,7 +460,7 @@ class Chef property :umask, String, desired_state: false, introduced: "16.2", - description: "Set a umask to be used for the duration of converging the resource. Defaults to `nil`, which means to use the system umask." + description: "Set a umask to be used for the duration of converging the resource. Defaults to `nil`, which means to use the system umask. Unsupported on Windows because Windows lacks a direct equivalent to UNIX's umask." # The time it took (in seconds) to run the most recently-run action. Not # cumulative across actions. This is set to 0 as soon as a new action starts diff --git a/lib/chef/resource/build_essential.rb b/lib/chef/resource/build_essential.rb index c83517fdfe..ad37d3924f 100644 --- a/lib/chef/resource/build_essential.rb +++ b/lib/chef/resource/build_essential.rb @@ -146,8 +146,8 @@ class Chef def install_xcode_cli_tools(label) # This script was graciously borrowed and modified from Tim Sutton's # osx-vm-templates at https://github.com/timsutton/osx-vm-templates/blob/b001475df54a9808d3d56d06e71b8fa3001fff42/scripts/xcode-cli-tools.sh - execute "install Xcode Command Line tools" do - command <<-EOH + bash "install Xcode Command Line Tools" do + code <<-EOH # create the placeholder file that's checked by CLI updates' .dist code # in Apple's SUS catalog touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress diff --git a/lib/chef/resource/windows_security_policy.rb b/lib/chef/resource/windows_security_policy.rb index 4fd38807de..dc89b09bc6 100644 --- a/lib/chef/resource/windows_security_policy.rb +++ b/lib/chef/resource/windows_security_policy.rb @@ -80,13 +80,55 @@ class Chef property :secvalue, String, required: true, description: "Policy value to be set for policy name." + load_current_value do |desired| + powershell_code = <<-CODE + C:\\Windows\\System32\\secedit /export /cfg $env:TEMP\\secopts_export.inf | Out-Null + # cspell:disable-next-line + $security_options_data = (Get-Content $env:TEMP\\secopts_export.inf | Select-String -Pattern "^[CEFLMNPR].* =.*$" | Out-String) + Remove-Item $env:TEMP\\secopts_export.inf -force + $security_options_hash = ($security_options_data -Replace '"'| ConvertFrom-StringData) + ([PSCustomObject]@{ + RequireLogonToChangePassword = $security_options_hash.RequireLogonToChangePassword + PasswordComplexity = $security_options_hash.PasswordComplexity + LSAAnonymousNameLookup = $security_options_hash.LSAAnonymousNameLookup + EnableAdminAccount = $security_options_hash.EnableAdminAccount + PasswordHistorySize = $security_options_hash.PasswordHistorySize + MinimumPasswordLength = $security_options_hash.MinimumPasswordLength + ResetLockoutCount = $security_options_hash.ResetLockoutCount + MaximumPasswordAge = $security_options_hash.MaximumPasswordAge + ClearTextPassword = $security_options_hash.ClearTextPassword + NewAdministratorName = $security_options_hash.NewAdministratorName + LockoutDuration = $security_options_hash.LockoutDuration + EnableGuestAccount = $security_options_hash.EnableGuestAccount + ForceLogoffWhenHourExpire = $security_options_hash.ForceLogoffWhenHourExpire + MinimumPasswordAge = $security_options_hash.MinimumPasswordAge + NewGuestName = $security_options_hash.NewGuestName + LockoutBadCount = $security_options_hash.LockoutBadCount + }) | ConvertTo-Json + CODE + output = powershell_out(powershell_code) + current_value_does_not_exist! if output.stdout.empty? + state = Chef::JSONCompat.from_json(output.stdout) + + if desired.secoption == "ResetLockoutCount" || desired.secoption == "LockoutDuration" + if state["LockoutBadCount"] == "0" + raise Chef::Exceptions::ValidationFailed.new "#{desired.secoption} cannot be set unless the \"LockoutBadCount\" security policy has been set to a non-zero value" + else + secvalue state[desired.secoption.to_s] + end + else + secvalue state[desired.secoption.to_s] + end + end + action :set do - security_option = new_resource.secoption - security_value = new_resource.secvalue - powershell_script "#{security_option} set to #{security_value}" do - convert_boolean_return true - code <<-EOH + converge_if_changed :secvalue do + security_option = new_resource.secoption + security_value = new_resource.secvalue + + cmd = <<-EOH $security_option = "#{security_option}" + C:\\Windows\\System32\\secedit /export /cfg $env:TEMP\\#{security_option}_Export.inf if ( ($security_option -match "NewGuestName") -Or ($security_option -match "NewAdministratorName") ) { $#{security_option}_Remediation = (Get-Content $env:TEMP\\#{security_option}_Export.inf) | Foreach-Object { $_ -replace '#{security_option}\\s*=\\s*\\"\\w*\\"', '#{security_option} = "#{security_value}"' } | Set-Content $env:TEMP\\#{security_option}_Export.inf @@ -99,21 +141,8 @@ class Chef } Remove-Item $env:TEMP\\#{security_option}_Export.inf -force EOH - not_if <<-EOH - $#{security_option}_Export = C:\\Windows\\System32\\secedit /export /cfg $env:TEMP\\#{security_option}_Export.inf - $ExportAudit = (Get-Content $env:TEMP\\#{security_option}_Export.inf | Select-String -Pattern #{security_option}) - $check_digit = $ExportAudit -match '#{security_option} = #{security_value}' - $check_string = $ExportAudit -match '#{security_option} = "#{security_value}"' - if ( $check_string -Or $check_digit ) - { - Remove-Item $env:TEMP\\#{security_option}_Export.inf -force - $true - } - else - { - $false - } - EOH + + powershell_out!(cmd) end end end diff --git a/lib/chef/version.rb b/lib/chef/version.rb index d47fb1c279..948ab1eee2 100644 --- a/lib/chef/version.rb +++ b/lib/chef/version.rb @@ -23,7 +23,7 @@ require_relative "version_string" class Chef CHEF_ROOT = File.expand_path("../..", __FILE__) - VERSION = Chef::VersionString.new("16.2.65") + VERSION = Chef::VersionString.new("16.2.80") end # diff --git a/omnibus/Gemfile.lock b/omnibus/Gemfile.lock index c37f90dc97..696331c372 100644 --- a/omnibus/Gemfile.lock +++ b/omnibus/Gemfile.lock @@ -1,9 +1,9 @@ GIT remote: https://github.com/chef/omnibus - revision: d75718522deb9faeb3c21b50c60e94daf70ce9b6 + revision: 320d9350cdf39abdcc4c37d5bc2971b3c222a0a0 branch: master specs: - omnibus (7.0.13) + omnibus (7.0.14) aws-sdk-s3 (~> 1) chef-cleanroom (~> 1.0) chef-sugar (>= 3.3) @@ -32,7 +32,7 @@ GEM artifactory (3.0.15) awesome_print (1.8.0) aws-eventstream (1.1.0) - aws-partitions (1.335.0) + aws-partitions (1.337.0) aws-sdk-core (3.102.1) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.239.0) @@ -41,7 +41,7 @@ GEM aws-sdk-kms (1.35.0) aws-sdk-core (~> 3, >= 3.99.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.71.1) + aws-sdk-s3 (1.72.0) aws-sdk-core (~> 3, >= 3.102.1) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.1) @@ -164,7 +164,7 @@ GEM citrus (3.0.2) cleanroom (1.0.0) concurrent-ruby (1.1.6) - diff-lcs (1.4.2) + diff-lcs (1.4.3) ed25519 (1.2.4) equatable (0.6.1) erubi (1.9.0) @@ -193,7 +193,7 @@ GEM ipaddress (0.8.3) iso8601 (0.12.2) jmespath (1.4.0) - json (2.3.0) + json (2.3.1) kitchen-vagrant (1.6.1) test-kitchen (>= 1.4, < 3) libyajl2 (1.2.0) diff --git a/omnibus/README.md b/omnibus/README.md index 6e49f091a5..a10190c136 100644 --- a/omnibus/README.md +++ b/omnibus/README.md @@ -1,17 +1,16 @@ -# Client Tools Omnibus project +# Chef Infra Client Omnibus project This project creates full-stack platform-specific packages for the following projects: - AngryChef - Chef -- Chef with FIPS enabled ## Installation You must have a sane Ruby environment with Bundler installed. Ensure all the required gems are installed: ```shell -$ bundle install --without development +bundle install --without development ``` ## Usage @@ -117,7 +116,7 @@ For a complete list of all commands and platforms, run `kitchen list` or `kitche ## License ```text -Copyright 2012-2018, Chef Software, Inc. +Copyright:: Chef Software, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/omnibus/config/software/more-ruby-cleanup.rb b/omnibus/config/software/more-ruby-cleanup.rb index f5af0501cd..f83e210512 100644 --- a/omnibus/config/software/more-ruby-cleanup.rb +++ b/omnibus/config/software/more-ruby-cleanup.rb @@ -24,6 +24,8 @@ license :project_license source path: "#{project.files_path}/#{name}" +dependency "ruby" + build do block "Removing console and setup binaries" do Dir.glob("#{install_dir}/embedded/lib/ruby/gems/*/gems/*/bin/{console,setup}").each do |f| @@ -31,9 +33,14 @@ build do FileUtils.rm_rf(f) end end -end -build do + block "remove any .gitkeep files" do + Dir.glob("#{install_dir}/**/{.gitkeep,.keep}").each do |f| + puts "Deleting #{f}" + File.delete(f) + end + end + block "Removing additional non-code files from installed gems" do # find the embedded ruby gems dir and clean it up for globbing target_dir = "#{install_dir}/embedded/lib/ruby/gems/*/gems".tr('\\', "/") diff --git a/omnibus/files/openssl-customization/windows/ssl_env_hack.rb b/omnibus/files/openssl-customization/windows/ssl_env_hack.rb index eaa5949f2d..b86c17db82 100644 --- a/omnibus/files/openssl-customization/windows/ssl_env_hack.rb +++ b/omnibus/files/openssl-customization/windows/ssl_env_hack.rb @@ -16,8 +16,8 @@ # # This script sets the SSL_CERT_FILE environment variable to the CA cert bundle -# that ships with omnibus packages of Chef and Chef DK. If this environment -# variable is already configured, this script is a no-op. +# that ships with omnibus packages of Chef Infra Client and Chef Workstation. If +# this environment variable is already configured, this script is a no-op. # # This is required to make Chef tools use https URLs out of the box. diff --git a/omnibus/omnibus.rb b/omnibus/omnibus.rb index e839174138..c04c3a87a0 100644 --- a/omnibus/omnibus.rb +++ b/omnibus/omnibus.rb @@ -1,5 +1,5 @@ # -# This file is used to configure the Omnibus projects in this repo. It contains +# This file is used to configure the Chef Infra Client project. It contains # some minimal configuration examples for working with Omnibus. For a full list # of configurable options, please see the documentation for +omnibus/config.rb+. # diff --git a/spec/functional/resource/aix_service_spec.rb b/spec/functional/resource/aix_service_spec.rb index 0bc3dd2aad..e7e6d0e822 100755 --- a/spec/functional/resource/aix_service_spec.rb +++ b/spec/functional/resource/aix_service_spec.rb @@ -18,7 +18,6 @@ # require "spec_helper" -require "functional/resource/base" require "chef/mixin/shell_out" shared_examples "src service" do @@ -80,6 +79,15 @@ describe Chef::Resource::Service, :requires_root, :aix_only do shell_out("id -u #{ENV["USER"]}").stdout.chomp end + let(:run_context) do + node = Chef::Node.new + node.default[:platform] = ohai[:platform] + node.default[:platform_version] = ohai[:platform_version] + node.default[:os] = ohai[:os] + events = Chef::EventDispatch::Dispatcher.new + Chef::RunContext.new(node, {}, events) + end + describe "When service is a subsystem" do before(:all) do script_dir = File.join(File.dirname(__FILE__), "/../assets/") diff --git a/spec/functional/resource/aixinit_service_spec.rb b/spec/functional/resource/aixinit_service_spec.rb index ed99472df3..bb89277e40 100755 --- a/spec/functional/resource/aixinit_service_spec.rb +++ b/spec/functional/resource/aixinit_service_spec.rb @@ -18,7 +18,6 @@ # require "spec_helper" -require "functional/resource/base" require "chef/mixin/shell_out" require "fileutils" @@ -57,6 +56,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do # Actual tests let(:new_resource) do + run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new) new_resource = Chef::Resource::Service.new("chefinittest", run_context) new_resource.provider Chef::Provider::Service::AixInit new_resource.supports({ status: true, restart: true, reload: true }) diff --git a/spec/functional/resource/base.rb b/spec/functional/resource/base.rb deleted file mode 100644 index df7eb3ed5d..0000000000 --- a/spec/functional/resource/base.rb +++ /dev/null @@ -1,28 +0,0 @@ -# -# Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>) -# Copyright:: Copyright (c) Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -def run_context - @run_context ||= begin - node = Chef::Node.new - node.default[:platform] = ohai[:platform] - node.default[:platform_version] = ohai[:platform_version] - node.default[:os] = ohai[:os] - events = Chef::EventDispatch::Dispatcher.new - Chef::RunContext.new(node, {}, events) - end -end diff --git a/spec/functional/resource/bash_spec.rb b/spec/functional/resource/bash_spec.rb index bc61bbd579..abb88f499f 100644 --- a/spec/functional/resource/bash_spec.rb +++ b/spec/functional/resource/bash_spec.rb @@ -17,11 +17,12 @@ # require "spec_helper" -require "functional/resource/base" describe Chef::Resource::Bash, :unix_only do let(:code) { "echo hello" } let(:resource) do + run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new) + resource = Chef::Resource::Bash.new("foo_resource", run_context) resource.code(code) unless code.nil? resource diff --git a/spec/functional/resource/bff_spec.rb b/spec/functional/resource/bff_spec.rb index 4368824067..ad45552c16 100644 --- a/spec/functional/resource/bff_spec.rb +++ b/spec/functional/resource/bff_spec.rb @@ -16,7 +16,6 @@ # limitations under the License. # -require "functional/resource/base" require "chef/mixin/shell_out" # Run the test only for AIX platform. @@ -24,6 +23,7 @@ describe Chef::Resource::BffPackage, :requires_root, external: ohai[:platform] ! include Chef::Mixin::ShellOut let(:new_resource) do + run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new) new_resource = Chef::Resource::BffPackage.new(@pkg_name, run_context) new_resource.source @pkg_path new_resource diff --git a/spec/functional/resource/chocolatey_package_spec.rb b/spec/functional/resource/chocolatey_package_spec.rb index e8b175f487..24975d2e01 100644 --- a/spec/functional/resource/chocolatey_package_spec.rb +++ b/spec/functional/resource/chocolatey_package_spec.rb @@ -25,6 +25,10 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do let(:package_list) { proc { powershell_out!("choco list -lo -r #{Array(package_name).join(" ")}").stdout.chomp } } let(:package_source) { File.join(CHEF_SPEC_ASSETS, "chocolatey_feed") } + let(:run_context) do + Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new) + end + subject do new_resource = Chef::Resource::ChocolateyPackage.new("test choco package", run_context) new_resource.package_name package_name diff --git a/spec/functional/resource/cron_spec.rb b/spec/functional/resource/cron_spec.rb index ed4905b980..bd75a86558 100644 --- a/spec/functional/resource/cron_spec.rb +++ b/spec/functional/resource/cron_spec.rb @@ -18,7 +18,6 @@ # require "spec_helper" -require "functional/resource/base" require "chef/mixin/shell_out" describe Chef::Resource::Cron, :requires_root, :unix_only do @@ -53,6 +52,16 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do end # Actual tests + + let(:run_context) do + node = Chef::Node.new + node.default[:platform] = ohai[:platform] + node.default[:platform_version] = ohai[:platform_version] + node.default[:os] = ohai[:os] + events = Chef::EventDispatch::Dispatcher.new + Chef::RunContext.new(node, {}, events) + end + let(:new_resource) do new_resource = Chef::Resource::Cron.new("Chef functional test cron", run_context) new_resource.user "root" diff --git a/spec/functional/resource/dnf_package_spec.rb b/spec/functional/resource/dnf_package_spec.rb index d8618a5dee..eef0d6296b 100644 --- a/spec/functional/resource/dnf_package_spec.rb +++ b/spec/functional/resource/dnf_package_spec.rb @@ -16,7 +16,6 @@ # require "spec_helper" -require "functional/resource/base" require "chef/mixin/shell_out" # run this test only for following platforms. @@ -66,6 +65,10 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do FileUtils.rm_f "/etc/yum.repos.d/chef-dnf-localtesting.repo" end + let(:run_context) do + Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new) + end + let(:package_name) { "chef_rpm" } let(:dnf_package) { Chef::Resource::DnfPackage.new(package_name, run_context) } diff --git a/spec/functional/resource/execute_spec.rb b/spec/functional/resource/execute_spec.rb index 874e2e5a41..3d7e185e17 100644 --- a/spec/functional/resource/execute_spec.rb +++ b/spec/functional/resource/execute_spec.rb @@ -17,11 +17,11 @@ # require "spec_helper" -require "functional/resource/base" require "timeout" describe Chef::Resource::Execute do let(:resource) do + run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new) resource = Chef::Resource::Execute.new("foo_resource", run_context) resource.command("echo hello") resource diff --git a/spec/functional/resource/group_spec.rb b/spec/functional/resource/group_spec.rb index 540e51f1e4..8fca689e68 100644 --- a/spec/functional/resource/group_spec.rb +++ b/spec/functional/resource/group_spec.rb @@ -18,7 +18,6 @@ # require "spec_helper" -require "functional/resource/base" require "chef/mixin/shell_out" describe Chef::Resource::Group, :requires_root_or_running_windows do @@ -113,6 +112,15 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do # TODO: User shouldn't exist end + let(:run_context) do + node = Chef::Node.new + node.default[:platform] = ohai[:platform] + node.default[:platform_version] = ohai[:platform_version] + node.default[:os] = ohai[:os] + events = Chef::EventDispatch::Dispatcher.new + Chef::RunContext.new(node, {}, events) + end + shared_examples_for "correct group management" do def add_members_to_group(members) temp_resource = group_resource.dup diff --git a/spec/functional/resource/ifconfig_spec.rb b/spec/functional/resource/ifconfig_spec.rb index a37dfac668..127e4e6331 100644 --- a/spec/functional/resource/ifconfig_spec.rb +++ b/spec/functional/resource/ifconfig_spec.rb @@ -17,7 +17,6 @@ # require "spec_helper" -require "functional/resource/base" require "chef/mixin/shell_out" # run this test only for following platforms. @@ -26,6 +25,15 @@ include_flag = !(%w{amazon debian aix}.include?(ohai[:platform_family]) || (ohai describe Chef::Resource::Ifconfig, :requires_root, :requires_ifconfig, external: include_flag do include Chef::Mixin::ShellOut + let(:run_context) do + node = Chef::Node.new + node.default[:platform] = ohai[:platform] + node.default[:platform_version] = ohai[:platform_version] + node.default[:os] = ohai[:os] + events = Chef::EventDispatch::Dispatcher.new + Chef::RunContext.new(node, {}, events) + end + let(:new_resource) do new_resource = Chef::Resource::Ifconfig.new("10.10.0.1", run_context) new_resource diff --git a/spec/functional/resource/insserv_spec.rb b/spec/functional/resource/insserv_spec.rb index 51ea064f32..788a46469b 100644 --- a/spec/functional/resource/insserv_spec.rb +++ b/spec/functional/resource/insserv_spec.rb @@ -18,7 +18,6 @@ # require "spec_helper" -require "functional/resource/base" require "chef/mixin/shell_out" require "fileutils" @@ -54,6 +53,8 @@ describe Chef::Resource::Service, :requires_root, :opensuse do # Actual tests let(:new_resource) do + run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new) + new_resource = Chef::Resource::Service.new("inittest", run_context) new_resource.provider Chef::Provider::Service::Insserv new_resource.supports({ status: true, restart: true, reload: true }) diff --git a/spec/functional/resource/link_spec.rb b/spec/functional/resource/link_spec.rb index 24a1f5cd7b..c9177ebc77 100644 --- a/spec/functional/resource/link_spec.rb +++ b/spec/functional/resource/link_spec.rb @@ -64,13 +64,10 @@ describe Chef::Resource::Link do end end - def node + def user(user) node = Chef::Node.new node.consume_external_attrs(ohai.data, {}) - node - end - - def user(user) + run_context = Chef::RunContext.new(node, {}, Chef::EventDispatch::Dispatcher.new) usr = Chef::Resource.resource_for_node(:user, node).new(user, run_context) usr.password("ComplexPass11!") if windows? usr diff --git a/spec/functional/resource/mount_spec.rb b/spec/functional/resource/mount_spec.rb index abaf74a506..55738a4326 100644 --- a/spec/functional/resource/mount_spec.rb +++ b/spec/functional/resource/mount_spec.rb @@ -17,7 +17,6 @@ # require "spec_helper" -require "functional/resource/base" require "chef/mixin/shell_out" require "tmpdir" @@ -101,6 +100,15 @@ describe Chef::Resource::Mount, :requires_root, external: include_flag do expect(shell_out("cat #{unix_mount_config_file}").stdout).not_to include("#{mount_point}:") end + let(:run_context) do + node = Chef::Node.new + node.default[:platform] = ohai[:platform] + node.default[:platform_version] = ohai[:platform_version] + node.default[:os] = ohai[:os] + events = Chef::EventDispatch::Dispatcher.new + Chef::RunContext.new(node, {}, events) + end + let(:new_resource) do new_resource = Chef::Resource::Mount.new(@mount_point, run_context) new_resource.device @device diff --git a/spec/functional/resource/msu_package_spec.rb b/spec/functional/resource/msu_package_spec.rb index 1161049571..2e6fcdcbca 100644 --- a/spec/functional/resource/msu_package_spec.rb +++ b/spec/functional/resource/msu_package_spec.rb @@ -26,11 +26,17 @@ describe Chef::Resource::MsuPackage, :win2012r2_only do let(:package_identity) { "Package_for_KB2959977~31bf3856ad364e35~amd64~~6.3.1.1" } let(:timeout) { 3600 } - let(:new_resource) { Chef::Resource::CabPackage.new("windows_test_pkg") } - let(:cab_provider) do + let(:run_context) do node = Chef::Node.new + node.default[:platform] = ohai[:platform] + node.default[:platform_version] = ohai[:platform_version] + node.default[:os] = ohai[:os] events = Chef::EventDispatch::Dispatcher.new - run_context = Chef::RunContext.new(node, {}, events) + Chef::RunContext.new(node, {}, events) + end + + let(:new_resource) { Chef::Resource::CabPackage.new("windows_test_pkg") } + let(:cab_provider) do Chef::Provider::Package::Cab.new(new_resource, run_context) end diff --git a/spec/functional/resource/rpm_spec.rb b/spec/functional/resource/rpm_spec.rb index 6e0c5a18cb..8a6cf32882 100644 --- a/spec/functional/resource/rpm_spec.rb +++ b/spec/functional/resource/rpm_spec.rb @@ -17,7 +17,6 @@ # require "spec_helper" -require "functional/resource/base" require "chef/mixin/shell_out" # run this test only for following platforms. @@ -26,6 +25,7 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do include Chef::Mixin::ShellOut let(:new_resource) do + run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new) new_resource = Chef::Resource::RpmPackage.new(@pkg_name, run_context) new_resource.source @pkg_path new_resource diff --git a/spec/functional/resource/timezone_spec.rb b/spec/functional/resource/timezone_spec.rb index d144bea284..d44d5b34a8 100644 --- a/spec/functional/resource/timezone_spec.rb +++ b/spec/functional/resource/timezone_spec.rb @@ -21,6 +21,8 @@ describe Chef::Resource::Timezone, :windows_only do let(:timezone) { "GMT Standard Time" } def timezone_resource + run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new) + Chef::Resource::Timezone.new(timezone, run_context) end diff --git a/spec/functional/resource/windows_package_spec.rb b/spec/functional/resource/windows_package_spec.rb index 3d75913ed1..3294e1c509 100644 --- a/spec/functional/resource/windows_package_spec.rb +++ b/spec/functional/resource/windows_package_spec.rb @@ -17,7 +17,6 @@ # require "spec_helper" -require "functional/resource/base" describe Chef::Resource::WindowsPackage, :windows_only, :volatile do let(:pkg_name) { nil } diff --git a/spec/functional/resource/windows_path_spec.rb b/spec/functional/resource/windows_path_spec.rb index 14e4ad8869..b2a3e5f5a4 100644 --- a/spec/functional/resource/windows_path_spec.rb +++ b/spec/functional/resource/windows_path_spec.rb @@ -21,6 +21,10 @@ require "spec_helper" describe Chef::Resource::WindowsPath, :windows_only do let(:path) { "test_path" } + let(:run_context) do + Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new) + end + before(:all) do @old_path = ENV["PATH"].dup end diff --git a/spec/functional/resource/windows_security_policy_spec.rb b/spec/functional/resource/windows_security_policy_spec.rb index cc225eec74..1a6b697bfa 100644 --- a/spec/functional/resource/windows_security_policy_spec.rb +++ b/spec/functional/resource/windows_security_policy_spec.rb @@ -17,7 +17,6 @@ # require "spec_helper" -require "functional/resource/base" require "chef/mixin/powershell_out" describe Chef::Resource::WindowsSecurityPolicy, :windows_only do diff --git a/spec/functional/resource/windows_service_spec.rb b/spec/functional/resource/windows_service_spec.rb index 195a974aa1..4c0c3acb58 100644 --- a/spec/functional/resource/windows_service_spec.rb +++ b/spec/functional/resource/windows_service_spec.rb @@ -62,6 +62,10 @@ describe Chef::Resource::WindowsService, :windows_only, :system_windows_service_ r end + let(:run_context) do + Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new) + end + before do user_resource.run_action(:create) diff --git a/spec/functional/resource/windows_task_spec.rb b/spec/functional/resource/windows_task_spec.rb index 84993cac0e..196e627272 100644 --- a/spec/functional/resource/windows_task_spec.rb +++ b/spec/functional/resource/windows_task_spec.rb @@ -25,12 +25,13 @@ describe Chef::Resource::WindowsTask, :windows_only do let(:task_name) { "chef-client-functional-test" } let(:new_resource) { Chef::Resource::WindowsTask.new(task_name) } let(:windows_task_provider) do - node = Chef::Node.new - events = Chef::EventDispatch::Dispatcher.new - run_context = Chef::RunContext.new(node, {}, events) Chef::Provider::WindowsTask.new(new_resource, run_context) end + let(:run_context) do + Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new) + end + describe "action :create" do after { delete_task } context "when command is with arguments" do diff --git a/spec/functional/resource/windows_user_privilege_spec.rb b/spec/functional/resource/windows_user_privilege_spec.rb index 115887e3e5..e30971d2e6 100644 --- a/spec/functional/resource/windows_user_privilege_spec.rb +++ b/spec/functional/resource/windows_user_privilege_spec.rb @@ -16,7 +16,6 @@ # require_relative "../../spec_helper" -require_relative "../../functional/resource/base" describe Chef::Resource::WindowsUserPrivilege, :windows_only do let(:principal) { nil } diff --git a/spec/functional/resource/yum_package_spec.rb b/spec/functional/resource/yum_package_spec.rb index 72e0a295b8..5f902cff17 100644 --- a/spec/functional/resource/yum_package_spec.rb +++ b/spec/functional/resource/yum_package_spec.rb @@ -16,7 +16,6 @@ # require "spec_helper" -require "functional/resource/base" require "chef/mixin/shell_out" # run this test only for following platforms. @@ -64,6 +63,10 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do FileUtils.rm_f "/etc/yum.repos.d/chef-yum-localtesting.repo" end + let(:run_context) do + Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new) + end + let(:package_name) { "chef_rpm" } let(:yum_package) do r = Chef::Resource::YumPackage.new(package_name, run_context) diff --git a/spec/functional/resource/zypper_package_spec.rb b/spec/functional/resource/zypper_package_spec.rb index 31168d9fe8..e56684b6f8 100644 --- a/spec/functional/resource/zypper_package_spec.rb +++ b/spec/functional/resource/zypper_package_spec.rb @@ -17,7 +17,6 @@ # require "spec_helper" -require "functional/resource/base" require "chef/mixin/shell_out" describe Chef::Resource::ZypperPackage, :requires_root, :suse_only do @@ -52,6 +51,10 @@ describe Chef::Resource::ZypperPackage, :requires_root, :suse_only do FileUtils.rm_f "/etc/zypp/repos.d/chef-zypp-localtesting.repo" end + let(:run_context) do + Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new) + end + let(:package_name) { "chef_rpm" } let(:zypper_package) do r = Chef::Resource::ZypperPackage.new(package_name, run_context) diff --git a/spec/functional/shell_spec.rb b/spec/functional/shell_spec.rb index d6dc6d8a08..583440d2b6 100644 --- a/spec/functional/shell_spec.rb +++ b/spec/functional/shell_spec.rb @@ -17,7 +17,6 @@ # require "spec_helper" -require "functional/resource/base" require "chef/version" require "chef/shell" diff --git a/spec/integration/recipes/recipe_dsl_spec.rb b/spec/integration/recipes/recipe_dsl_spec.rb index b939317c62..7db5599db5 100644 --- a/spec/integration/recipes/recipe_dsl_spec.rb +++ b/spec/integration/recipes/recipe_dsl_spec.rb @@ -1233,6 +1233,10 @@ describe "Recipe DSL methods" do before { Namer.current_index += 1 } context "with an LWRP that declares actions" do + let(:run_context) do + Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new) + end + let(:resource_class) do Class.new(Chef::Resource::LWRPBase) do provides :"recipe_dsl_spec#{Namer.current_index}" diff --git a/spec/support/shared/functional/securable_resource.rb b/spec/support/shared/functional/securable_resource.rb index 7bbd7d1666..26f2b1cc5a 100644 --- a/spec/support/shared/functional/securable_resource.rb +++ b/spec/support/shared/functional/securable_resource.rb @@ -19,7 +19,6 @@ # require "etc" -require "functional/resource/base" shared_context "setup correct permissions" do if windows? diff --git a/spec/support/shared/functional/securable_resource_with_reporting.rb b/spec/support/shared/functional/securable_resource_with_reporting.rb index abeb1ba4bb..6f816265bf 100644 --- a/spec/support/shared/functional/securable_resource_with_reporting.rb +++ b/spec/support/shared/functional/securable_resource_with_reporting.rb @@ -1,5 +1,4 @@ -require "functional/resource/base" ALL_EXPANDED_PERMISSIONS = ["generic read", "generic write", diff --git a/spec/unit/chef_fs/diff_spec.rb b/spec/unit/chef_fs/diff_spec.rb index 88cd6540e5..726adf8e50 100644 --- a/spec/unit/chef_fs/diff_spec.rb +++ b/spec/unit/chef_fs/diff_spec.rb @@ -26,10 +26,9 @@ describe "diff", uses_diff: true do # Removes the date stamp from the diff and replaces it with ' DATE' # example match: "/dev/null\t2012-10-16 16:15:54.000000000 +0000" # windows match: "--- /dev/null\tTue Oct 16 18:04:34 2012" - # https://rubular.com/r/5JdtZDqWnZhB9J def remove_os_differences(diff) diff = diff.gsub(/([+-]{3}.*)\t.*/, '\1 DATE') - diff.gsub(/^@@ -\d(,\d)? \+-?\d(,-?\d)? @@/, "CONTEXT_LINE_NUMBERS") + diff.gsub(/^@@ -\d(,\d)? \+\d(,\d)? @@/, "CONTEXT_LINE_NUMBERS") end context "with two filesystems with all types of difference" do diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb index 29a9945d8f..b0ddf30b28 100644 --- a/spec/unit/lwrp_spec.rb +++ b/spec/unit/lwrp_spec.rb @@ -653,14 +653,17 @@ describe "LWRP" do end end - let(:recipe) do + let(:run_context) do cookbook_repo = File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "cookbooks")) cookbook_loader = Chef::CookbookLoader.new(cookbook_repo) cookbook_loader.load_cookbooks cookbook_collection = Chef::CookbookCollection.new(cookbook_loader) node = Chef::Node.new events = Chef::EventDispatch::Dispatcher.new - run_context = Chef::RunContext.new(node, cookbook_collection, events) + Chef::RunContext.new(node, cookbook_collection, events) + end + + let(:recipe) do Chef::Recipe.new("hjk", "test", run_context) end diff --git a/spec/unit/provider/execute_spec.rb b/spec/unit/provider/execute_spec.rb index 000d8cebda..80bdb6a230 100644 --- a/spec/unit/provider/execute_spec.rb +++ b/spec/unit/provider/execute_spec.rb @@ -26,7 +26,7 @@ describe Chef::Provider::Execute do let(:provider) { Chef::Provider::Execute.new(new_resource, run_context) } let(:current_resource) { Chef::Resource::Ifconfig.new("foo_resource", run_context) } # You will be the same object, I promise. - @live_stream = Chef::EventDispatch::EventsOutputStream.new(run_context.events, name: :execute) + @live_stream = Chef::EventDispatch::EventsOutputStream.new(Chef::EventDispatch::Dispatcher.new, name: :execute) let(:opts) do { diff --git a/spec/unit/provider/mdadm_spec.rb b/spec/unit/provider/mdadm_spec.rb index 7e3546dcce..c0f6813afd 100644 --- a/spec/unit/provider/mdadm_spec.rb +++ b/spec/unit/provider/mdadm_spec.rb @@ -22,9 +22,7 @@ require "ostruct" describe Chef::Resource::Mdadm do before(:each) do - @node = Chef::Node.new - @events = Chef::EventDispatch::Dispatcher.new - @run_context = Chef::RunContext.new(@node, {}, @events) + run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new) @new_resource = Chef::Resource::Mdadm.new("/dev/md1", run_context) @new_resource.devices ["/dev/sdz1", "/dev/sdz2", "/dev/sdz3"] @provider = @new_resource.provider_for_action(:create) diff --git a/spec/unit/provider/windows_env_spec.rb b/spec/unit/provider/windows_env_spec.rb index 0e6cb02d48..5d14128230 100644 --- a/spec/unit/provider/windows_env_spec.rb +++ b/spec/unit/provider/windows_env_spec.rb @@ -20,14 +20,15 @@ require "spec_helper" describe Chef::Provider::WindowsEnv, :windows_only do + let(:run_context) do + Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new) + end + before do - @node = Chef::Node.new - @events = Chef::EventDispatch::Dispatcher.new - @run_context = Chef::RunContext.new(@node, {}, @events) @new_resource = Chef::Resource::WindowsEnv.new("FOO") @new_resource.value("bar") @new_resource.user("<System>") - @provider = Chef::Provider::WindowsEnv.new(@new_resource, @run_context) + @provider = Chef::Provider::WindowsEnv.new(@new_resource, run_context) end it "assumes the key_name exists by default" do diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index 5181414215..7a19e0e8e1 100644 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -1255,19 +1255,36 @@ describe Chef::Resource do expect(block_value).to eq(original_umask) end - it "changes the umask in the block to the set value" do - resource.umask = "0123" + if windows? + it "is a no-op on Windows" do + resource.umask = "0123" - block_value = nil + block_value = nil - resource.with_umask do - block_value = ::File.umask + resource.with_umask do + block_value = ::File.umask + end + + # Format the returned value so a potential error message is easier to understand. + actual_value = block_value.to_s(8).rjust(4, "0") + + expect(actual_value).to eq("0000") end + else + it "changes the umask in the block to the set value" do + resource.umask = "0123" + + block_value = nil - # Format the returned value so a potential error message is easier to understand. - actual_value = block_value.to_s(8).rjust(4, "0") + resource.with_umask do + block_value = ::File.umask + end - expect(actual_value).to eq("0123") + # Format the returned value so a potential error message is easier to understand. + actual_value = block_value.to_s(8).rjust(4, "0") + + expect(actual_value).to eq("0123") + end end it "resets the umask afterwards" do |