diff options
author | Adam Edwards <adamed@opscode.com> | 2014-08-30 22:11:48 -0700 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2014-09-19 12:47:59 -0700 |
commit | 864f4a7b5f7a688026a034d8c3fe8e547770cbb4 (patch) | |
tree | bb5e472cf342a4d8b2faa14a5e5d218d6556cd31 /lib/chef/util/dsc | |
parent | fb433e2df1c9ddf1a3d31e37db4eade4f78b32f6 (diff) | |
download | chef-864f4a7b5f7a688026a034d8c3fe8e547770cbb4.tar.gz |
Set exit code from start-dscconfiguraiton to enable identification of DSC errors
Diffstat (limited to 'lib/chef/util/dsc')
-rw-r--r-- | lib/chef/util/dsc/local_configuration_manager.rb | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/chef/util/dsc/local_configuration_manager.rb b/lib/chef/util/dsc/local_configuration_manager.rb index 79cfcd2996..959d5ef829 100644 --- a/lib/chef/util/dsc/local_configuration_manager.rb +++ b/lib/chef/util/dsc/local_configuration_manager.rb @@ -57,7 +57,7 @@ class Chef::Util::DSC test_only_parameters = ! apply_configuration ? '-whatif; if (! $?) { exit 1 }' : '' start_operation_timing - command_code = "$ProgressPreference = 'SilentlyContinue';start-dscconfiguration -path #{@configuration_path} -wait -force #{test_only_parameters}" + command_code = lcm_command_code(@configuration_path, test_only_parameters) status = nil begin @@ -79,6 +79,27 @@ class Chef::Util::DSC status end + def lcm_command_code(configuration_path, test_only_parameters) + <<-EOH +try +{ + $ProgressPreference = 'SilentlyContinue';start-dscconfiguration -path #{@configuration_path} -wait -force #{test_only_parameters} -erroraction 'Stop' +} +catch [Microsoft.Management.Infrastructure.CimException] +{ + $exception = $_.Exception + write-error -Exception $exception + $StatusCode = 1 + if ( $exception.HResult -ne 0 ) + { + $StatusCode = $exception.HResult + } + $exception | format-table -property * -force + exit $StatusCode +} +EOH + end + def configuration_update_required?(what_if_output) Chef::Log.debug("DSC: DSC returned the following '-whatif' output from test operation:\n#{what_if_output}") begin |