[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. puppet-0.24.5-rc3-1601-gf8c1b08
James Turnbull
james at lovedthanlost.net
Fri Jan 15 09:07:32 UTC 2010
The following commit has been merged in the upstream branch:
commit 01c98f6a196d37d346ccb34863502409da212f8d
Author: Andrew Forgue <andrew.forgue at gmail.com>
Date: Mon Nov 23 17:58:13 2009 -0500
Fixed #2798 - Correct issue with crontab provider on AIX
Clean up AIX crontab type:
- The return "" if output.include?(...) prevented the
raise from ever being reached.
- Ensure the temp file is deleted after feeding it
to cron.
- Prevent dumping of the new crontab to STDOUT.
Signed-off-by: Andrew Forgue <andrew.forgue at gmail.com>
diff --git a/lib/puppet/provider/cron/crontab.rb b/lib/puppet/provider/cron/crontab.rb
index 82384d0..6dee2e5 100755
--- a/lib/puppet/provider/cron/crontab.rb
+++ b/lib/puppet/provider/cron/crontab.rb
@@ -3,6 +3,8 @@ require 'puppet/provider/parsedfile'
tab = case Facter.value(:operatingsystem)
when "Solaris"
:suntab
+ when "AIX"
+ :aixtab
else
:crontab
end
diff --git a/lib/puppet/util/filetype.rb b/lib/puppet/util/filetype.rb
index 93c002f..8e8b8dd 100755
--- a/lib/puppet/util/filetype.rb
+++ b/lib/puppet/util/filetype.rb
@@ -251,4 +251,50 @@ class Puppet::Util::FileType
output_file.delete
end
end
+
+ # Support for AIX crontab with output different than suntab's crontab command.
+ newfiletype(:aixtab) do
+ # Read a specific @path's cron tab.
+ def read
+ begin
+ output = Puppet::Util.execute(%w{crontab -l}, :uid => @path)
+ if output.include?("You are not authorized to use the cron command")
+ raise Puppet::Error, "User %s not authorized to use cron" % @path
+ end
+ return output
+ rescue => detail
+ raise Puppet::Error, "Could not read crontab for %s: %s" % [@path, detail]
+ end
+ end
+
+ # Remove a specific @path's cron tab.
+ def remove
+ begin
+ Puppet::Util.execute(%w{crontab -r}, :uid => @path)
+ rescue => detail
+ raise Puppet::Error, "Could not remove crontab for %s: %s" % [@path, detail]
+ end
+ end
+
+ # Overwrite a specific @path's cron tab; must be passed the @path name
+ # and the text with which to create the cron tab.
+ def write(text)
+ require "tempfile"
+ output_file = Tempfile.new("puppet")
+ fh = output_file.open
+ fh.print text
+ fh.close
+
+ # We have to chown the stupid file to the user.
+ File.chown(Puppet::Util.uid(@path), nil, output_file.path)
+
+ begin
+ Puppet::Util.execute(["crontab", output_file.path], :uid => @path)
+ rescue => detail
+ raise Puppet::Error, "Could not write crontab for %s: %s" % [@path, detail]
+ ensure
+ output_file.delete
+ end
+ end
+ end
end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list