chef 16.9.32-universal-mingw32 → 16.13.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 -3
- data/Rakefile +11 -0
- data/chef-universal-mingw32.gemspec +1 -1
- data/chef.gemspec +1 -1
- data/distro/ruby_bin_folder/AMD64/Chef.PowerShell.Wrapper.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/Chef.PowerShell.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/Newtonsoft.Json.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.PowerShell.Wrapper.Core.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.pdb +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.NETCore.App.deps.json +153 -149
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Diagnostics.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Management.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Utility.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.ConsoleHost.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.CoreCLR.Eventing.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.MarkdownRender.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Security.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.WSMan.Management.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.WSMan.Runtime.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Newtonsoft.Json.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.Messages.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Drawing.Common.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Management.Automation.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Security.Cryptography.Pkcs.dll +0 -0
- data/distro/ruby_bin_folder/x86/Chef.PowerShell.dll +0 -0
- data/distro/ruby_bin_folder/x86/Chef.Powershell.Wrapper.dll +0 -0
- data/distro/ruby_bin_folder/x86/Newtonsoft.Json.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Chef.PowerShell.Wrapper.Core.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.pdb +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.NETCore.App.deps.json +153 -149
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Diagnostics.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Management.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Utility.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.ConsoleHost.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.CoreCLR.Eventing.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.MarkdownRender.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Security.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.WSMan.Management.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.WSMan.Runtime.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Newtonsoft.Json.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.Messages.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Drawing.Common.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Management.Automation.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Security.Cryptography.Pkcs.dll +0 -0
- data/lib/chef/compliance/default_attributes.rb +6 -2
- data/lib/chef/compliance/fetcher/automate.rb +15 -4
- data/lib/chef/compliance/runner.rb +8 -3
- data/lib/chef/dsl/reboot_pending.rb +1 -1
- data/lib/chef/file_access_control/windows.rb +4 -4
- data/lib/chef/file_cache.rb +4 -4
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +1 -1
- data/lib/chef/handler/json_file.rb +1 -1
- data/lib/chef/knife/bootstrap.rb +54 -4
- data/lib/chef/provider/file.rb +1 -1
- data/lib/chef/provider/mount.rb +7 -2
- data/lib/chef/provider/mount/mount.rb +1 -1
- data/lib/chef/provider/package.rb +2 -2
- data/lib/chef/provider/package/dnf/dnf_helper.py +5 -1
- data/lib/chef/provider/package/yum/yum_helper.py +4 -0
- data/lib/chef/provider/service/macosx.rb +3 -3
- data/lib/chef/resource.rb +27 -3
- data/lib/chef/resource/chef_client_cron.rb +1 -1
- data/lib/chef/resource/chef_client_launchd.rb +1 -1
- data/lib/chef/resource/windows_certificate.rb +47 -17
- data/lib/chef/resource_inspector.rb +5 -1
- data/lib/chef/shell.rb +2 -2
- data/lib/chef/util/dsc/configuration_generator.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/spec/functional/resource/cron_spec.rb +1 -1
- data/spec/integration/compliance/compliance_spec.rb +2 -1
- data/spec/integration/recipes/resource_action_spec.rb +14 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/platform_helpers.rb +4 -0
- data/spec/support/shared/unit/provider/file.rb +14 -0
- data/spec/unit/compliance/fetcher/automate_spec.rb +8 -0
- data/spec/unit/compliance/runner_spec.rb +54 -5
- data/spec/unit/dsl/reboot_pending_spec.rb +2 -2
- data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +2 -2
- data/spec/unit/knife/bootstrap_spec.rb +42 -3
- data/spec/unit/knife/supermarket_share_spec.rb +5 -6
- data/spec/unit/provider/mount/mount_spec.rb +52 -0
- data/spec/unit/provider/package/dnf/python_helper_spec.rb +7 -1
- data/spec/unit/provider/service/macosx_spec.rb +3 -3
- data/spec/unit/resource/chef_client_cron_spec.rb +8 -8
- data/spec/unit/resource_inspector_spec.rb +7 -2
- data/spec/unit/resource_spec.rb +46 -0
- metadata +15 -13
@@ -115,7 +115,7 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
|
|
115
115
|
# fake code to run through #recipe_snippet
|
116
116
|
source_file = [ "if true", "var = non_existent", "end" ]
|
117
117
|
allow(IO).to receive(:readlines).and_return(source_file)
|
118
|
-
allow(File).to receive(:
|
118
|
+
allow(File).to receive(:exist?).and_return(true)
|
119
119
|
end
|
120
120
|
|
121
121
|
it "parses a Windows path" do
|
@@ -141,7 +141,7 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
|
|
141
141
|
|
142
142
|
context "when the recipe file does not exist" do
|
143
143
|
before do
|
144
|
-
allow(File).to receive(:
|
144
|
+
allow(File).to receive(:exist?).and_return(false)
|
145
145
|
allow(IO).to receive(:readlines).and_raise(Errno::ENOENT)
|
146
146
|
end
|
147
147
|
|
@@ -1726,7 +1726,8 @@ describe Chef::Knife::Bootstrap do
|
|
1726
1726
|
|
1727
1727
|
describe "#perform_bootstrap" do
|
1728
1728
|
let(:exit_status) { 0 }
|
1729
|
-
let(:
|
1729
|
+
let(:stdout) { "" }
|
1730
|
+
let(:result_mock) { double("result", exit_status: exit_status, stderr: "A message", stdout: stdout) }
|
1730
1731
|
|
1731
1732
|
before do
|
1732
1733
|
allow(connection).to receive(:hostname).and_return "testhost"
|
@@ -1739,12 +1740,13 @@ describe Chef::Knife::Bootstrap do
|
|
1739
1740
|
expect(connection)
|
1740
1741
|
.to receive(:run_command)
|
1741
1742
|
.with("sh /path.sh")
|
1742
|
-
.and_yield("output here")
|
1743
|
+
.and_yield("output here", nil)
|
1743
1744
|
.and_return result_mock
|
1744
1745
|
|
1745
1746
|
expect(knife.ui).to receive(:msg).with(/testhost/)
|
1746
1747
|
knife.perform_bootstrap("/path.sh")
|
1747
1748
|
end
|
1749
|
+
|
1748
1750
|
context "when the remote command fails" do
|
1749
1751
|
let(:exit_status) { 1 }
|
1750
1752
|
it "shows an error and exits" do
|
@@ -1756,6 +1758,25 @@ describe Chef::Knife::Bootstrap do
|
|
1756
1758
|
expect { knife.perform_bootstrap("/path.sh") }.to raise_error(SystemExit)
|
1757
1759
|
end
|
1758
1760
|
end
|
1761
|
+
|
1762
|
+
context "when the remote command failed due to su auth error" do
|
1763
|
+
let(:exit_status) { 1 }
|
1764
|
+
let(:stdout) { "su: Authentication failure" }
|
1765
|
+
let(:connection_obj) { double("connection", transport_options: {}) }
|
1766
|
+
it "shows an error and exits" do
|
1767
|
+
allow(connection).to receive(:connection).and_return(connection_obj)
|
1768
|
+
expect(knife.ui).to receive(:info).with(/Bootstrapping.*/)
|
1769
|
+
expect(knife).to receive(:bootstrap_command)
|
1770
|
+
.with("/path.sh")
|
1771
|
+
.and_return("su - USER -c 'sh /path.sh'")
|
1772
|
+
expect(connection)
|
1773
|
+
.to receive(:run_command)
|
1774
|
+
.with("su - USER -c 'sh /path.sh'")
|
1775
|
+
.and_yield("output here", nil)
|
1776
|
+
.and_raise(Train::UserError)
|
1777
|
+
expect { knife.perform_bootstrap("/path.sh") }.to raise_error(Train::UserError)
|
1778
|
+
end
|
1779
|
+
end
|
1759
1780
|
end
|
1760
1781
|
|
1761
1782
|
describe "#connect!" do
|
@@ -1964,7 +1985,25 @@ describe Chef::Knife::Bootstrap do
|
|
1964
1985
|
context "under Linux" do
|
1965
1986
|
let(:linux_test) { true }
|
1966
1987
|
it "prefixes the command to run under sh" do
|
1967
|
-
expect(knife.bootstrap_command("bootstrap")).to eq "sh bootstrap"
|
1988
|
+
expect(knife.bootstrap_command("bootstrap.sh")).to eq "sh bootstrap.sh"
|
1989
|
+
end
|
1990
|
+
|
1991
|
+
context "with --su-user option" do
|
1992
|
+
let(:connection_obj) { double("connection", transport_options: {}) }
|
1993
|
+
before do
|
1994
|
+
knife.config[:su_user] = "root"
|
1995
|
+
allow(connection).to receive(:connection).and_return(connection_obj)
|
1996
|
+
end
|
1997
|
+
it "prefixes the command to run using su -USER -c" do
|
1998
|
+
expect(knife.bootstrap_command("bootstrap.sh")).to eq "su - #{knife.config[:su_user]} -c 'sh bootstrap.sh'"
|
1999
|
+
expect(connection_obj.transport_options.key?(:pty)).to eq true
|
2000
|
+
end
|
2001
|
+
|
2002
|
+
it "sudo appended if --sudo option enabled" do
|
2003
|
+
knife.config[:use_sudo] = true
|
2004
|
+
expect(knife.bootstrap_command("bootstrap.sh")).to eq "sudo su - #{knife.config[:su_user]} -c 'sh bootstrap.sh'"
|
2005
|
+
expect(connection_obj.transport_options.key?(:pty)).to eq true
|
2006
|
+
end
|
1968
2007
|
end
|
1969
2008
|
end
|
1970
2009
|
end
|
@@ -46,7 +46,9 @@ describe Chef::Knife::SupermarketShare do
|
|
46
46
|
|
47
47
|
allow(@knife).to receive(:shell_out!).and_return(true)
|
48
48
|
@stdout = StringIO.new
|
49
|
+
@stderr = StringIO.new
|
49
50
|
allow(@knife.ui).to receive(:stdout).and_return(@stdout)
|
51
|
+
allow(@knife.ui).to receive(:stderr).and_return(@stderr)
|
50
52
|
end
|
51
53
|
|
52
54
|
describe "run" do
|
@@ -140,7 +142,9 @@ describe Chef::Knife::SupermarketShare do
|
|
140
142
|
before do
|
141
143
|
allow(Chef::CookbookSiteStreamingUploader).to receive(:create_build_dir).and_return("/var/tmp/dummy")
|
142
144
|
@knife.config = { dry_run: true }
|
143
|
-
|
145
|
+
@so = instance_double("Mixlib::ShellOut")
|
146
|
+
allow(@knife).to receive(:shell_out!).and_return(@so)
|
147
|
+
allow(@so).to receive(:stdout).and_return("file")
|
144
148
|
end
|
145
149
|
|
146
150
|
it "should list files in the tarball" do
|
@@ -151,7 +155,6 @@ describe Chef::Knife::SupermarketShare do
|
|
151
155
|
end
|
152
156
|
|
153
157
|
it "does not upload the cookbook" do
|
154
|
-
allow(@knife).to receive(:shell_out!).and_return(true)
|
155
158
|
expect(@knife).not_to receive(:do_upload)
|
156
159
|
@knife.run
|
157
160
|
end
|
@@ -164,10 +167,6 @@ describe Chef::Knife::SupermarketShare do
|
|
164
167
|
@upload_response = double("Net::HTTPResponse")
|
165
168
|
allow(Chef::CookbookSiteStreamingUploader).to receive(:post).and_return(@upload_response)
|
166
169
|
|
167
|
-
@stdout = StringIO.new
|
168
|
-
@stderr = StringIO.new
|
169
|
-
allow(@knife.ui).to receive(:stdout).and_return(@stdout)
|
170
|
-
allow(@knife.ui).to receive(:stderr).and_return(@stderr)
|
171
170
|
allow(File).to receive(:open).and_return(true)
|
172
171
|
end
|
173
172
|
|
@@ -66,6 +66,7 @@ describe Chef::Provider::Mount::Mount do
|
|
66
66
|
|
67
67
|
describe "when dealing with network mounts" do
|
68
68
|
{ "nfs" => "nfsserver:/vol/path",
|
69
|
+
"cephfs" => "cephserver:6789:/",
|
69
70
|
"cifs" => "//cifsserver/share" }.each do |type, fs_spec|
|
70
71
|
it "should detect network fs_spec (#{type})" do
|
71
72
|
@new_resource.device fs_spec
|
@@ -505,6 +506,57 @@ describe Chef::Provider::Mount::Mount do
|
|
505
506
|
end
|
506
507
|
end
|
507
508
|
|
509
|
+
context "network mount" do
|
510
|
+
before(:each) do
|
511
|
+
@node = Chef::Node.new
|
512
|
+
@events = Chef::EventDispatch::Dispatcher.new
|
513
|
+
@run_context = Chef::RunContext.new(@node, {}, @events)
|
514
|
+
|
515
|
+
@new_resource = Chef::Resource::Mount.new("/tmp/bar")
|
516
|
+
@new_resource.device "cephserver:6789:/"
|
517
|
+
@new_resource.device_type :device
|
518
|
+
@new_resource.fstype "cephfs"
|
519
|
+
|
520
|
+
@new_resource.supports remount: false
|
521
|
+
|
522
|
+
@provider = Chef::Provider::Mount::Mount.new(@new_resource, @run_context)
|
523
|
+
|
524
|
+
allow(::File).to receive(:exists?).with("cephserver:6789:/").and_return true
|
525
|
+
allow(::File).to receive(:exists?).with("/tmp/bar").and_return true
|
526
|
+
allow(::File).to receive(:realpath).with("cephserver:6789:/").and_return "cephserver:6789:/"
|
527
|
+
allow(::File).to receive(:realpath).with("/tmp/bar").and_return "/tmp/foo"
|
528
|
+
end
|
529
|
+
|
530
|
+
before do
|
531
|
+
@current_resource = Chef::Resource::Mount.new("/tmp/foo")
|
532
|
+
@current_resource.device "cephserver:6789:/"
|
533
|
+
@current_resource.device_type :device
|
534
|
+
@current_resource.fstype "cephfs"
|
535
|
+
|
536
|
+
@provider.current_resource = @current_resource
|
537
|
+
end
|
538
|
+
|
539
|
+
it "should enable network mount if enabled isn't true" do
|
540
|
+
@current_resource.enabled(false)
|
541
|
+
|
542
|
+
@fstab = StringIO.new
|
543
|
+
allow(::File).to receive(:open).with("/etc/fstab", "a").and_yield(@fstab)
|
544
|
+
@provider.enable_fs
|
545
|
+
expect(@fstab.string).to match(%r{^cephserver:6789:/\s+/tmp/bar\s+cephfs\s+defaults\s+0\s+2\s*$})
|
546
|
+
end
|
547
|
+
|
548
|
+
it "should not enable network if enabled is true and resources match" do
|
549
|
+
@current_resource.enabled(true)
|
550
|
+
@current_resource.fstype("cephfs")
|
551
|
+
@current_resource.options(["defaults"])
|
552
|
+
@current_resource.dump(0)
|
553
|
+
@current_resource.pass(2)
|
554
|
+
expect(::File).not_to receive(:open).with("/etc/fstab", "a")
|
555
|
+
|
556
|
+
@provider.enable_fs
|
557
|
+
end
|
558
|
+
end
|
559
|
+
|
508
560
|
# the fstab might contain the mount with the device as a device but the resource has a label.
|
509
561
|
# we should not create two mount lines, but update the existing one
|
510
562
|
# not supported on solaris because it can't cope with a UUID device type
|
@@ -19,11 +19,17 @@ require "spec_helper"
|
|
19
19
|
|
20
20
|
# NOTE: most of the tests of this functionality are baked into the func tests for the dnf package provider
|
21
21
|
|
22
|
-
|
22
|
+
# run this test only for following platforms.
|
23
|
+
exclude_test = !(%w{rhel fedora amazon}.include?(ohai[:platform_family]) && File.exist?("/usr/bin/dnf"))
|
24
|
+
describe Chef::Provider::Package::Dnf::PythonHelper, :requires_root, external: exclude_test do
|
23
25
|
let(:helper) { Chef::Provider::Package::Dnf::PythonHelper.instance }
|
24
26
|
|
25
27
|
it "propagates stacktraces on stderr from the forked subprocess", :rhel do
|
26
28
|
allow(helper).to receive(:dnf_command).and_return("ruby -e 'raise \"your hands in the air\"'")
|
27
29
|
expect { helper.package_query(:whatprovides, "tcpdump") }.to raise_error(/your hands in the air/)
|
28
30
|
end
|
31
|
+
|
32
|
+
it "compares EVRAs with dots in the release correctly" do
|
33
|
+
expect(helper.compare_versions("0:1.8.29-6.el8.x86_64", "0:1.8.29-6.el8_3.1.x86_64")).to eql(-1)
|
34
|
+
end
|
29
35
|
end
|
@@ -78,7 +78,7 @@ describe Chef::Provider::Service::Macosx do
|
|
78
78
|
@getpwuid = double("Etc::Passwd", { name: "mikedodge04" })
|
79
79
|
allow(Etc).to receive(:getpwuid).and_return(@getpwuid)
|
80
80
|
allow(node).to receive(:[]).with("platform_version").and_return("10.11.1")
|
81
|
-
cmd = "launchctl list #{service_label}"
|
81
|
+
cmd = "/bin/launchctl list #{service_label}"
|
82
82
|
allow(provider).to receive(:shell_out)
|
83
83
|
.with(/(#{su_cmd} '#{cmd}'|#{cmd})/, default_env: false)
|
84
84
|
.and_return(double("Status",
|
@@ -265,7 +265,7 @@ describe Chef::Provider::Service::Macosx do
|
|
265
265
|
end
|
266
266
|
|
267
267
|
it "starts service via launchctl if service found" do
|
268
|
-
cmd = "launchctl load -w " + session + plist
|
268
|
+
cmd = "/bin/launchctl load -w " + session + plist
|
269
269
|
expect(provider).to receive(:shell_out)
|
270
270
|
.with(/(#{su_cmd} .#{cmd}.|#{cmd})/, default_env: false)
|
271
271
|
.and_return(0)
|
@@ -297,7 +297,7 @@ describe Chef::Provider::Service::Macosx do
|
|
297
297
|
end
|
298
298
|
|
299
299
|
it "stops the service via launchctl if service found" do
|
300
|
-
cmd = "launchctl unload -w " + plist
|
300
|
+
cmd = "/bin/launchctl unload -w " + plist
|
301
301
|
expect(provider).to receive(:shell_out)
|
302
302
|
.with(/(#{su_cmd} .#{cmd}.|#{cmd})/, default_env: false)
|
303
303
|
.and_return(0)
|
@@ -93,41 +93,41 @@ describe Chef::Resource::ChefClientCron do
|
|
93
93
|
|
94
94
|
it "creates a valid command if using all default properties" do
|
95
95
|
expect(provider.client_command).to eql(
|
96
|
-
"/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path}
|
96
|
+
"/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} >> /var/log/chef/client.log 2>&1"
|
97
97
|
)
|
98
98
|
end
|
99
99
|
|
100
100
|
it "uses daemon_options if set" do
|
101
101
|
resource.daemon_options ["--foo 1", "--bar 2"]
|
102
102
|
expect(provider.client_command).to eql(
|
103
|
-
"/bin/sleep 123; /opt/chef/bin/chef-client --foo 1 --bar 2 -c #{root_path}
|
103
|
+
"/bin/sleep 123; /opt/chef/bin/chef-client --foo 1 --bar 2 -c #{root_path} >> /var/log/chef/client.log 2>&1"
|
104
104
|
)
|
105
105
|
end
|
106
106
|
|
107
107
|
it "uses custom config dir if set" do
|
108
108
|
resource.config_directory "/etc/some_other_dir"
|
109
|
-
expect(provider.client_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client -c /etc/some_other_dir/client.rb
|
109
|
+
expect(provider.client_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client -c /etc/some_other_dir/client.rb >> /var/log/chef/client.log 2>&1")
|
110
110
|
end
|
111
111
|
|
112
112
|
it "uses custom log files / paths if set" do
|
113
113
|
resource.log_file_name "my-client.log"
|
114
114
|
resource.log_directory "/var/log/my-chef/"
|
115
115
|
expect(provider.client_command).to eql(
|
116
|
-
"/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path}
|
116
|
+
"/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} >> /var/log/my-chef/my-client.log 2>&1"
|
117
117
|
)
|
118
118
|
end
|
119
119
|
|
120
120
|
it "uses mailto if set" do
|
121
121
|
resource.mailto "bob@example.com"
|
122
122
|
expect(provider.client_command).to eql(
|
123
|
-
"/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path}
|
123
|
+
"/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} >> /var/log/chef/client.log 2>&1 || echo \"Chef Infra Client execution failed\""
|
124
124
|
)
|
125
125
|
end
|
126
126
|
|
127
127
|
it "uses custom chef-client binary if set" do
|
128
128
|
resource.chef_binary_path "/usr/local/bin/chef-client"
|
129
129
|
expect(provider.client_command).to eql(
|
130
|
-
"/bin/sleep 123; /usr/local/bin/chef-client -c #{root_path}
|
130
|
+
"/bin/sleep 123; /usr/local/bin/chef-client -c #{root_path} >> /var/log/chef/client.log 2>&1"
|
131
131
|
)
|
132
132
|
end
|
133
133
|
|
@@ -141,7 +141,7 @@ describe Chef::Resource::ChefClientCron do
|
|
141
141
|
it "sets the license acceptance flag if set" do
|
142
142
|
resource.accept_chef_license true
|
143
143
|
expect(provider.client_command).to eql(
|
144
|
-
"/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} --chef-license accept
|
144
|
+
"/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} --chef-license accept >> /var/log/chef/client.log 2>&1"
|
145
145
|
)
|
146
146
|
end
|
147
147
|
|
@@ -149,7 +149,7 @@ describe Chef::Resource::ChefClientCron do
|
|
149
149
|
allow(provider).to receive(:which).with("nice").and_return("/usr/bin/nice")
|
150
150
|
resource.nice(-15)
|
151
151
|
expect(provider.client_command).to eql(
|
152
|
-
"/bin/sleep 123; /usr/bin/nice -n -15 /opt/chef/bin/chef-client -c #{root_path}
|
152
|
+
"/bin/sleep 123; /usr/bin/nice -n -15 /opt/chef/bin/chef-client -c #{root_path} >> /var/log/chef/client.log 2>&1"
|
153
153
|
)
|
154
154
|
end
|
155
155
|
end
|
@@ -28,7 +28,11 @@ class DummyResource < Chef::Resource
|
|
28
28
|
introduced "14.0"
|
29
29
|
property :first, String, description: "My First Property", introduced: "14.0"
|
30
30
|
|
31
|
-
action :dummy do
|
31
|
+
action :dummy, description: "Dummy action" do
|
32
|
+
return true
|
33
|
+
end
|
34
|
+
|
35
|
+
action :dummy_no_desc do
|
32
36
|
return true
|
33
37
|
end
|
34
38
|
end
|
@@ -39,7 +43,8 @@ describe Chef::ResourceInspector do
|
|
39
43
|
|
40
44
|
it "returns a hash with required data" do
|
41
45
|
expect(subject[:description]).to eq "A dummy resource"
|
42
|
-
expect(subject[:actions]).to
|
46
|
+
expect(subject[:actions]).to eq({ nothing: nil, dummy: "Dummy action",
|
47
|
+
dummy_no_desc: nil })
|
43
48
|
end
|
44
49
|
|
45
50
|
context "excluding built in properties" do
|
data/spec/unit/resource_spec.rb
CHANGED
@@ -1162,6 +1162,52 @@ describe Chef::Resource do
|
|
1162
1162
|
end
|
1163
1163
|
end
|
1164
1164
|
|
1165
|
+
describe "#action_description" do
|
1166
|
+
class TestResource < ::Chef::Resource
|
1167
|
+
action :symbol_action, description: "a symbol test" do; end
|
1168
|
+
action "string_action", description: "a string test" do; end
|
1169
|
+
action :base_action0 do; end
|
1170
|
+
action :base_action1, description: "unmodified base action 1 desc" do; end
|
1171
|
+
action :base_action2, description: "unmodified base action 2 desc" do; end
|
1172
|
+
action :base_action3, description: "unmodified base action 3 desc" do; end
|
1173
|
+
end
|
1174
|
+
|
1175
|
+
it "returns nil when no description was provided for the action" do
|
1176
|
+
expect(TestResource.action_description(:base_action0)).to eql(nil)
|
1177
|
+
end
|
1178
|
+
|
1179
|
+
context "when action definition is a string" do
|
1180
|
+
it "returns the description whether a symbol or string is used to look it up" do
|
1181
|
+
expect(TestResource.action_description("string_action")).to eql("a string test")
|
1182
|
+
expect(TestResource.action_description(:string_action)).to eql("a string test")
|
1183
|
+
end
|
1184
|
+
end
|
1185
|
+
|
1186
|
+
context "when action definition is a symbol" do
|
1187
|
+
it "returns the description whether a symbol or string is used to look up" do
|
1188
|
+
expect(TestResource.action_description("symbol_action")).to eql("a symbol test")
|
1189
|
+
expect(TestResource.action_description(:symbol_action)).to eql("a symbol test")
|
1190
|
+
end
|
1191
|
+
end
|
1192
|
+
|
1193
|
+
context "when inheriting from an existing resource" do
|
1194
|
+
class TestResourceChild < TestResource
|
1195
|
+
action :base_action2, description: "modified base action 2 desc" do; end
|
1196
|
+
action :base_action3 do; end
|
1197
|
+
end
|
1198
|
+
|
1199
|
+
it "returns original description when a described action is not overridden in child resource" do
|
1200
|
+
expect(TestResourceChild.action_description(:base_action1)).to eq "unmodified base action 1 desc"
|
1201
|
+
end
|
1202
|
+
it "returns original description when the child resource overrides an inherited action but NOT its description" do
|
1203
|
+
expect(TestResourceChild.action_description(:base_action3)).to eq "unmodified base action 3 desc"
|
1204
|
+
end
|
1205
|
+
it "returns new description when the child resource overrides an inherited action and its description" do
|
1206
|
+
expect(TestResourceChild.action_description(:base_action2)).to eq "modified base action 2 desc"
|
1207
|
+
end
|
1208
|
+
end
|
1209
|
+
end
|
1210
|
+
|
1165
1211
|
describe ".default_action" do
|
1166
1212
|
let(:default_action) {}
|
1167
1213
|
let(:resource_class) do
|
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.
|
4
|
+
version: 16.13.16
|
5
5
|
platform: universal-mingw32
|
6
6
|
authors:
|
7
7
|
- Adam Jacob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-08 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.
|
19
|
+
version: 16.13.16
|
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.
|
26
|
+
version: 16.13.16
|
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.
|
33
|
+
version: 16.13.16
|
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.
|
40
|
+
version: 16.13.16
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: train-core
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -326,16 +326,16 @@ dependencies:
|
|
326
326
|
name: bcrypt_pbkdf
|
327
327
|
requirement: !ruby/object:Gem::Requirement
|
328
328
|
requirements:
|
329
|
-
- -
|
329
|
+
- - "~>"
|
330
330
|
- !ruby/object:Gem::Version
|
331
|
-
version: 1.1
|
331
|
+
version: '1.1'
|
332
332
|
type: :runtime
|
333
333
|
prerelease: false
|
334
334
|
version_requirements: !ruby/object:Gem::Requirement
|
335
335
|
requirements:
|
336
|
-
- -
|
336
|
+
- - "~>"
|
337
337
|
- !ruby/object:Gem::Version
|
338
|
-
version: 1.1
|
338
|
+
version: '1.1'
|
339
339
|
- !ruby/object:Gem::Dependency
|
340
340
|
name: highline
|
341
341
|
requirement: !ruby/object:Gem::Requirement
|
@@ -756,14 +756,14 @@ dependencies:
|
|
756
756
|
requirements:
|
757
757
|
- - "~>"
|
758
758
|
- !ruby/object:Gem::Version
|
759
|
-
version:
|
759
|
+
version: 0.5.0
|
760
760
|
type: :runtime
|
761
761
|
prerelease: false
|
762
762
|
version_requirements: !ruby/object:Gem::Requirement
|
763
763
|
requirements:
|
764
764
|
- - "~>"
|
765
765
|
- !ruby/object:Gem::Version
|
766
|
-
version:
|
766
|
+
version: 0.5.0
|
767
767
|
description: A systems integration framework, built to bring the benefits of configuration
|
768
768
|
management to your entire infrastructure.
|
769
769
|
email: adam@chef.io
|
@@ -852,6 +852,7 @@ files:
|
|
852
852
|
- distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.Contracts.dll
|
853
853
|
- distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.Debug.dll
|
854
854
|
- distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.DiagnosticSource.dll
|
855
|
+
- distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.Messages.dll
|
855
856
|
- distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.dll
|
856
857
|
- distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.FileVersionInfo.dll
|
857
858
|
- distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.Process.dll
|
@@ -1156,6 +1157,7 @@ files:
|
|
1156
1157
|
- distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.Contracts.dll
|
1157
1158
|
- distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.Debug.dll
|
1158
1159
|
- distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.DiagnosticSource.dll
|
1160
|
+
- distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.Messages.dll
|
1159
1161
|
- distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.dll
|
1160
1162
|
- distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.FileVersionInfo.dll
|
1161
1163
|
- distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.Process.dll
|
@@ -3555,7 +3557,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
3555
3557
|
- !ruby/object:Gem::Version
|
3556
3558
|
version: '0'
|
3557
3559
|
requirements: []
|
3558
|
-
rubygems_version: 3.1.
|
3560
|
+
rubygems_version: 3.1.6
|
3559
3561
|
signing_key:
|
3560
3562
|
specification_version: 4
|
3561
3563
|
summary: A systems integration framework, built to bring the benefits of configuration
|