summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Edwards <adamed@opscode.com>2014-08-30 22:41:04 -0700
committerJay Mundrawala <jdmundrawala@gmail.com>2014-09-19 12:47:59 -0700
commit297a5d7b54e8e07b97458e1c8f2dcc2fcda62203 (patch)
tree986f39a2641e13644e72ec58280fd23b8b6c4eed
parent864f4a7b5f7a688026a034d8c3fe8e547770cbb4 (diff)
downloadchef-297a5d7b54e8e07b97458e1c8f2dcc2fcda62203.tar.gz
Handle not installed DSC resource errors from LCM
-rw-r--r--lib/chef/util/dsc/local_configuration_manager.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/chef/util/dsc/local_configuration_manager.rb b/lib/chef/util/dsc/local_configuration_manager.rb
index 959d5ef829..a12ca98d7c 100644
--- a/lib/chef/util/dsc/local_configuration_manager.rb
+++ b/lib/chef/util/dsc/local_configuration_manager.rb
@@ -27,17 +27,24 @@ class Chef::Util::DSC
clear_execution_time
end
+ LCM_MODULE_NOT_INSTALLED_ERROR_CODE = 0x80131500
+
def test_configuration(configuration_document)
status = run_configuration_cmdlet(configuration_document)
+ command_output = status.return_value
unless status.succeeded?
- # LCM returns an error if any of the resources do not support the opptional What-If
+ if status.exitcode == LCM_MODULE_NOT_INSTALLED_ERROR_CODE
+ Chef::Log::warn('Unable to test configuration because a required DSC PowerShell module may not be installed.')
+ command_output = ''
+ end
if status.stderr.gsub(/\s+/, ' ') =~ /A parameter cannot be found that matches parameter name 'Whatif'/
+ # LCM returns an error if any of the resources do not support the opptional What-If
Chef::Log::warn("Received error while testing configuration due to resource not supporting 'WhatIf'")
else
raise Chef::Exceptions::PowershellCmdletException, "Powershell Cmdlet failed: #{status.stderr.gsub(/\s+/, ' ')}"
end
end
- configuration_update_required?(status.return_value)
+ configuration_update_required?(command_output)
end
def set_configuration(configuration_document)
@@ -105,7 +112,7 @@ EOH
begin
Parser::parse(what_if_output)
rescue Chef::Util::DSC::LocalConfigurationManager::Parser => e
- Chef::Log::warn("Could not parse parse LCM output: #{e}")
+ Chef::Log::warn("Could not parse LCM output: #{e}")
[Chef::Util::DSC::ResourceInfo.new('Unknown DSC Resources', true, ['Unknown changes because LCM output was not parsable.'])]
end
end