chef 18.3.0 → 18.4.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -1
  3. data/chef.gemspec +2 -2
  4. data/lib/chef/chef_fs/file_pattern.rb +1 -1
  5. data/lib/chef/chef_fs/path_utils.rb +7 -9
  6. data/lib/chef/cookbook/synchronizer.rb +2 -3
  7. data/lib/chef/delayed_evaluator.rb +4 -0
  8. data/lib/chef/file_access_control/windows.rb +4 -1
  9. data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +2 -0
  10. data/lib/chef/mixin/homebrew_user.rb +6 -3
  11. data/lib/chef/monkey_patches/net-http.rb +5 -5
  12. data/lib/chef/node/attribute_collections.rb +2 -1
  13. data/lib/chef/node/immutable_collections.rb +2 -1
  14. data/lib/chef/node/mixin/state_tracking_array.rb +41 -0
  15. data/lib/chef/node.rb +23 -1
  16. data/lib/chef/provider/package/apt.rb +11 -2
  17. data/lib/chef/provider/package/chocolatey.rb +228 -24
  18. data/lib/chef/provider/package/zypper.rb +5 -0
  19. data/lib/chef/provider/powershell_script.rb +96 -6
  20. data/lib/chef/provider/service/systemd.rb +23 -8
  21. data/lib/chef/provider/service/windows.rb +1 -0
  22. data/lib/chef/provider/service.rb +14 -0
  23. data/lib/chef/provider/user.rb +5 -1
  24. data/lib/chef/recipe.rb +3 -11
  25. data/lib/chef/resource/_rest_resource.rb +1 -1
  26. data/lib/chef/resource/apt_package.rb +19 -0
  27. data/lib/chef/resource/apt_repository.rb +2 -1
  28. data/lib/chef/resource/chef_client_systemd_timer.rb +1 -1
  29. data/lib/chef/resource/chocolatey_installer.rb +207 -0
  30. data/lib/chef/resource/chocolatey_package.rb +8 -0
  31. data/lib/chef/resource/homebrew_package.rb +1 -1
  32. data/lib/chef/resource/locale.rb +5 -2
  33. data/lib/chef/resource/macos_pkg.rb +111 -0
  34. data/lib/chef/resource/powershell_script.rb +5 -1
  35. data/lib/chef/resource/service.rb +3 -0
  36. data/lib/chef/resource/sudo.rb +37 -2
  37. data/lib/chef/resource/support/ulimit.erb +40 -0
  38. data/lib/chef/resource/user_ulimit.rb +38 -0
  39. data/lib/chef/resources.rb +2 -0
  40. data/lib/chef/version.rb +1 -1
  41. data/spec/data/trusted_certs/example.crt +29 -20
  42. data/spec/data/trusted_certs/example_no_cn.crt +30 -34
  43. data/spec/functional/resource/chocolatey_package_spec.rb +2 -2
  44. data/spec/functional/resource/zypper_package_spec.rb +10 -0
  45. data/spec/unit/compliance/reporter/chef_server_automate_spec.rb +1 -1
  46. data/spec/unit/delayed_evaluator_spec.rb +35 -0
  47. data/spec/unit/node_spec.rb +6 -0
  48. data/spec/unit/provider/package/apt_spec.rb +18 -13
  49. data/spec/unit/provider/package/chocolatey_spec.rb +40 -12
  50. data/spec/unit/provider/powershell_script_spec.rb +100 -4
  51. data/spec/unit/provider/service/systemd_service_spec.rb +1 -0
  52. data/spec/unit/provider/user/linux_spec.rb +10 -0
  53. data/spec/unit/resource/chef_client_systemd_timer_spec.rb +1 -1
  54. data/spec/unit/resource/chocolatey_installer_spec.rb +151 -0
  55. data/spec/unit/resource/macos_pkg_spec.rb +38 -0
  56. data/spec/unit/resource/powershell_script_spec.rb +2 -2
  57. metadata +22 -10
@@ -102,7 +102,7 @@ describe Chef::Resource::ChefClientSystemdTimer do
102
102
 
103
103
  it "sets CPUQuota if cpu_quota property is set" do
104
104
  resource.cpu_quota 50
105
- expect(provider.service_content["Service"]["CPUQuota"]).to eq(50)
105
+ expect(provider.service_content["Service"]["CPUQuota"]).to eq("50%")
106
106
  end
107
107
  end
108
108
  end
@@ -0,0 +1,151 @@
1
+ #
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require "spec_helper"
19
+
20
+ describe Chef::Resource::ChocolateyInstaller do
21
+ include RecipeDSLHelper
22
+
23
+ let(:resource) { Chef::Resource::ChocolateyInstaller.new("fakey_fakerton") }
24
+ let(:config) do
25
+ <<-CONFIG
26
+ <?xml version="1.0" encoding="utf-8"?>
27
+ <chocolatey xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
28
+ <config>
29
+ <add key="containsLegacyPackageInstalls" value="true" description="Install has packages installed prior to 0.9.9 series." />
30
+ </config>
31
+ <sources>
32
+ <source id="chocolatey" value="https://chocolatey.org/api/v2/" disabled="false" bypassProxy="false" selfService="false" adminOnly="false" priority="0" />
33
+ </sources>
34
+ <features>
35
+ <feature name="checksumFiles" enabled="true" setExplicitly="false" description="Checksum files when pulled in from internet (based on package)." />
36
+ </features>
37
+ <apiKeys />
38
+ </chocolatey>
39
+ CONFIG
40
+ end
41
+
42
+ # we save off the ENV and set ALLUSERSPROFILE so these specs will work on *nix and non-C drive Windows installs
43
+ before(:each) do
44
+ @original_env = ENV.to_hash
45
+ ENV["ALLUSERSPROFILE"] = "C:\\ProgramData"
46
+ end
47
+
48
+ after(:each) do
49
+ ENV.clear
50
+ ENV.update(@original_env)
51
+ end
52
+
53
+ describe "Basic Resource Settings" do
54
+ context "on windows", :windows_only do
55
+ it "supports :install, :uninstall, :upgrade actions" do
56
+ expect { resource.action :install }.not_to raise_error
57
+ expect { resource.action :uninstall }.not_to raise_error
58
+ expect { resource.action :upgrade }.not_to raise_error
59
+ end
60
+ end
61
+ end
62
+
63
+ describe "Basic chocolatey settings" do
64
+ context "on windows", :windows_only do
65
+ it "has a resource name of :chocolatey_installer" do
66
+ expect(resource.resource_name).to eql(:chocolatey_installer)
67
+ end
68
+
69
+ it "sets the default action as :install" do
70
+ expect(resource.action).to eql([:install])
71
+ end
72
+
73
+ it "supports :install and :uninstall actions" do
74
+ expect { resource.action :install }.not_to raise_error
75
+ expect { resource.action :uninstall }.not_to raise_error
76
+ end
77
+
78
+ it "does not support bologna install options" do
79
+ expect { resource.action :foo }.to raise_error(Chef::Exceptions::ValidationFailed)
80
+ end
81
+ end
82
+ end
83
+
84
+ describe "Installing chocolatey" do
85
+ context "on windows", :windows_only do
86
+ it "can install Chocolatey with parameters" do
87
+ resource.chocolatey_version = "1.4.0"
88
+ expect { resource.action :install }.not_to raise_error
89
+ end
90
+
91
+ it "logs a warning if a chocolatey install cannot be found" do
92
+ allow(::File).to receive(:exist?).with('C:\ProgramData\chocolatey\bin\choco.exe').and_return(false)
93
+ expect { Chef::Log.warn("Chocolatey is already uninstalled.") }.not_to output.to_stderr
94
+ end
95
+ end
96
+ end
97
+
98
+ describe "Chocolatey is idempotent because" do
99
+ context "on windows", :windows_only do
100
+ it "it does not install choco again if it is already installed" do
101
+ install_choco
102
+ chocolatey_installer "install" do
103
+ action :install
104
+ end.should_not_be_updated
105
+ end
106
+ end
107
+ end
108
+
109
+ describe "upgrading choco versions" do
110
+
111
+ context "on windows", :windows_only do
112
+ describe "when the versions do not match" do
113
+ it "upgrades if the proposed version is newer" do
114
+ allow(resource).to receive(:get_choco_version).and_return(Gem::Version.new("1.2.2"))
115
+ allow(resource).to receive(:chocolatey_version).and_return(Gem::Version.new("4.2.2"))
116
+ expect { resource.action :upgrade }.not_to raise_error
117
+ allow(resource).to receive(:get_choco_version).and_return(Gem::Version.new("4.2.2"))
118
+ expect(resource.get_choco_version).to eql(Gem::Version.new("4.2.2"))
119
+ end
120
+ end
121
+ describe "when the versions match" do
122
+ it "does not upgrade if the old version is identical" do
123
+ allow(resource).to receive(:get_choco_version).and_return(Gem::Version.new("2.2.2"))
124
+ allow(resource).to receive(:chocolatey_version).and_return(Gem::Version.new("2.2.2"))
125
+ expect { resource.action :upgrade }.not_to raise_error
126
+ expect(resource).not_to be_updated
127
+ end
128
+ end
129
+ end
130
+ end
131
+
132
+ describe "Uninstalling chocolatey" do
133
+ context "on windows", :windows_only do
134
+ it "doesn't error out uninstalling chocolatey if chocolatey is not installed" do
135
+ allow(::File).to receive(:exist?).with('C:\ProgramData\chocolatey\bin\choco.exe').and_return(false)
136
+ expect { resource.action :uninstall }.not_to raise_error
137
+ end
138
+ end
139
+ end
140
+
141
+ def install_choco
142
+ require "chef-powershell"
143
+ include ChefPowerShell::ChefPowerShellModule::PowerShellExec
144
+ powershell_code = <<-CODE
145
+ Set-ExecutionPolicy Bypass -Scope Process -Force;
146
+ [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
147
+ iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
148
+ CODE
149
+ powershell_exec(powershell_code)
150
+ end
151
+ end
@@ -0,0 +1,38 @@
1
+ #
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require "spec_helper"
19
+
20
+ describe Chef::Resource::MacosPkg do
21
+ let(:resource) { Chef::Resource::MacosPkg.new("fakey_fakerton") }
22
+
23
+ it "has a resource name of :macos_pkg" do
24
+ expect(resource.resource_name).to eql(:macos_pkg)
25
+ end
26
+
27
+ it "sets the default action as :install" do
28
+ expect(resource.action).to eql([:install])
29
+ end
30
+
31
+ it "supports :install action" do
32
+ expect { resource.action :install }.not_to raise_error
33
+ end
34
+
35
+ it "target property defaults to /" do
36
+ expect(resource.target).to eql("/")
37
+ end
38
+ end
@@ -47,9 +47,9 @@ describe Chef::Resource::PowershellScript do
47
47
  expect(resource.convert_boolean_return).to eq(false)
48
48
  end
49
49
 
50
- it "inherits exactly the :cwd, :domain, :environment, :group, :password, :path, :user, :umask, :architecture, :elevated, :interpreter, :login properties from a parent resource class" do
50
+ it "inherits exactly the :cwd, :domain, :environment, :group, :password, :path, :user, :umask, :architecture, :elevated, :interpreter, :login, :use_inline_powershell properties from a parent resource class" do
51
51
  inherited_difference = Chef::Resource::PowershellScript.guard_inherited_attributes -
52
- %i{cwd domain environment group password path user umask architecture elevated interpreter login}
52
+ %i{cwd domain environment group password path user umask architecture elevated interpreter login use_inline_powershell}
53
53
 
54
54
  expect(inherited_difference).to eq([])
55
55
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 18.3.0
4
+ version: 18.4.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-29 00:00:00.000000000 Z
11
+ date: 2024-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 18.3.0
19
+ version: 18.4.12
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 18.3.0
26
+ version: 18.4.12
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: chef-utils
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 18.3.0
33
+ version: 18.4.12
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 18.3.0
40
+ version: 18.4.12
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: train-core
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -221,6 +221,9 @@ dependencies:
221
221
  - - ">="
222
222
  - !ruby/object:Gem::Version
223
223
  version: '5'
224
+ - - "<"
225
+ - !ruby/object:Gem::Version
226
+ version: '6'
224
227
  type: :runtime
225
228
  prerelease: false
226
229
  version_requirements: !ruby/object:Gem::Requirement
@@ -228,6 +231,9 @@ dependencies:
228
231
  - - ">="
229
232
  - !ruby/object:Gem::Version
230
233
  version: '5'
234
+ - - "<"
235
+ - !ruby/object:Gem::Version
236
+ version: '6'
231
237
  - !ruby/object:Gem::Dependency
232
238
  name: ffi
233
239
  requirement: !ruby/object:Gem::Requirement
@@ -458,14 +464,14 @@ dependencies:
458
464
  name: unf_ext
459
465
  requirement: !ruby/object:Gem::Requirement
460
466
  requirements:
461
- - - ">="
467
+ - - "~>"
462
468
  - !ruby/object:Gem::Version
463
469
  version: 0.0.8.2
464
470
  type: :runtime
465
471
  prerelease: false
466
472
  version_requirements: !ruby/object:Gem::Requirement
467
473
  requirements:
468
- - - ">="
474
+ - - "~>"
469
475
  - !ruby/object:Gem::Version
470
476
  version: 0.0.8.2
471
477
  - !ruby/object:Gem::Dependency
@@ -871,6 +877,7 @@ files:
871
877
  - lib/chef/node/mixin/immutablize_hash.rb
872
878
  - lib/chef/node/mixin/mashy_array.rb
873
879
  - lib/chef/node/mixin/state_tracking.rb
880
+ - lib/chef/node/mixin/state_tracking_array.rb
874
881
  - lib/chef/node_map.rb
875
882
  - lib/chef/null_logger.rb
876
883
  - lib/chef/org.rb
@@ -1056,6 +1063,7 @@ files:
1056
1063
  - lib/chef/resource/chef_vault_secret.rb
1057
1064
  - lib/chef/resource/chocolatey_config.rb
1058
1065
  - lib/chef/resource/chocolatey_feature.rb
1066
+ - lib/chef/resource/chocolatey_installer.rb
1059
1067
  - lib/chef/resource/chocolatey_package.rb
1060
1068
  - lib/chef/resource/chocolatey_source.rb
1061
1069
  - lib/chef/resource/conditional.rb
@@ -1109,6 +1117,7 @@ files:
1109
1117
  - lib/chef/resource/locale.rb
1110
1118
  - lib/chef/resource/log.rb
1111
1119
  - lib/chef/resource/lwrp_base.rb
1120
+ - lib/chef/resource/macos_pkg.rb
1112
1121
  - lib/chef/resource/macos_userdefaults.rb
1113
1122
  - lib/chef/resource/macosx_service.rb
1114
1123
  - lib/chef/resource/macports_package.rb
@@ -1988,6 +1997,7 @@ files:
1988
1997
  - spec/unit/decorator/lazy_array_spec.rb
1989
1998
  - spec/unit/decorator/lazy_spec.rb
1990
1999
  - spec/unit/decorator_spec.rb
2000
+ - spec/unit/delayed_evaluator_spec.rb
1991
2001
  - spec/unit/deprecated_spec.rb
1992
2002
  - spec/unit/deprecation_spec.rb
1993
2003
  - spec/unit/digester_spec.rb
@@ -2233,6 +2243,7 @@ files:
2233
2243
  - spec/unit/resource/chef_vault_secret_spec.rb
2234
2244
  - spec/unit/resource/chocolatey_config_spec.rb
2235
2245
  - spec/unit/resource/chocolatey_feature_spec.rb
2246
+ - spec/unit/resource/chocolatey_installer_spec.rb
2236
2247
  - spec/unit/resource/chocolatey_package_spec.rb
2237
2248
  - spec/unit/resource/chocolatey_source_spec.rb
2238
2249
  - spec/unit/resource/conditional_action_not_nothing_spec.rb
@@ -2275,6 +2286,7 @@ files:
2275
2286
  - spec/unit/resource/link_spec.rb
2276
2287
  - spec/unit/resource/locale_spec.rb
2277
2288
  - spec/unit/resource/log_spec.rb
2289
+ - spec/unit/resource/macos_pkg_spec.rb
2278
2290
  - spec/unit/resource/macos_user_defaults_spec.rb
2279
2291
  - spec/unit/resource/macosx_service.rb
2280
2292
  - spec/unit/resource/macports_package_spec.rb
@@ -2459,14 +2471,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
2459
2471
  requirements:
2460
2472
  - - ">="
2461
2473
  - !ruby/object:Gem::Version
2462
- version: 3.1.0
2474
+ version: 3.0.3
2463
2475
  required_rubygems_version: !ruby/object:Gem::Requirement
2464
2476
  requirements:
2465
2477
  - - ">="
2466
2478
  - !ruby/object:Gem::Version
2467
2479
  version: '0'
2468
2480
  requirements: []
2469
- rubygems_version: 3.3.7
2481
+ rubygems_version: 3.2.32
2470
2482
  signing_key:
2471
2483
  specification_version: 4
2472
2484
  summary: A systems integration framework, built to bring the benefits of configuration