Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quote task options #310

Merged
merged 1 commit into from
Dec 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions providers/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
options['MO'] = @new_resource.frequency_modifier if frequency_modifier_allowed.include?(@new_resource.frequency)
options['SD'] = @new_resource.start_day unless @new_resource.start_day.nil?
options['ST'] = @new_resource.start_time unless @new_resource.start_time.nil?
options['TR'] = "\"#{@new_resource.command}\" "
options['TR'] = @new_resource.command
options['RU'] = @new_resource.user
options['RP'] = @new_resource.password if use_password?
options['RL'] = 'HIGHEST' if @new_resource.run_level == :highest
Expand Down Expand Up @@ -75,7 +75,7 @@
validate_interactive_setting

options = {}
options['TR'] = "\"#{@new_resource.command}\" " if @new_resource.command
options['TR'] = @new_resource.command if @new_resource.command
options['RU'] = @new_resource.user if @new_resource.user
options['RP'] = @new_resource.password if @new_resource.password
options['SD'] = @new_resource.start_day unless @new_resource.start_day.nil?
Expand Down Expand Up @@ -168,7 +168,8 @@ def load_current_resource
def run_schtasks(task_action, options = {})
cmd = "schtasks /#{task_action} /TN \"#{@new_resource.task_name}\" "
options.keys.each do |option|
cmd += "/#{option} #{options[option]} "
cmd += "/#{option} "
cmd += "\"#{options[option]}\" " unless options[option] == ''
end
Chef::Log.debug('running: ')
Chef::Log.debug(" #{cmd}")
Expand Down
3 changes: 2 additions & 1 deletion test/cookbooks/minimal/recipes/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

windows_task 'task_for_system' do
command 'dir'
user 'system'
user 'NT AUTHORITY\SYSTEM'
run_level :highest
password 'ignored'
end