diff options
author | Vasu1105 <vasundhara.jagdale@msystechnologies.com> | 2017-12-11 11:38:27 +0000 |
---|---|---|
committer | Vasu1105 <vasundhara.jagdale@msystechnologies.com> | 2017-12-11 11:38:27 +0000 |
commit | e228bdf9fa5340dfd03c29243448c2ec5fc8d176 (patch) | |
tree | 9de30c75cf04a1c8acc930698474726f7008893b /lib | |
parent | 35eac8934a51d86bf9e12131b40148642d0b06cf (diff) | |
download | chef-e228bdf9fa5340dfd03c29243448c2ec5fc8d176.tar.gz |
[MSYS-731] Fix for [chef] windows_task resource isn't idempotent for any command
Signed-off-by: Vasu1105 <vasundhara.jagdale@msystechnologies.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/provider/windows_task.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/chef/provider/windows_task.rb b/lib/chef/provider/windows_task.rb index 937d28cf4b..023f79b1c0 100644 --- a/lib/chef/provider/windows_task.rb +++ b/lib/chef/provider/windows_task.rb @@ -20,6 +20,7 @@ require "chef/mixin/shell_out" require "rexml/document" require "iso8601" require "chef/mixin/powershell_out" +require 'pry' class Chef class Provider @@ -207,8 +208,14 @@ class Chef def run_schtasks(task_action, options = {}) cmd = "schtasks /#{task_action} /TN \"#{new_resource.task_name}\" " options.keys.each do |option| - cmd += "/#{option} " - cmd += "\"#{options[option].to_s.gsub('"', "\\\"")}\" " unless options[option] == "" + unless option == "TR" + cmd += "/#{option} " + cmd += "\"#{options[option].to_s.gsub('"', "\\\"")}\" " unless options[option] == "" + end + end + # Appending Task Run [TR] option at the end since appending causing sometimes to append other options in option["TR"] value + if options["TR"] + cmd += "/TR \"#{options["TR"]} \" " unless task_action == "DELETE" end Chef::Log.debug("running: ") Chef::Log.debug(" #{cmd}") @@ -361,7 +368,6 @@ class Chef options["RP"] = new_resource.password if new_resource.password options["IT"] = "" if new_resource.interactive_enabled options["XML"] = temp_task_file - run_schtasks("DELETE", "F" => "") run_schtasks("CREATE", options) ensure |