summaryrefslogtreecommitdiff
path: root/lib/chef/provider
diff options
context:
space:
mode:
authorEric Saxby & Greg Poirier <eric+greg@wanelo.com>2014-09-26 13:07:40 -0700
committerEric Saxby & Greg Poirier <eric+greg@wanelo.com>2014-09-26 13:07:40 -0700
commit601481ebc362eaf9418cbd12eef38952404c7675 (patch)
treef5fd0360f3e8b7d8450cfe28d087fbac31f763c9 /lib/chef/provider
parent521712d5e32d982ca25d4965bada9b7432f5e5a9 (diff)
downloadchef-601481ebc362eaf9418cbd12eef38952404c7675.tar.gz
Unix cron provider uses shell_out
- update unix_spec to more modern RSpec syntax - both #read_crontab and #write_crontab use shell_out
Diffstat (limited to 'lib/chef/provider')
-rw-r--r--lib/chef/provider/cron/unix.rb18
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