summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Cheslock <pcheslock@sonian.com>2012-12-03 17:39:59 -0500
committerPete Cheslock <pcheslock@sonian.com>2012-12-03 17:39:59 -0500
commit833b5a1c2c8bd171c2170789997201a4615ad2fa (patch)
tree75cbdf5fbf1f357585cc0cf3185fe1a31597e211
parentb2726d616be3f8c72bd22f1eeae794133dcd2575 (diff)
downloadmixlib-shellout-833b5a1c2c8bd171c2170789997201a4615ad2fa.tar.gz
[COOK-1921] Set log action to fatal if missing un/pw and use command if
exists
-rw-r--r--providers/task.rb6
-rw-r--r--resources/task.rb3
2 files changed, 4 insertions, 5 deletions
diff --git a/providers/task.rb b/providers/task.rb
index 7222633..abaa215 100644
--- a/providers/task.rb
+++ b/providers/task.rb
@@ -31,7 +31,7 @@ action :create do
if @new_resource.user && @new_resource.password
cmd += "/RU \"#{@new_resource.user}\" /RP \"#{@new_resource.password}\" "
elsif (@new_resource.user and !@new_resource.password) || (@new_resource.password and !@new_resource.user)
- Chef::Log.warn "#{@new_resource.name}: Can't specify user or password without both!"
+ Chef::Log.fatal "#{@new_resource.name}: Can't specify user or password without both!"
end
cmd += "/RL HIGHEST " if @new_resource.run_level == :highest
shell_out!(cmd, {:returns => [0]})
@@ -58,11 +58,11 @@ end
action :change do
if @current_resource.exists
cmd = "schtasks /Change /TN \"#{@current_resource.name}\" "
- cmd += "/TR \"#{@new_resource.command}\" "
+ cmd += "/TR \"#{@new_resource.command}\" " if @new_resource.command
if @new_resource.user && @new_resource.password
cmd += "/RU \"#{@new_resource.user}\" /RP \"#{@new_resource.password}\" "
elsif (@new_resource.user and !@new_resource.password) || (@new_resource.password and !@new_resource.user)
- Chef::Log.warn "#{@new_resource.name}: Can't specify user or password without both!"
+ Chef::Log.fatal "#{@new_resource.name}: Can't specify user or password without both!"
end
shell_out!(cmd, {:returns => [0]})
@new_resource.updated_by_last_action true
diff --git a/resources/task.rb b/resources/task.rb
index d5cf985..e0c4a2d 100644
--- a/resources/task.rb
+++ b/resources/task.rb
@@ -23,7 +23,7 @@
actions :create, :delete, :run
attribute :name, :kind_of => String, :name_attribute => true
-attribute :command, :kind_of => String, :required => true
+attribute :command, :kind_of => String
attribute :cwd, :kind_of => String
attribute :user, :kind_of => String, :default => nil
attribute :password, :kind_of => String, :default => nil
@@ -43,5 +43,4 @@ attr_accessor :exists, :status
def initialize(name, run_context=nil)
super
@action = :create
- @command = name
end