summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorpiyushawasthi <piyush.awasthi@msystechnologies.com>2017-09-07 18:22:31 +0530
committerBryan McLellan <btm@loftninjas.org>2017-09-12 12:01:15 -0400
commit8c5252581403e2b7522a8ae8bcd419947afd9d7e (patch)
tree2b422450ebec58c45bacf0802a7845beea999173 /lib/chef
parent863e9bf7b7c61d4c2b3de71fbb33892b51316e1c (diff)
downloadchef-8c5252581403e2b7522a8ae8bcd419947afd9d7e.tar.gz
MSYS-656 - fixed dsc_script for WMF5
Signed-off-by: piyushawasthi <piyush.awasthi@msystechnologies.com>
Diffstat (limited to 'lib/chef')
-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)