help-cfengine
[Top][All Lists]
Advanced

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

Re: [Cfengine] copy: templates


From: Bas van der Vlies
Subject: Re: [Cfengine] copy: templates
Date: Wed, 14 May 2003 12:07:53 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3.1) Gecko/20030425

Will Lowe wrote:
I'm using cfengine 2.x (right now 2.0.4, but I don't mind upgrading)
under Debian woody.  Let's say I have several variables set in my
cfagent program named $cfgroot, $site, $type, and $host, with the
obvious meanings.

I'd like to do something like this:

copy:

        $cfgroot/$host/etc/resolv.conf dest=/etc/resolv.conf recurse=inf
# if it exists, otherwise try:
        $cfgroot/$type/etc/resolv.conf dest=/etc/resolv.conf recurse=inf
# if it exists, otherwise try:
        $cfgroot/$site/etc/resolv.conf dest=/etc/resolv.conf recurse=inf
# if it exists, otherwise try:
        $cfgroot/default/etc/resolv.conf dest=/etc/resolv.conf recurse=inf

.. in other words, I'd like to be able to maintain (possibly partial)
sets of configs for each of $site, $type, $host, and a default set,
and have cfengine automatically find the "most specific" action to
apply.

An additonal catch is that I'd like to do it for *every* *single* copy
statement anywhere in the cfagent config (find the most specific
resolv.conf, the most specific set of apache configs, the most
specific /etc/nsswitch.conf, etc.) -- a generic templating system.

Using groups/classes might be possible:

sitefoo.farma:
        copy resolv.conf.1234

sitefoo.!farmb.farmc.!sitebar:
        copy resolv.conf.4321

siteBaz.farmF:
        copy resolv.conf.0987

.. but with 15 farms, 1000 servers, and 10 sites, the number of
possibly needed rules becomes insane.  It'd be a lot simpler if
cfengine could find the "best match" somehow on its own ... any ideas?


I think the trick is: (From the reference manual)
SingleCopy


        singlecopy = ( on )



If singlecopy is defined the behavior of copy: is modified so that a file will only be copied once, helping to achieve hierarchical or "most specific" file copy overrides, provided that the most specific file occurs first. With the following file structure on a host running cfservd:

/dist/hosts/loghost1.example.com/etc/syslog.conf /dist/solaris/etc/syslog.conf /dist/all/etc/syslog.conf

The configuration:

     control:
        singlecopy = ( on )

     copy:

/dist/${fqhost} dest=/ inform=true syslog=true r=inf server=disthost /dist/${ostype} dest=/ inform=true syslog=true r=inf server=disthost /dist/all dest=/ inform=true syslog=true r=inf server=disthost



Would result in:

/dist/hosts/loghost1.example.com/etc/syslog.conf being copied to loghost1.example.com
     /dist/solaris/etc/syslog.conf being copied to Solaris systems
     /dist/all/etc/syslog.conf being copied to all other systems


--
--
********************************************************************
*                                                                  *
*  Bas van der Vlies                     e-mail: basv@sara.nl      *
*  SARA - Academic Computing Services    phone:  +31 20 592 8012   *
*  Kruislaan 415                         fax:    +31 20 6683167    *
*  1098 SJ Amsterdam                                               *
*                                                                  *
********************************************************************





reply via email to

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