Issue #2798 has been updated by Andrew Forgue.
<pre>
diff -rup puppet/provider/cron/crontab.rb puppet.mod/provider/cron/crontab.rb
--- puppet/provider/cron/crontab.rb 2009-11-06 11:01:28.000000000 -0500
+++ puppet.mod/provider/cron/crontab.rb 2009-11-10 16:15:07.000000000 -0500
@@ -3,6 +3,8 @@ require 'puppet/provider/parsedfile'
tab = case Facter.value(:operatingsystem)
when "Solaris"
:suntab
+ when "AIX"
+ :aixtab
else
:crontab
end
diff -rup puppet/util/filetype.rb puppet.mod/util/filetype.rb
--- puppet/util/filetype.rb 2009-11-06 11:01:30.000000000 -0500
+++ puppet.mod/util/filetype.rb 2009-11-10 16:04:03.000000000 -0500
@@ -251,4 +251,49 @@ class Puppet::Util::FileType
output_file.delete
end
end
+
+ # Support for AIX crontab with differing ouput from suntab jon crontab
command.
+ newfiletype(:aixtab) do
+ # Read a specific @path's cron tab.
+ def read
+ begin
+ output = Puppet::Util.execute(%w{crontab -l}, :uid => @path)
+ return "" if output.include?("You are not authorized to use
the cron command")
+ raise Puppet::Error, "User %s not authorized to use cron" %
@path if output.include?("You are not authorized to use the cron command")
+ 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)
+ puts 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]
+ end
+ output_file.delete
+ end
+ end
end
</pre>
----------------------------------------
Bug #2798: Crontab does not work in AIX
http://projects.reductivelabs.com/issues/2798
Author: Andrew Forgue
Status: Needs design decision
Priority: Normal
Assigned to:
Category: cron
Target version: 0.25.2
Affected version: 0.25.1
Keywords: cron, aix
Branch:
Puppet's crontab support does not work in AIX.
Running crontab rules under AIX results in:
<pre>
crontab: cannot access
</pre>
This occurs when the crontab file is being flushed. The AIX crontab binary
does not permit reading from "-" (just like Solaris). The attached patch will
make the cron type work on AIX.
This defines a new "aixtab" crontab in provder/cron/cron.rb. And adds an entry
to util/filetype.rb for aixtab to recognize proper output messages (which are
different than Solaris, of course).
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://reductivelabs.com/redmine/my/account
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Bugs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/puppet-bugs?hl=en
-~----------~----~----~----~------~----~------~--~---