[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Editfiles DefineClasses does not seem to work
From: |
ABostick |
Subject: |
RE: Editfiles DefineClasses does not seem to work |
Date: |
Mon, 12 Aug 2002 14:12:06 -0500 |
David,
Thanks for the config snippet. I already had my dynamic classes defined in
AddInstallable. The problem was I did not quote my dynamic class name in
the DefineClasses statement. e.g.:
Changing
DefineClasses cronrestart
To
DefineClasses 'cronrestart'
fixed it. Crazy no? :)
Thanks for the help,
Aaron
-----Original Message-----
From: David J. Bianco [mailto:bianco@jlab.org]
Sent: Monday, August 12, 2002 12:37 PM
To: Bostick, Aaron PH/US
Cc: help-cfengine@gnu.org
Subject: Re: Editfiles DefineClasses does not seem to work
On Mon, 2002-08-12 at 13:09, ABostick@mydoconline.com wrote:
> I am trying to define a class based on the edit of a file with
> DefineClasses. I use editfiles to edit my crontab, but the dynamic class
> does not get instantiated. I am trying to trigger a HUP to cron based on
> the edit of a crontab but with no luck...
>
> Is this an unimplemented feature or known bug?
>
It works for me in several places. I do something like the following:
-------------------------------------------------
control:
AddInstallable = ( CFE_INIT_CHANGED CFE_CRONTAB_MODIFIED )
editfiles:
# Create a crontab entry to run cfagent on a regular basis.
# If we end up having to edit the crontab because the lines aren't
# already there, define CFE_CRONTAB_MODIFIED so we can restart cron
# later.
linux::
{ /var/spool/cron/root
Backup yes
AutoCreate
Inform yes
DefineClasses "CFE_CRONTAB_MODIFIED"
BeginGroupIfNoLineMatching "0,30.*restart-cfexecd.*"
Append "0,30 * * * * /var/cfengine/bin/restart-cfexecd"
EndGroup
}
shellcommands:
# If we modified the crontab file in the editfiles section, restart
# cron right now to read in the new entries
linux.CFE_CRONTAB_MODIFIED::
"/etc/rc.d/init.d/crond restart" preview=false umask=022
-------------------------------------------------
You probably just need to add the AddInstallable statement like
mine above. If you dynamically define classes during runtime,
cfengine needs to know about them first. The cfagent actually
iterates over each type of action up to 5 (I think) times to
make sure that all possible actions are performed. If you don't
use AddInstallable, cfengine might not know that it's possible for
a certain class to be defined at run time, so it might incorrectly
compute that all possible actions have been taken for a given
stanza. You can get a better explanation from the AddInstallable
documention on the web site, but this sounds like it might be all
you need.
David
--
David J. Bianco, GSEC <bianco@jlab.org>
Thomas Jefferson National Accelerator Facility
The views expressed herein are soley those of the author and
not those of SURA/Jefferson Lab or the US DOE.