help-cfengine
[Top][All Lists]
Advanced

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

Re: Determine file to copy based on classes


From: Mark . Burgess
Subject: Re: Determine file to copy based on classes
Date: Thu, 30 Jan 2003 19:58:13 +0100 (MET)

The cfengine way of doing this is to put the hosts and their
resources in the same class container. Then it happens automatically

M

On 26 Oct, Kai Gro├čjohann wrote:
> Is there a way to implement something like the following algorithm in
> CFengine?
> 
> /----
> | repository=$CFINPUTS/../files # Repository of config files.
> | file=etc/printcap             # Config file to consider.
> | prio="$HOST laptop desktop linux default"
> | 
> | # Determine subset of $prio that is actually defined in $CFALLCLASSES.
> | # Keep same order as in $prio.
> | classes=""
> | for x in $prio; do
> |     case :${CFALLCLASSES}: in
> |         :${x}:)
> |             classes="${x} ${classes}"
> |             ;;
> |     esac
> | done
> | 
> | # Now search for an existing file and copy the first file found.
> | for c in $classes; do
> |     if [ -f $repository/$file/$c ]; then
> |         cp $repository/$file/$c /$file
> |         exit 0
> |     fi
> | done
> \----
> 
> What with all this automatic iteration over colon-separated lists and
> so on it should be possible.  But how?
> 
> The above is only meant to convey a general idea.  It does not have
> to be this exact logic.  The issue is I want to write some files in
> the repository and CFengine should automatically pick the "right"
> one.  And I don't want to write a file for each host.  (Of course, it
> would be easy to copy the file that's named like the host.)  Instead,
> I want to write files that are named after CFengine classes, and the
> most specific file should be preferred.
> 
> kai



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Work: +47 22453272            Email:  address@hidden
Fax : +47 22453205            WWW  :  http://www.iu.hio.no/~mark
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~






reply via email to

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