chef 12.21.14 → 12.21.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: badf5e8bd4f99974685e95fb2456c1448eb8847f
4
- data.tar.gz: c84f02357be9848521807397383bb5e98f5674c1
3
+ metadata.gz: de64cfb4b80687fd5b8ecaceefd8a3235ca46c1f
4
+ data.tar.gz: b3b0cf0dbe5aaa840f5411d4cc40f590b6ccc919
5
5
  SHA512:
6
- metadata.gz: 8d08b95da842e485c54b2a5d8c7aab24e170eda8b485a16232eed37da82f7eb8ad05ea5ec2a2ac28b854619cb4de23f1e04bbac1b5b0e5b258dc1daccdee8423
7
- data.tar.gz: 8a997e21ae9f177c00fd4d46d139b0dd9d8562d7c92feb55dcd9a21df38320743cf3e3c28b0fbf99e315035ecda5f4884437bcef45a9f36e775d18b994131ba3
6
+ metadata.gz: 63018ed2227e4f05c8969116df94449cbe247585e6adf664efadfe81e9e43956542446f7b15df462d45989ac50a034450c5efbe3c9405d8bba4481ff5f1be933
7
+ data.tar.gz: ea5fce225cfffc4dc08a166b18543d232f7a8924e5ecfc628699c845d1a0c6f3c40533597518107fcadb7beb3a2fbc6e09ea670823a0917855d4f8652fe7e607
data/README.md CHANGED
@@ -291,7 +291,7 @@ Chef - A configuration management system
291
291
  | | |
292
292
  |:---------------------|:-----------------------------------------|
293
293
  | **Author:** | Adam Jacob (<adam@chef.io>)
294
- | **Copyright:** | Copyright 2008-2016, Chef Software, Inc.
294
+ | **Copyright:** | Copyright 2008-2017, Chef Software, Inc.
295
295
  | **License:** | Apache License, Version 2.0
296
296
 
297
297
  ```
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
3
  # Author:: Daniel DeLeo (<dan@chef.io>)
4
- # Copyright:: Copyright 2008-2016, Chef Software Inc.
4
+ # Copyright:: Copyright 2008-2017, Chef Software Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
data/VERSION CHANGED
@@ -1 +1 @@
1
- 12.21.14
1
+ 12.21.20
@@ -605,6 +605,9 @@ class Chef
605
605
  filter = Chef::Config[:minimal_ohai] ? %w{fqdn machinename hostname platform platform_version os os_version} : nil
606
606
  ohai.all_plugins(filter)
607
607
  events.ohai_completed(node)
608
+ rescue Ohai::Exceptions::CriticalPluginFailure => e
609
+ Chef::Log.error("Critical Ohai plugins failed: #{e.message}")
610
+ exit(false)
608
611
  end
609
612
 
610
613
  #
@@ -165,7 +165,11 @@ class Chef
165
165
  if resource.changes_state?
166
166
  # We ignore the last log message because it only contains the time it took, which looks weird
167
167
  cleaned_messages = resource.change_log[0..-2].map { |c| c.sub(/^#{Regexp.escape(resource.name)}/, "").strip }
168
- "converge DSC resource #{resource.name} by #{cleaned_messages.find_all { |c| c != '' }.join("\n")}"
168
+ unless cleaned_messages.empty?
169
+ "converge DSC resource #{resource.name} by #{cleaned_messages.find_all { |c| c != '' }.join("\n")}"
170
+ else
171
+ "converge DSC resource #{resource.name}"
172
+ end
169
173
  else
170
174
  # This is needed because a dsc script can have resources that are both converged and not
171
175
  "converge DSC resource #{resource.name} by doing nothing because it is already converged"
@@ -35,13 +35,18 @@ class Chef
35
35
  use_multipackage_api
36
36
  use_package_name_for_source
37
37
 
38
- provides :package, platform_family: %w{fedora} do
39
- which("dnf") && shell_out("rpm -q dnf").stdout =~ /^dnf-[1-9]/
40
- end
38
+ # all rhel variants >= 8 will use DNF
39
+ provides :package, platform_family: "rhel", platform: "!amazon", platform_version: ">= 8"
40
+
41
+ # fedora >= 22 uses DNF
42
+ provides :package, platform: "fedora", platform_version: ">= 22"
41
43
 
42
- provides :package, platform_family: %w{rhel}, platform_version: ">= 8"
44
+ # amazon will eventually use DNF
45
+ provides :package, platform: "amazon" do
46
+ which("dnf")
47
+ end
43
48
 
44
- provides :dnf_package, os: "linux"
49
+ provides :dnf_package
45
50
 
46
51
  #
47
52
  # Most of the magic in this class happens in the python helper script. The ruby side of this
@@ -29,8 +29,15 @@ class Chef
29
29
 
30
30
  allowed_actions :install, :upgrade, :remove, :purge, :reconfig, :lock, :unlock, :flush_cache
31
31
 
32
- provides :package, platform_family: %w{rhel fedora} do
33
- which("dnf") && shell_out("rpm -q dnf").stdout =~ /^dnf-[1-9]/
32
+ # all rhel variants >= 8 will use DNF
33
+ provides :package, platform_family: "rhel", platform: "!amazon", platform_version: ">= 8"
34
+
35
+ # fedora >= 22 uses DNF
36
+ provides :package, platform: "fedora", platform_version: ">= 22"
37
+
38
+ # amazon will eventually use DNF
39
+ provides :package, platform: "amazon" do
40
+ which("dnf")
34
41
  end
35
42
 
36
43
  provides :dnf_package
@@ -28,7 +28,7 @@ class Chef
28
28
  # Parses the output from LCM and returns a list of Chef::Util::DSC::ResourceInfo objects
29
29
  # that describe how the resources affected the system
30
30
  #
31
- # Example:
31
+ # Example for WhatIfParser:
32
32
  # parse <<-EOF
33
33
  # What if: [Machine]: LCM: [Start Set ]
34
34
  # What if: [Machine]: LCM: [Start Resource ] [[File]FileToNotBeThere]
@@ -53,7 +53,62 @@ class Chef
53
53
  # )
54
54
  # ]
55
55
  #
56
- def self.parse(lcm_output)
56
+ # Example for TestDSCParser:
57
+ # parse <<-EOF
58
+ # InDesiredState : False
59
+ # ResourcesInDesiredState :
60
+ # ResourcesNotInDesiredState: {[Environment]texteditor}
61
+ # ReturnValue : 0
62
+ # PSComputerName : .
63
+ # EOF
64
+ #
65
+ # would return
66
+ #
67
+ # [
68
+ # Chef::Util::DSC::ResourceInfo.new(
69
+ # '{[Environment]texteditor}',
70
+ # true,
71
+ # [
72
+ # ]
73
+ # )
74
+ # ]
75
+ #
76
+
77
+ def self.parse(lcm_output, test_dsc_configuration)
78
+ test_dsc_configuration ? test_dsc_parser(lcm_output) : what_if_parser(lcm_output)
79
+ end
80
+
81
+ def self.test_dsc_parser(lcm_output)
82
+ lcm_output ||= ""
83
+ current_resource = Hash.new
84
+
85
+ resources = []
86
+ lcm_output.lines.each do |line|
87
+ op_action , op_value = line.strip.split(":")
88
+ op_action&.strip!
89
+ case op_action
90
+ when "InDesiredState"
91
+ current_resource[:skipped] = op_value.strip == "True" ? true : false
92
+ when "ResourcesInDesiredState"
93
+ current_resource[:name] = op_value.strip if op_value
94
+ when "ResourcesNotInDesiredState"
95
+ current_resource[:name] = op_value.strip if op_value
96
+ when "ReturnValue"
97
+ current_resource[:context] = nil
98
+ end
99
+ end
100
+ if current_resource[:name]
101
+ resources.push(current_resource)
102
+ end
103
+
104
+ if resources.length > 0
105
+ build_resource_info(resources)
106
+ else
107
+ raise Chef::Exceptions::LCMParser, "Could not parse:\n#{lcm_output}"
108
+ end
109
+ end
110
+
111
+ def self.what_if_parser(lcm_output)
57
112
  lcm_output ||= ""
58
113
  current_resource = Hash.new
59
114
 
@@ -29,7 +29,7 @@ class Chef::Util::DSC
29
29
 
30
30
  def test_configuration(configuration_document, shellout_flags)
31
31
  status = run_configuration_cmdlet(configuration_document, false, shellout_flags)
32
- log_what_if_exception(status.stderr) unless status.succeeded?
32
+ log_dsc_exception(status.stderr) unless status.succeeded?
33
33
  configuration_update_required?(status.return_value)
34
34
  end
35
35
 
@@ -77,7 +77,7 @@ class Chef::Util::DSC
77
77
  ps4_base_command
78
78
  else
79
79
  if ps_version_gte_5?
80
- "#{common_command_prefix} Test-DscConfiguration -path #{@configuration_path}"
80
+ "#{common_command_prefix} Test-DscConfiguration -path #{@configuration_path} | format-list"
81
81
  else
82
82
  ps4_base_command + " -whatif; if (! $?) { exit 1 }"
83
83
  end
@@ -88,31 +88,31 @@ class Chef::Util::DSC
88
88
  Chef::Platform.supported_powershell_version?(@node, 5)
89
89
  end
90
90
 
91
- def log_what_if_exception(what_if_exception_output)
92
- if whatif_not_supported?(what_if_exception_output)
91
+ def log_dsc_exception(dsc_exception_output)
92
+ if whatif_not_supported?(dsc_exception_output)
93
93
  # LCM returns an error if any of the resources do not support the opptional What-If
94
94
  Chef::Log.warn("Received error while testing configuration due to resource not supporting 'WhatIf'")
95
- elsif dsc_module_import_failure?(what_if_exception_output)
96
- Chef::Log.warn("Received error while testing configuration due to a module for an imported resource possibly not being fully installed:\n#{what_if_exception_output.gsub(/\s+/, ' ')}")
95
+ elsif dsc_module_import_failure?(dsc_exception_output)
96
+ Chef::Log.warn("Received error while testing configuration due to a module for an imported resource possibly not being fully installed:\n#{dsc_exception_output.gsub(/\s+/, ' ')}")
97
97
  else
98
- Chef::Log.warn("Received error while testing configuration:\n#{what_if_exception_output.gsub(/\s+/, ' ')}")
98
+ Chef::Log.warn("Received error while testing configuration:\n#{dsc_exception_output.gsub(/\s+/, ' ')}")
99
99
  end
100
100
  end
101
101
 
102
- def whatif_not_supported?(what_if_exception_output)
103
- !! (what_if_exception_output.gsub(/[\r\n]+/, "").gsub(/\s+/, " ") =~ /A parameter cannot be found that matches parameter name 'Whatif'/i)
102
+ def whatif_not_supported?(dsc_exception_output)
103
+ !! (dsc_exception_output.gsub(/[\r\n]+/, "").gsub(/\s+/, " ") =~ /A parameter cannot be found that matches parameter name 'Whatif'/i)
104
104
  end
105
105
 
106
- def dsc_module_import_failure?(what_if_output)
107
- !! (what_if_output =~ /\sCimException/ &&
108
- what_if_output =~ /ProviderOperationExecutionFailure/ &&
109
- what_if_output =~ /\smodule\s+is\s+installed/)
106
+ def dsc_module_import_failure?(command_output)
107
+ !! (command_output =~ /\sCimException/ &&
108
+ command_output =~ /ProviderOperationExecutionFailure/ &&
109
+ command_output =~ /\smodule\s+is\s+installed/)
110
110
  end
111
111
 
112
- def configuration_update_required?(what_if_output)
113
- Chef::Log.debug("DSC: DSC returned the following '-whatif' output from test operation:\n#{what_if_output}")
112
+ def configuration_update_required?(command_output)
113
+ Chef::Log.debug("DSC: DSC returned the following '-whatif' output from test operation:\n#{command_output}")
114
114
  begin
115
- Parser.parse(what_if_output)
115
+ Parser.parse(command_output, ps_version_gte_5?)
116
116
  rescue Chef::Exceptions::LCMParser => e
117
117
  Chef::Log.warn("Could not parse LCM output: #{e}")
118
118
  [Chef::Util::DSC::ResourceInfo.new("Unknown DSC Resources", true, ["Unknown changes because LCM output was not parsable."])]
@@ -21,7 +21,7 @@
21
21
 
22
22
  class Chef
23
23
  CHEF_ROOT = File.expand_path("../..", __FILE__)
24
- VERSION = "12.21.14"
24
+ VERSION = "12.21.20"
25
25
  end
26
26
 
27
27
  #
@@ -44,6 +44,17 @@ describe Chef::Client do
44
44
  end
45
45
  end
46
46
 
47
+ context "when Ohai tells us to fail" do
48
+ it "fails" do
49
+ ohai_system = Ohai::System.new
50
+ module Ohai::Exceptions
51
+ class CriticalPluginFailure < Error; end
52
+ end
53
+ expect(ohai_system).to receive(:all_plugins) { raise Ohai::Exceptions::CriticalPluginFailure }
54
+ expect { client.run_ohai }.to raise_error(SystemExit)
55
+ end
56
+ end
57
+
47
58
  describe "authentication protocol selection" do
48
59
  context "when FIPS is disabled" do
49
60
  before do
@@ -709,18 +709,21 @@ describe Chef::ProviderResolver do
709
709
 
710
710
  "rhel" => {
711
711
  # service: [ Chef::Resource::SystemdService, Chef::Provider::Service::Systemd ],
712
- package: [ Chef::Resource::YumPackage, Chef::Provider::Package::Yum ],
712
+ package: [ Chef::Resource::DnfPackage, Chef::Provider::Package::Dnf ],
713
713
  ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig::Redhat ],
714
714
 
715
715
  %w{amazon xcp xenserver ibm_powerkvm cloudlinux parallels} => {
716
716
  "3.1.4" => {
717
+ package: [ Chef::Resource::YumPackage, Chef::Provider::Package::Yum ],
717
718
  # service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ],
718
719
  },
719
720
  },
720
721
  %w{redhat centos scientific oracle} => {
721
722
  "7.0" => {
723
+ package: [ Chef::Resource::YumPackage, Chef::Provider::Package::Yum ],
722
724
  },
723
725
  "6.0" => {
726
+ package: [ Chef::Resource::YumPackage, Chef::Provider::Package::Yum ],
724
727
  # service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ],
725
728
  },
726
729
  },
@@ -19,20 +19,33 @@
19
19
  require "chef/util/dsc/lcm_output_parser"
20
20
 
21
21
  describe Chef::Util::DSC::LocalConfigurationManager::Parser do
22
- context "empty input parameter" do
22
+ context "empty input parameter for WhatIfParser" do
23
23
  it "raises an exception when there are no valid lines" do
24
24
  str = <<-EOF
25
25
 
26
26
  EOF
27
- expect { Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str) }.to raise_error(Chef::Exceptions::LCMParser)
27
+ expect { Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false) }.to raise_error(Chef::Exceptions::LCMParser)
28
28
  end
29
29
 
30
30
  it "raises an exception for a nil input" do
31
- expect { Chef::Util::DSC::LocalConfigurationManager::Parser.parse(nil) }.to raise_error(Chef::Exceptions::LCMParser)
31
+ expect { Chef::Util::DSC::LocalConfigurationManager::Parser.parse(nil, false) }.to raise_error(Chef::Exceptions::LCMParser)
32
32
  end
33
33
  end
34
34
 
35
- context "correctly formatted output from lcm" do
35
+ context "empty input parameter for TestDSCParser" do
36
+ it "raises an exception when there are no valid lines" do
37
+ str = <<-EOF
38
+
39
+ EOF
40
+ expect { Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, true) }.to raise_error(Chef::Exceptions::LCMParser)
41
+ end
42
+
43
+ it "raises an exception for a nil input" do
44
+ expect { Chef::Util::DSC::LocalConfigurationManager::Parser.parse(nil, true) }.to raise_error(Chef::Exceptions::LCMParser)
45
+ end
46
+ end
47
+
48
+ context "correctly formatted output from lcm for WhatIfParser" do
36
49
  it "returns a single resource when only 1 logged with the correct name" do
37
50
  str = <<EOF
38
51
  logtype: [machinename]: LCM: [ Start Set ]
@@ -40,7 +53,7 @@ logtype: [machinename]: LCM: [ Start Resource ] [name]
40
53
  logtype: [machinename]: LCM: [ End Resource ] [name]
41
54
  logtype: [machinename]: LCM: [ End Set ]
42
55
  EOF
43
- resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str)
56
+ resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false)
44
57
  expect(resources.length).to eq(1)
45
58
  expect(resources[0].name).to eq("[name]")
46
59
  end
@@ -54,7 +67,7 @@ logtype: [machinename]: LCM: [ End Set ] [name]
54
67
  logtype: [machinename]: LCM: [ End Resource ] [name]
55
68
  logtype: [machinename]: LCM: [ End Set ]
56
69
  EOF
57
- resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str)
70
+ resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false)
58
71
  expect(resources[0].changes_state?).to be_truthy
59
72
  end
60
73
 
@@ -68,11 +81,11 @@ logtype: [machinename]: LCM: [ End Set ] [name]
68
81
  logtype: [machinename]: LCM: [ End Resource ] [name]
69
82
  logtype: [machinename]: LCM: [ End Set ]
70
83
  EOF
71
- resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str)
84
+ resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false)
72
85
  expect(resources[0].change_log).to match_array(["[name]", "[message]", "[name]"])
73
86
  end
74
87
 
75
- it "should return false for changes_state?" do
88
+ it "returns false for changes_state?" do
76
89
  str = <<EOF
77
90
  logtype: [machinename]: LCM: [ Start Set ]
78
91
  logtype: [machinename]: LCM: [ Start Resource ] [name]
@@ -80,11 +93,11 @@ logtype: [machinename]: LCM: [ Skip Set ] [name]
80
93
  logtype: [machinename]: LCM: [ End Resource ] [name]
81
94
  logtype: [machinename]: LCM: [ End Set ]
82
95
  EOF
83
- resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str)
96
+ resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false)
84
97
  expect(resources[0].changes_state?).to be_falsey
85
98
  end
86
99
 
87
- it "should return an empty array for change_log if changes_state? is false" do
100
+ it "returns an empty array for change_log if changes_state? is false" do
88
101
  str = <<EOF
89
102
  logtype: [machinename]: LCM: [ Start Set ]
90
103
  logtype: [machinename]: LCM: [ Start Resource ] [name]
@@ -92,13 +105,64 @@ logtype: [machinename]: LCM: [ Skip Set ] [name]
92
105
  logtype: [machinename]: LCM: [ End Resource ] [name]
93
106
  logtype: [machinename]: LCM: [ End Set ]
94
107
  EOF
95
- resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str)
108
+ resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false)
96
109
  expect(resources[0].change_log).to be_empty
97
110
  end
98
111
  end
99
112
 
100
- context "Incorrectly formatted output from LCM" do
101
- it "should allow missing a [End Resource] when its the last one and still find all the resource" do
113
+ context "correctly formatted output from lcm for TestDSCParser" do
114
+ it "returns a single resource when only 1 logged with the correct name" do
115
+ str = <<EOF
116
+ InDesiredState : False
117
+ ResourcesInDesiredState :
118
+ ResourcesNotInDesiredState: [name]
119
+ ReturnValue : 0
120
+ PSComputerName : .
121
+ EOF
122
+ resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, true)
123
+ expect(resources.length).to eq(1)
124
+ expect(resources[0].name).to eq("[name]")
125
+ end
126
+
127
+ it "identifies when a resource changes the state of the system" do
128
+ str = <<EOF
129
+ InDesiredState : False
130
+ ResourcesInDesiredState :
131
+ ResourcesNotInDesiredState: [name]
132
+ ReturnValue : 0
133
+ PSComputerName : .
134
+ EOF
135
+ resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, true)
136
+ expect(resources[0].changes_state?).to be_truthy
137
+ end
138
+
139
+ it "returns false for changes_state?" do
140
+ str = <<EOF
141
+ InDesiredState : True
142
+ ResourcesInDesiredState : [name]
143
+ ResourcesNotInDesiredState:
144
+ ReturnValue : 0
145
+ PSComputerName : .
146
+ EOF
147
+ resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, true)
148
+ expect(resources[0].changes_state?).to be_falsey
149
+ end
150
+
151
+ it "returns an empty array for change_log if changes_state? is false" do
152
+ str = <<EOF
153
+ InDesiredState : True
154
+ ResourcesInDesiredState : [name]
155
+ ResourcesNotInDesiredState:
156
+ ReturnValue : 0
157
+ PSComputerName : .
158
+ EOF
159
+ resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, true)
160
+ expect(resources[0].change_log).to be_empty
161
+ end
162
+ end
163
+
164
+ context "Incorrectly formatted output from LCM for WhatIfParser" do
165
+ it "allows missing [End Resource] when its the last one and still find all the resource" do
102
166
  str = <<-EOF
103
167
  logtype: [machinename]: LCM: [ Start Set ]
104
168
  logtype: [machinename]: LCM: [ Start Resource ] [name]
@@ -114,12 +178,12 @@ logtype: [machinename]: LCM: [ End Set ]
114
178
  logtype: [machinename]: LCM: [ End Set ]
115
179
  EOF
116
180
 
117
- resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str)
181
+ resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false)
118
182
  expect(resources[0].changes_state?).to be_falsey
119
183
  expect(resources[1].changes_state?).to be_truthy
120
184
  end
121
185
 
122
- it "should allow missing a [End Resource] when its the first one and still find all the resource" do
186
+ it "allow missing [End Resource] when its the first one and still find all the resource" do
123
187
  str = <<-EOF
124
188
  logtype: [machinename]: LCM: [ Start Set ]
125
189
  logtype: [machinename]: LCM: [ Start Resource ] [name]
@@ -135,12 +199,12 @@ logtype: [machinename]: LCM: [ End Resource ]
135
199
  logtype: [machinename]: LCM: [ End Set ]
136
200
  EOF
137
201
 
138
- resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str)
202
+ resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false)
139
203
  expect(resources[0].changes_state?).to be_falsey
140
204
  expect(resources[1].changes_state?).to be_truthy
141
205
  end
142
206
 
143
- it "should allow missing set and end resource and assume an unconverged resource in this case" do
207
+ it "allows missing set and end resource and assume an unconverged resource in this case" do
144
208
  str = <<-EOF
145
209
  logtype: [machinename]: LCM: [ Start Set ]
146
210
  logtype: [machinename]: LCM: [ Start Resource ] [name]
@@ -154,11 +218,31 @@ logtype: [machinename]: LCM: [ End Set ]
154
218
  logtype: [machinename]: LCM: [ End Resource ]
155
219
  logtype: [machinename]: LCM: [ End Set ]
156
220
  EOF
157
- resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str)
221
+ resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false)
158
222
  expect(resources[0].changes_state?).to be_truthy
159
223
  expect(resources[0].name).to eql("[name]")
160
224
  expect(resources[1].changes_state?).to be_truthy
161
225
  expect(resources[1].name).to eql("[name2]")
162
226
  end
163
227
  end
228
+
229
+ context "Incorrectly formatted output from LCM for TestDSCParser" do
230
+ it "allows missing [End Resource] when its the last one and still find all the resource" do
231
+ str = <<EOF
232
+ InDesiredState : True
233
+ ResourcesInDesiredState :
234
+ ResourcesNotInDesiredState: [name]
235
+ ReturnValue : 0
236
+ PSComputerName : .
237
+ InDesiredState : True
238
+ ResourcesInDesiredState :
239
+ ResourcesNotInDesiredState: [name2]
240
+ ReturnValue : 0
241
+ PSComputerName : .
242
+ EOF
243
+
244
+ resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, true)
245
+ expect(resources[0].changes_state?).to be_falsey
246
+ end
247
+ end
164
248
  end
@@ -57,6 +57,7 @@ EOH
57
57
  context "when interacting with the LCM using a PowerShell cmdlet" do
58
58
  before(:each) do
59
59
  allow(lcm).to receive(:run_configuration_cmdlet).and_return(lcm_status)
60
+ allow(lcm).to receive(:ps_version_gte_5?).and_return(false)
60
61
  end
61
62
  context "that returns successfully" do
62
63
  let(:lcm_standard_output) { normal_lcm_output }
@@ -103,7 +104,7 @@ EOH
103
104
  let(:common_command_prefix) { "$ProgressPreference = 'SilentlyContinue';" }
104
105
  let(:ps4_base_command) { "#{common_command_prefix} Start-DscConfiguration -path tmp -wait -erroraction 'stop' -force" }
105
106
  let(:lcm_command_ps4) { ps4_base_command + " -whatif; if (! $?) { exit 1 }" }
106
- let(:lcm_command_ps5) { "#{common_command_prefix} Test-DscConfiguration -path tmp" }
107
+ let(:lcm_command_ps5) { "#{common_command_prefix} Test-DscConfiguration -path tmp | format-list" }
107
108
  let(:lcm_standard_output) { normal_lcm_output }
108
109
  let(:lcm_standard_error) { nil }
109
110
  let(:lcm_cmdlet_success) { true }
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: 12.21.14
4
+ version: 12.21.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-27 00:00:00.000000000 Z
11
+ date: 2017-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 12.21.14
19
+ version: 12.21.20
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: 12.21.14
26
+ version: 12.21.20
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mixlib-cli
29
29
  requirement: !ruby/object:Gem::Requirement