diff options
author | Adam Edwards <adamed@opscode.com> | 2014-08-30 22:41:04 -0700 |
---|---|---|
committer | adamedx <adamed@getchef.com> | 2014-09-10 20:29:00 -0700 |
commit | e0c8077c5beed58afc55cd1b8cf2cd3951ece2a4 (patch) | |
tree | 0b23acb895e8fae8136bd0e06d3c66514e6bf1a4 /lib/chef/util | |
parent | eb918c554e37a61ae5115763a3d016c3918b99b6 (diff) | |
download | chef-e0c8077c5beed58afc55cd1b8cf2cd3951ece2a4.tar.gz |
Handle not installed DSC resource errors from LCM
Diffstat (limited to 'lib/chef/util')
-rw-r--r-- | lib/chef/util/dsc/local_configuration_manager.rb | 13 |
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 |