chef 16.5.77 → 16.6.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/lib/chef/application/client.rb +6 -1
  4. data/lib/chef/client.rb +2 -31
  5. data/lib/chef/data_collector.rb +1 -1
  6. data/lib/chef/mixin/powershell_exec.rb +22 -10
  7. data/lib/chef/mixin/powershell_out.rb +12 -5
  8. data/lib/chef/node/mixin/immutablize_hash.rb +2 -0
  9. data/lib/chef/powershell.rb +3 -2
  10. data/lib/chef/provider/ifconfig.rb +1 -1
  11. data/lib/chef/provider/ifconfig/debian.rb +33 -15
  12. data/lib/chef/provider/ifconfig/redhat.rb +51 -17
  13. data/lib/chef/provider/powershell_script.rb +12 -1
  14. data/lib/chef/pwsh.rb +64 -0
  15. data/lib/chef/resource/apt_repository.rb +2 -3
  16. data/lib/chef/resource/chef_client_config.rb +313 -0
  17. data/lib/chef/resource/chef_client_cron.rb +5 -5
  18. data/lib/chef/resource/chef_client_scheduled_task.rb +4 -4
  19. data/lib/chef/resource/chef_client_systemd_timer.rb +5 -5
  20. data/lib/chef/resource/chef_sleep.rb +1 -1
  21. data/lib/chef/resource/cron/cron_d.rb +2 -2
  22. data/lib/chef/resource/kernel_module.rb +1 -1
  23. data/lib/chef/resource/launchd.rb +15 -15
  24. data/lib/chef/resource/mount.rb +1 -1
  25. data/lib/chef/resource/powershell_script.rb +7 -1
  26. data/lib/chef/resource/support/client.erb +65 -0
  27. data/lib/chef/resource/windows_audit_policy.rb +26 -24
  28. data/lib/chef/resources.rb +1 -0
  29. data/lib/chef/version.rb +1 -1
  30. data/spec/functional/mixin/powershell_out_spec.rb +9 -1
  31. data/spec/functional/resource/powershell_script_spec.rb +57 -14
  32. data/spec/spec_helper.rb +1 -0
  33. data/spec/support/platform_helpers.rb +6 -1
  34. data/spec/unit/mixin/powershell_exec_spec.rb +40 -3
  35. data/spec/unit/mixin/powershell_out_spec.rb +14 -0
  36. data/spec/unit/provider/powershell_script_spec.rb +11 -0
  37. data/spec/unit/resource/chef_client_config_spec.rb +137 -0
  38. data/spec/unit/resource/powershell_script_spec.rb +2 -2
  39. metadata +11 -7
@@ -44,6 +44,20 @@ describe Chef::Mixin::PowershellOut, :windows_only do
44
44
  expect(object.powershell_out("Get-Process", timeout: 600)).to eql(ret)
45
45
  end
46
46
 
47
+ it "uses pwsh.exe when given :pwsh interpreter" do
48
+ ret = double("Mixlib::ShellOut")
49
+ expect(object).to receive(:shell_out).with(
50
+ "pwsh.exe #{flags} -Command \"Get-Process\"",
51
+ timeout: 600
52
+ ).and_return(ret)
53
+ expect(object.powershell_out("Get-Process", :pwsh, timeout: 600)).to eql(ret)
54
+ end
55
+
56
+ it "raises error if interpreter is invalid" do
57
+ ret = double("Mixlib::ShellOut")
58
+ expect { object.powershell_out("Get-Process", :blah, timeout: 600) }.to raise_error(ArgumentError)
59
+ end
60
+
47
61
  context "when double quote is passed in the powershell command" do
48
62
  it "passes if double quote is appended with single escape" do
49
63
  result = object.powershell_out("Write-Verbose \"Some String\" -Verbose")
@@ -46,5 +46,16 @@ describe Chef::Provider::PowershellScript, "action_run" do
46
46
 
47
47
  expect(provider.command).to eq(expected)
48
48
  end
49
+
50
+ it "uses pwsh when given the pwsh interpreter" do
51
+ new_resource.interpreter = "pwsh"
52
+ provider.send(:script_file_path=, "C:\\Temp\\Script.ps1")
53
+
54
+ expected = <<~CMD.strip
55
+ "pwsh" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None -File "C:\\Temp\\Script.ps1"
56
+ CMD
57
+
58
+ expect(provider.command).to eq(expected)
59
+ end
49
60
  end
50
61
  end
@@ -0,0 +1,137 @@
1
+ #
2
+ # Author:: Tim Smith (<tsmith@chef.io>)
3
+ # Copyright:: Copyright (c) Chef Software Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require "spec_helper"
20
+
21
+ describe Chef::Resource::ChefClientConfig do
22
+ let(:node) { Chef::Node.new }
23
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
24
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
25
+ let(:resource) { Chef::Resource::ChefClientConfig.new("fakey_fakerton", run_context) }
26
+ let(:provider) { resource.provider_for_action(:create) }
27
+
28
+ it "sets the default action as :create" do
29
+ expect(resource.action).to eql([:create])
30
+ end
31
+
32
+ it "supports :create and :remove actions" do
33
+ expect { resource.action :create }.not_to raise_error
34
+ expect { resource.action :remove }.not_to raise_error
35
+ end
36
+
37
+ describe "ssl_verify_mode property" do
38
+ it "coerces String to Symbol" do
39
+ resource.ssl_verify_mode "verify_peer"
40
+ expect(resource.ssl_verify_mode).to eql(:verify_peer)
41
+ end
42
+
43
+ it "coerces Symbol-like String to Symbol" do
44
+ resource.ssl_verify_mode ":verify_peer"
45
+ expect(resource.ssl_verify_mode).to eql(:verify_peer)
46
+ end
47
+
48
+ it "raises an error if it is not an allowed value" do
49
+ expect { resource.ssl_verify_mode("foo") }.to raise_error(Chef::Exceptions::ValidationFailed)
50
+ expect { resource.ssl_verify_mode(:verify_none) }.not_to raise_error
51
+ expect { resource.ssl_verify_mode(:verify_peer) }.not_to raise_error
52
+ end
53
+ end
54
+
55
+ describe "no_proxy property" do
56
+ it "coerces Array into comma separated list" do
57
+ resource.no_proxy ["something.com", "example.com"]
58
+ expect(resource.no_proxy).to eql("something.com,example.com")
59
+ end
60
+
61
+ it "accepts String of comma separated values" do
62
+ resource.no_proxy "something.com,example.com"
63
+ expect(resource.no_proxy).to eql("something.com,example.com")
64
+ end
65
+ end
66
+
67
+ describe "ohai_disabled_plugins property" do
68
+ it "coerces String values into capitalized symbols" do
69
+ resource.ohai_disabled_plugins %w{foo Bar}
70
+ expect(resource.ohai_disabled_plugins).to eql(%i{Foo Bar})
71
+ end
72
+
73
+ it "coerces symbol-like string values into capitalized Symbols" do
74
+ resource.ohai_disabled_plugins [":foo", ":Bar"]
75
+ expect(resource.ohai_disabled_plugins).to eql(%i{Foo Bar})
76
+ end
77
+
78
+ it "coerces Symbol values into capitalized Symbols" do
79
+ resource.ohai_disabled_plugins %i{foo Bar}
80
+ expect(resource.ohai_disabled_plugins).to eql(%i{Foo Bar})
81
+ end
82
+ end
83
+
84
+ describe "ohai_optional_plugins property" do
85
+ it "coerces String values into capitalized symbols" do
86
+ resource.ohai_optional_plugins %w{foo Bar}
87
+ expect(resource.ohai_optional_plugins).to eql(%i{Foo Bar})
88
+ end
89
+
90
+ it "coerces symbol-like string values into capitalized Symbols" do
91
+ resource.ohai_optional_plugins [":foo", ":Bar"]
92
+ expect(resource.ohai_optional_plugins).to eql(%i{Foo Bar})
93
+ end
94
+
95
+ it "coerces Symbol values into capitalized Symbols" do
96
+ resource.ohai_optional_plugins %i{foo Bar}
97
+ expect(resource.ohai_optional_plugins).to eql(%i{Foo Bar})
98
+ end
99
+ end
100
+
101
+ describe "log_level property" do
102
+ it "accepts auto trace debug info warn fatal" do
103
+ expect { resource.log_level(:auto) }.not_to raise_error
104
+ expect { resource.log_level(:trace) }.not_to raise_error
105
+ expect { resource.log_level(:debug) }.not_to raise_error
106
+ expect { resource.log_level(:info) }.not_to raise_error
107
+ expect { resource.log_level(:warn) }.not_to raise_error
108
+ end
109
+
110
+ it "raises an error if an invalid value is passed" do
111
+ expect { resource.log_level(":foo") }.to raise_error(Chef::Exceptions::ValidationFailed)
112
+ end
113
+ end
114
+
115
+ describe "log_location property" do
116
+ it "accepts a String logfile location" do
117
+ expect { resource.log_location("/foo/bar/") }.not_to raise_error
118
+ end
119
+
120
+ it "accepts a String form of STDOUT/STDERR" do
121
+ expect { resource.log_location("STDOUT") }.not_to raise_error
122
+ expect { resource.log_location("STDERR") }.not_to raise_error
123
+ end
124
+
125
+ it "accepts :syslog or :win_evt Symbols" do
126
+ expect { resource.log_location(:syslog) }.not_to raise_error
127
+ expect { resource.log_location(:win_evt) }.not_to raise_error
128
+ expect { resource.log_location(:nope) }.to raise_error(Chef::Exceptions::ValidationFailed)
129
+ end
130
+ end
131
+
132
+ describe "#format_handler" do
133
+ it "provides an array of handler object creation code" do
134
+ expect(provider.format_handler([{ "class" => "Foo", "arguments" => ["'one'", "two", "three"] }])).to eql(["Foo.new('one',two,three)"])
135
+ end
136
+ end
137
+ end
@@ -53,9 +53,9 @@ describe Chef::Resource::PowershellScript do
53
53
  allow(resource).to receive(:updated).and_return(true)
54
54
  end
55
55
 
56
- it "inherits exactly the :cwd, :environment, :group, :path, :user, :umask, :architecture, :elevated properties from a parent resource class" do
56
+ it "inherits exactly the :cwd, :environment, :group, :path, :user, :umask, :architecture, :elevated, :interpreter properties from a parent resource class" do
57
57
  inherited_difference = Chef::Resource::PowershellScript.guard_inherited_attributes -
58
- %i{cwd environment group path user umask architecture elevated}
58
+ %i{cwd environment group path user umask architecture elevated interpreter}
59
59
 
60
60
  expect(inherited_difference).to eq([])
61
61
  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: 16.5.77
4
+ version: 16.6.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-28 00:00:00.000000000 Z
11
+ date: 2020-10-14 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: 16.5.77
19
+ version: 16.6.14
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: 16.5.77
26
+ version: 16.6.14
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: 16.5.77
33
+ version: 16.6.14
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: 16.5.77
40
+ version: 16.6.14
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: train-core
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -1224,6 +1224,7 @@ files:
1224
1224
  - lib/chef/provider/zypper_repository.rb
1225
1225
  - lib/chef/provider_resolver.rb
1226
1226
  - lib/chef/providers.rb
1227
+ - lib/chef/pwsh.rb
1227
1228
  - lib/chef/recipe.rb
1228
1229
  - lib/chef/request_id.rb
1229
1230
  - lib/chef/reserved_names.rb
@@ -1241,6 +1242,7 @@ files:
1241
1242
  - lib/chef/resource/breakpoint.rb
1242
1243
  - lib/chef/resource/build_essential.rb
1243
1244
  - lib/chef/resource/cab_package.rb
1245
+ - lib/chef/resource/chef_client_config.rb
1244
1246
  - lib/chef/resource/chef_client_cron.rb
1245
1247
  - lib/chef/resource/chef_client_launchd.rb
1246
1248
  - lib/chef/resource/chef_client_scheduled_task.rb
@@ -1344,6 +1346,7 @@ files:
1344
1346
  - lib/chef/resource/solaris_package.rb
1345
1347
  - lib/chef/resource/ssh_known_hosts_entry.rb
1346
1348
  - lib/chef/resource/sudo.rb
1349
+ - lib/chef/resource/support/client.erb
1347
1350
  - lib/chef/resource/support/cron.d.erb
1348
1351
  - lib/chef/resource/support/cron_access.erb
1349
1352
  - lib/chef/resource/support/ssh_known_hosts.erb
@@ -2520,6 +2523,7 @@ files:
2520
2523
  - spec/unit/resource/breakpoint_spec.rb
2521
2524
  - spec/unit/resource/build_essential_spec.rb
2522
2525
  - spec/unit/resource/cab_package_spec.rb
2526
+ - spec/unit/resource/chef_client_config_spec.rb
2523
2527
  - spec/unit/resource/chef_client_cron_spec.rb
2524
2528
  - spec/unit/resource/chef_client_launchd_spec.rb
2525
2529
  - spec/unit/resource/chef_client_scheduled_task_spec.rb
@@ -2737,7 +2741,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
2737
2741
  - !ruby/object:Gem::Version
2738
2742
  version: '0'
2739
2743
  requirements: []
2740
- rubygems_version: 3.1.2
2744
+ rubygems_version: 3.1.4
2741
2745
  signing_key:
2742
2746
  specification_version: 4
2743
2747
  summary: A systems integration framework, built to bring the benefits of configuration