diff options
Diffstat (limited to 'lib/chef/provider')
-rw-r--r-- | lib/chef/provider/cron/unix.rb | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/chef/provider/cron/unix.rb b/lib/chef/provider/cron/unix.rb index b3a38a28a4..8e81ff6706 100644 --- a/lib/chef/provider/cron/unix.rb +++ b/lib/chef/provider/cron/unix.rb @@ -25,16 +25,19 @@ class Chef class Provider class Cron class Unix < Chef::Provider::Cron + include Chef::Mixin::ShellOut private def read_crontab - status, crontab, stderr = run_command_and_return_stdout_stderr(:command => "/usr/bin/crontab -l",:user => @new_resource.user) - if status.exitstatus > 1 - raise Chef::Exceptions::Cron, "Error determining state of #{@new_resource.name}, exit: #{status.exitstatus}" + crontab = shell_out('/usr/bin/crontab -l', :user => @new_resource.user) + status = crontab.status.exitstatus + + if status > 1 + raise Chef::Exceptions::Cron, "Error determining state of #{@new_resource.name}, exit: #{status}" end - return nil if status.exitstatus > 0 - crontab.chomp << "\n" + return nil if status > 0 + crontab.stdout.chomp << "\n" end def write_crontab(crontab) @@ -45,8 +48,9 @@ class Chef exit_status = 0 error_message = "" begin - status, stdout, stderr = run_command_and_return_stdout_stderr(:command => "/usr/bin/crontab #{tempcron.path}",:user => @new_resource.user) - exit_status = status.exitstatus + crontab_write = shell_out("/usr/bin/crontab #{tempcron.path}", :user => @new_resource.user) + stderr = crontab_write.stderr + exit_status = crontab_write.status.exitstatus # solaris9, 10 on some failures for example invalid 'mins' in crontab fails with exit code of zero :( if stderr && stderr.include?("errors detected in input, no crontab file generated") error_message = stderr |