help-cfengine
[Top][All Lists]
Advanced

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

Re: dynamis class creation


From: Bob Van Cleef
Subject: Re: dynamis class creation
Date: Mon, 15 Jul 2002 12:48:12 -0700 (PDT)

Hurray!!  I finally have gotten something that works!

On Mon, 15 Jul 2002, Vilius Puidokas wrote:

> what about using cfengine's logic for classes, like:
>  RH72 = ( "/bin/grep 7.2 /etc/redhat-release" )
>  amd = ( "/bin/grep amd /etc/whatever-amd-file" )
>  RH = ( RH1 RH62 RH72 )
> 
>  RH::
>    do whats common for all RH boxes
>  RH.!amd-very-specific::
>    except amd-very-specific boxes which conflict with RH standarts and
> shouldnt be really called RH :)
> 
>  RH.amd-mod::
>    do whats common for all amd stuff
>  RH.amd-very-specific::
>    do something very special
> 
> v

This is exactly what I wanted to do - however, it did not work as in your
examples, every one of those classes would be set, irregardless of the
output of the "grep".  (see reason below)

>From the documents:
        http://www.cfengine.org/docs/cfengine-1.6.3.Reference.html
--------------------------------------------------------------------------
Finally, you can define groups (strictly classes) by the result of a shell
command. A shell command or program is deemed to be `true' if it exits
with a status of zero, i.e. it calls exit(0). Any other value is taken to
be false. You can include shell commands as the members of groups in order
to define classes based on the outcomes of your own scripts by enclosing
the script in single or double quotes:

   have_cc = ( '/bin/test -f /usr/ucb/cc' )

--------------------------------------------------------------------------

I had in my cfengine script:
--------------------------------------------------------------------------
groups:
    rh60 = ( '/usr/local/etc/cfengine/check-os 6.0' )
    rh62 = ( '/usr/local/etc/cfengine/check-os 6.2' )
    rh73 = ( '/usr/local/etc/cfengine/check-os 7.3' )
--------------------------------------------------------------------------

The script returned "echo -n $NULL" on a match or does "echo DOES NOT 
MATCH" on failure to match.  Unfortunately, all groups were always set!

The problem was that I was looking at the script's "return value" and not
at the shell execution status variable!!!  See the docs: "calls exit(0)"

I changed my os levet test script to:
--------------------------------------------------------------------------
if [ "$LEVEL" = "$OS" ]
then
        exit 0
else
        # NOT A MATCH
        exit 1
fi
--------------------------------------------------------------------------


This works!!!  Now I don't have to worry about trying to juggle a 2.x
upgrade across systems ranging from SunOS 4.1.4 to Solaris 8, RedHat 6.0
to RedHat 7.3, etc....

Bob




reply via email to

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