help-cfengine
[Top][All Lists]
Advanced

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

Re: Scalable remote config


From: Chip Seraphine
Subject: Re: Scalable remote config
Date: Sun, 16 Nov 2003 01:30:52 -0000 (GMT)
User-agent: WebMail/1.4.1

> Ok, here's the senario:
>
> Have an application that has one configuration file. All the remote
> boxes have a 'default' set of values in the config file I want to keep
> in one file. But the other part of the file is host dependant. I tried
> using editfiles with InsertFile to append two files and create a new
> config file. I then realized that editfiles does not support copying to
> remote boxes.
>
> One way around this is to use editfiles on the local master server,
> creating appending the files there, and then using copy to distribute
> the files to the remote boxes. To me and my peers, this is an ugly way
> around our problem.
>
> Is there a better solution to this problem?

Only if you are willing to do some extra work.  You can store the entire
file contents in the cfengine script and rebuild it, or you can copy the
templates out and then do the surgery.  Neither is very practical.

In my shop I have (on the cfengine "server") an exported directory called
"perhost".  In it is a subdirectory for every host on the system (they
create these directories themselves when they first run cfengine).  In
situations like yours, I stick host-specific "master" files in the
perhosts area and use cfengine to copy them out when the local files get
outdated.

Using something like this, you could do the following (a tad convoluted
but works fine):

Have one file representing the static information and another representing
the host specific.  (This might be an m4 template and a definitions file
or a pair of file 'snippets', either works fine for this example.)  The
host-specific file can reside in the 'perhost' area, as does their
combined output (the host-specific 'master' file).   Give cfengine a rule
that says that when either source file is newer than the master, rerun
whatever procedure generates the master from source.  The regular copy
stuff takes care of the rest.

Below is an example where you are appending two files and a perhost dir is
available on NFS.  You could easily adapt it to copying via cfengine's
native pseudo-rsync stuff, but you would need to do the template copies to
a local scratch directory before comparing them.   If you want to
generated it from a script or m4 thingie, just use shellcommands: to fire
the parser rather than editfiles:.  At any rate, if done correctly you
will have each host on the network regenerating their 'info' file whenever
either source file is modified.

control:
  hostdir = ( /opt/cfengine/perhost/$(host)/ )
  actionsequence = ( editfiles copy )

groups:
  update_stuff = ( IsNewerThan(/somewhere/info.header,$(hostdir)/info.out
                   IsNewerThan($(hostdir)/info.host,$(hostdir)/info.out )
editifles:
  update_stuff::
    { $(hostdir)/info.out
        EmptyEntireFilePlease
        InsertFile "/somewhere/info.static"
        InsertFile "$(hostdir)/info.host"
        Prepend "#File generated on $(date)"
    }

copy:
   $(hostdir)/info.out dest=/path/to/info type=checksum









reply via email to

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