chef 16.9.20-universal-mingw32 → 16.11.7-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -0
  3. data/chef-universal-mingw32.gemspec +1 -1
  4. data/chef.gemspec +11 -2
  5. data/lib/chef/compliance/default_attributes.rb +6 -2
  6. data/lib/chef/compliance/fetcher/automate.rb +15 -4
  7. data/lib/chef/compliance/runner.rb +11 -4
  8. data/lib/chef/dsl/reboot_pending.rb +1 -1
  9. data/lib/chef/file_access_control/windows.rb +4 -4
  10. data/lib/chef/file_cache.rb +4 -4
  11. data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +1 -1
  12. data/lib/chef/handler/json_file.rb +1 -1
  13. data/lib/chef/knife/bootstrap.rb +54 -4
  14. data/lib/chef/provider/mount/mount.rb +1 -1
  15. data/lib/chef/provider/package.rb +2 -2
  16. data/lib/chef/provider/package/dnf/dnf_helper.py +5 -1
  17. data/lib/chef/provider/package/yum/yum_helper.py +4 -0
  18. data/lib/chef/resource.rb +27 -3
  19. data/lib/chef/resource/chef_client_cron.rb +1 -1
  20. data/lib/chef/resource/windows_certificate.rb +47 -17
  21. data/lib/chef/resource_inspector.rb +5 -1
  22. data/lib/chef/shell.rb +32 -1
  23. data/lib/chef/util/dsc/configuration_generator.rb +1 -1
  24. data/lib/chef/version.rb +1 -1
  25. data/lib/chef/version_string.rb +1 -1
  26. data/spec/functional/resource/ohai_spec.rb +2 -10
  27. data/spec/integration/compliance/compliance_spec.rb +2 -1
  28. data/spec/integration/recipes/resource_action_spec.rb +14 -0
  29. data/spec/spec_helper.rb +1 -1
  30. data/spec/unit/compliance/fetcher/automate_spec.rb +8 -0
  31. data/spec/unit/compliance/runner_spec.rb +57 -9
  32. data/spec/unit/dsl/reboot_pending_spec.rb +2 -2
  33. data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +2 -2
  34. data/spec/unit/knife/bootstrap_spec.rb +42 -3
  35. data/spec/unit/knife/supermarket_share_spec.rb +5 -6
  36. data/spec/unit/provider/mount/mount_spec.rb +1 -0
  37. data/spec/unit/provider/package/dnf/python_helper_spec.rb +7 -1
  38. data/spec/unit/resource/chef_client_cron_spec.rb +8 -8
  39. data/spec/unit/resource_inspector_spec.rb +7 -2
  40. data/spec/unit/resource_spec.rb +46 -0
  41. metadata +20 -14
@@ -57,12 +57,12 @@ describe Chef::DSL::RebootPending do
57
57
  end
58
58
 
59
59
  it "should return true if /var/run/reboot-required exists" do
60
- allow(File).to receive(:exists?).with("/var/run/reboot-required").and_return(true)
60
+ allow(File).to receive(:exist?).with("/var/run/reboot-required").and_return(true)
61
61
  expect(recipe.reboot_pending?).to be_truthy
62
62
  end
63
63
 
64
64
  it "should return false if /var/run/reboot-required does not exist" do
65
- allow(File).to receive(:exists?).with("/var/run/reboot-required").and_return(false)
65
+ allow(File).to receive(:exist?).with("/var/run/reboot-required").and_return(false)
66
66
  expect(recipe.reboot_pending?).to be_falsey
67
67
  end
68
68
  end
@@ -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(:exists?).and_return(true)
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(:exists?).and_return(false)
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(:result_mock) { double("result", exit_status: exit_status, stderr: "A message") }
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
- allow(@knife).to receive_message_chain(:shell_out!, :stdout).and_return("file")
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
@@ -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
- describe Chef::Provider::Package::Dnf::PythonHelper do
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
@@ -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} -L /var/log/chef/client.log"
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} -L /var/log/chef/client.log"
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 -L /var/log/chef/client.log")
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} -L /var/log/my-chef/my-client.log"
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} -L /var/log/chef/client.log || echo \"Chef Infra Client execution failed\""
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} -L /var/log/chef/client.log"
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 -L /var/log/chef/client.log"
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} -L /var/log/chef/client.log"
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 match_array %i{nothing dummy}
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
@@ -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.9.20
4
+ version: 16.11.7
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-01-12 00:00:00.000000000 Z
11
+ date: 2021-03-17 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.9.20
19
+ version: 16.11.7
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.9.20
26
+ version: 16.11.7
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.9.20
33
+ version: 16.11.7
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.9.20
40
+ version: 16.11.7
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.0.rc2
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.0.rc2
338
+ version: '1.1'
339
339
  - !ruby/object:Gem::Dependency
340
340
  name: highline
341
341
  requirement: !ruby/object:Gem::Requirement
@@ -554,16 +554,22 @@ dependencies:
554
554
  name: uuidtools
555
555
  requirement: !ruby/object:Gem::Requirement
556
556
  requirements:
557
- - - "~>"
557
+ - - ">="
558
558
  - !ruby/object:Gem::Version
559
559
  version: 2.1.5
560
+ - - "<"
561
+ - !ruby/object:Gem::Version
562
+ version: '3.0'
560
563
  type: :runtime
561
564
  prerelease: false
562
565
  version_requirements: !ruby/object:Gem::Requirement
563
566
  requirements:
564
- - - "~>"
567
+ - - ">="
565
568
  - !ruby/object:Gem::Version
566
569
  version: 2.1.5
570
+ - - "<"
571
+ - !ruby/object:Gem::Version
572
+ version: '3.0'
567
573
  - !ruby/object:Gem::Dependency
568
574
  name: proxifier
569
575
  requirement: !ruby/object:Gem::Requirement
@@ -750,14 +756,14 @@ dependencies:
750
756
  requirements:
751
757
  - - "~>"
752
758
  - !ruby/object:Gem::Version
753
- version: '0.3'
759
+ version: 0.5.0
754
760
  type: :runtime
755
761
  prerelease: false
756
762
  version_requirements: !ruby/object:Gem::Requirement
757
763
  requirements:
758
764
  - - "~>"
759
765
  - !ruby/object:Gem::Version
760
- version: '0.3'
766
+ version: 0.5.0
761
767
  description: A systems integration framework, built to bring the benefits of configuration
762
768
  management to your entire infrastructure.
763
769
  email: adam@chef.io