Cronjobs v1.2 rc1, a beta version fairly tested, successfully passed the ocf-tester. Currently running on a 2 node test cluster and a 3 node pre-production cluster.
Main feature: preserves all those crontab entries added either manually or by other bots. Pick up here: http://www.geocities.com/pica1dilly/cronjobs.zip Installation: 1) drop cronjobs in /usr/lib/ocf/resource.d/heartbeat on each cluster node, chmod u+x the file, 2) drop cronjobs.cf in /etc/ha.d on each cluster node, 3) edit cronjobs.cf on each cluster node to suit the local cron flavor, 4) eventually, if you are picky, specify your own logger commands to invoke in place of, or additionally to, the ocf_log( ) if your needs exceed the current implementation, 5) fire up the haclient.py, create a new primitive resource, scroll the list of types, cronjobs should appear is an ocf/heartbeat agent, 6) specify the user of the crontab to manage, the source file of the block of crontab instructions to enable and disable each time the resource is started and stopped, 7) fill in the crontab source file on each node with cron instructions to run when the resource is enabled on that node, eventually maintain only one shared copy of the crontab instructions to run on all nodes for which a specific resource is configured to run on, 8) start the resource, tah-Dah, showtime ! # Name: cronjobs, an OCF resource agent # Version: 1.2 beta, rc 1 # Author: Eric Defferard <[EMAIL PROTECTED]> # Last modification: 30-jun-2008 # License: GNU General Public License (GPL) Version 2, June 1991 # http://www.gnu.org/licenses/gpl-2.0.txt # Copyright: (c) 2008 Eric Defferard, all rights reserved # #==================================================================================== # # description: # Enables and disables as cron jobs, those cron job entries listed in a source file # which path is specified as parameter. # # The cron jobs are copied in the cron table of the user specified also as parameter. # # Unless an existing crontab entry is repeated exactly in a cron job source file, # the agent *preserves* all cron job entries previously configured in the user's # cron table. # # If a crontab file corruption is detected, the agent will automatically attempt to # fix the crontab by removing from the crontab *all* job entries specified in the # instance's cron job source file. # # Dillon cron (dcron) supported as hard coded default. # # OCF instance parameters: # - OCF_RESKEY_crontabusr # - OCF_RESKEY_crontabsrc # # OCF environment variables # - OCF_ROOT, expected, no defaults. # # config file: # - cronjobs.cf: # Search order: /etc/ha.d/cronjobs.cf, /etc/ha.d/conf/cronjobs.cf. # Contains the user specification of the crontab 'list' and 'replace' operations # to support different cron implementations while keeping the code independent, # as well as a 'logger' substitution operation for the ocf_log() function # called by default. # # The user specified 'logger' operation was prompted as a quick user-manageable # dynamic fix if user shys away from the "unfinished" or "to be improved" state # of the implementation of the ocf_log() function and underlying APIs. # # The required attributes for a config file are: # - must be a plain text file # - must be NON-world writeable, non-executable # - it's directory must be non-writeable # # Uses @@ encapsulated tokens that are automagically substituted # with real values passed as OCF instance parameters (see above), or # other values handled by the agent. # # Header: # # Configuration file for the 'cronjobs' OCF resource agent. # # Format: op = command , or # log_env_var = value # # Syntax: # - 'op' is: # - the crontab operation to specify # - 'list' # - 'replace', or # - the logging command that, if defined, shall be invoked # in place of, or following any routine call in this agent # to the standard ocf_log() function. # - 'logger' # - eval'd in place of call to ocf_log() # - '+logger' # - eval'd immediately following call to ocf_log() # # - 'command' is the exact command line that would be typed to # invoke the crontab operation # # - '=' is the operation or variable delimiter # # - '@user@' is the token used to specify where in the command line # the token should be substituted with the crontab user, # in both command lines used respectively to invoke # the 'list' and the 'replace' crontab operations, immediately # before the command line is eval'ed. # # - '@file@' is the token used to specify where in the command line # the token should be substituted with the crontab job # source file, specifically in the command line used to # invoke the 'replace' crontab operation. # # - '@msg@' is the token used to specify where in the specific 'logger' # command line the token should be substituted with the message that # is to be logged. # # - '@pri@' is the token used to specify where in the specific 'logger' # command line the token should be substituted with the syslog # priority that is to be assigned to a message that is to be logged. # # - '#', when the first non-blank character encountered in a line, # used to comment out the whole line. # # - '\', when the last non-blank character encountered in a line, # indicates the next line is the continuation of the current line. # # implementation notes: # # - originally thought of a task that would comment out and uncomment cron jobs # in the crontabs but realized there was then no reliable way to distinguish # those permanent jobs from those dependent on heartbeat controlled resources. # # - the config file is read using the bash 'read' command # # - uses internally those log priority level names specified for BSD 4.3 syslog, # before eventually converting the names to what APIs may require. Enjoy !
_______________________________________________________ Linux-HA-Dev: [email protected] http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/
