help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Puzzler: Can cfengine replace make?


From: Marion Hakanson
Subject: Re: Puzzler: Can cfengine replace make?
Date: Tue, 06 Nov 2001 11:22:17 -0800

Steve Traugott wrote:

> (Cc'ing to both help-cfengine@gnu.org and infrastructures@terraluna.org).
> 
> Many of us commonly use 'make' as a state engine for tracking
> long-term dependencies over the life of a machine.  For instance,
> here's a fragment of a real-world makefile, used in a AIX environment,
> . . .
> Now, here's the question:  Can anyone see a way to do this once-only
> type of action cleanly in cfengine?  I've tried several different ways
> over the years, but I've never been satisfied with the results.  
> 
> Steve

Folks,

We've also been frustrated here with cfengine's apparently not having a
way to represent make-like semantics ("update this item only if it's older
than the source").  A former colleague came up with a trick for dealing
with this issue in the "editfiles:" section of a cfengine file, basically
by embedding a timestamp within the file being edited.  Here's an excerpt:

###################################################################
. . .
editfiles:

        any::
        { $(crondir)/root
        AutoCreate

        # you must change both (matching!) test blocks to have it work
        BeginGroupIfNoMatch "# cfengine messed with this 2001/07/20"
                EmptyEntireFilePlease
                DeleteLinesStarting "# cfengine messed with this"
                Prepend "# cfengine messed with this 2001/07/20"
                Append "#"
                Append "# this is maintained by cfengine, don't change locally."
                Append "#"
                Append "# min    hour    daymo   month   daywk   cmd" 
                Append "#"
        EndGroup
        }

        (solaris|linux).webserver::
        { $(crondir)/root

        AppendIfNoSuchLine "# Rotate Web logs monthly"
        AppendIfNoSuchLine "10 0 1 * *   /usr/local/sbin/apache_log_rotate"
        }

        mysqlhost::
        { $(crondir)/root
        AppendIfNoSuchLine "# Rotate mysql logs"
        AppendIfNoSuchLine "10 1 * * 0 /var/local/mysql/rotate_mysql"
        AppendIfNoSuchLine "30 21 * * * /var/local/mysql/dbsnap"
        }
. . .
###################################################################



Please note that we're not very sophisticated in our use of cfengine,
so feel free to point out better ways to do something like this.
Currently we're manually generating those internal timestamp strings,
so of course it's error-prone.

And even with the above approach, it's possible to make a change which
only affects a particular host (e.g. "mysqlhost" above), but still end
up editing files on every host.  To deal with this issue, I imagine one
would need a timestamp for each edit section -- automation is the only
way to deal with this (use make+something to generate the cfengine config?).

Personally, I prefer to use something like make+m4 or make+perl to
generate conditional-content config files and install them as necessary,
either on each target host (pushed out with "scp"), or into a config-file
area which is referenced by a cfengine "copy" section.  This way the only
changes made on target hosts are for those where changes are necessary.

-- 
Marion Hakanson <hakanson@cse.ogi.edu>
CSE Computing Facilities





reply via email to

[Prev in Thread] Current Thread [Next in Thread]