summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpiyushawasthi <piyush.awasthi@msystechnologies.com>2017-09-07 18:22:31 +0530
committerpiyushawasthi <piyush.awasthi@msystechnologies.com>2017-09-08 18:54:04 +0530
commit6b00c276b8db843dda12842e7afe24ef3ac706be (patch)
tree1a8ac54abc6fd9cf287e5ee9e24eea50e0f35a8d
parenta06b75f3f29e707872e3d615c15d4842c6874fb7 (diff)
downloadchef-6b00c276b8db843dda12842e7afe24ef3ac706be.tar.gz
MSYS-656 - fixed dsc_script for WMF5
Signed-off-by: piyushawasthi <piyush.awasthi@msystechnologies.com>
-rw-r--r--lib/chef/util/dsc/local_configuration_manager.rb20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/chef/util/dsc/local_configuration_manager.rb b/lib/chef/util/dsc/local_configuration_manager.rb
index d837a16185..1176602af9 100644
--- a/lib/chef/util/dsc/local_configuration_manager.rb
+++ b/lib/chef/util/dsc/local_configuration_manager.rb
@@ -47,10 +47,10 @@ class Chef::Util::DSC
def run_configuration_cmdlet(configuration_document, apply_configuration, shellout_flags)
Chef::Log.debug("DSC: Calling DSC Local Config Manager to #{apply_configuration ? "set" : "test"} configuration document.")
- test_only_parameters = ! apply_configuration ? "-whatif; if (! $?) { exit 1 }" : ""
+ test_parameters = ! apply_configuration ? "-whatif; if (! $?) { exit 1 }" : ""
start_operation_timing
- command_code = lcm_command_code(@configuration_path, test_only_parameters)
+ command_code = lcm_command_code(@configuration_path, test_parameters)
status = nil
begin
@@ -72,10 +72,20 @@ class Chef::Util::DSC
status
end
- def lcm_command_code(configuration_path, test_only_parameters)
- <<-EOH
-$ProgressPreference = 'SilentlyContinue';start-dscconfiguration -path #{@configuration_path} -wait -erroraction 'stop' -force #{test_only_parameters}
+ def lcm_command_code(configuration_path, test_parameters)
+ if !test_parameters.strip.empty? && is_ps_version_gte_5?
+ <<-EOH
+$ProgressPreference = 'SilentlyContinue';Test-DscConfiguration -path #{@configuration_path}
EOH
+ else
+ <<-EOH
+$ProgressPreference = 'SilentlyContinue';start-dscconfiguration -path #{@configuration_path} -wait -erroraction 'stop' -force #{test_parameters}
+EOH
+ end
+ end
+
+ def is_ps_version_gte_5?
+ Chef::Platform.supported_powershell_version?(@node, 5)
end
def log_what_if_exception(what_if_exception_output)