help-cfengine
[Top][All Lists]
Advanced

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

Re: Cfengine Feature Wish List?


From: Marion Hakanson
Subject: Re: Cfengine Feature Wish List?
Date: Thu, 15 May 2003 11:28:42 -0700

Folks,

The "import when class is defined" approach suffers from the fact that
you'll have to also import any files that want to _use_ the groups/classes
defined in the imported file (the parent file won't see things defined in
anything it imports).  It takes some careful coordination to keep all those
imported sub-files in sync with each other.

I'd settle for being able to combine previously-defined classes and/or
builtin primitives in the groups section, like this:

groups:
  hasrpm = ( FileExists(/bin/rpm) )
  haspkginfo = ( FileExists(/usr/bin/pkginfo) )

  hasacroreadrpm = ( hasrpm.ReturnsZero(/bin/rpm -q --quiet acroread) )
  hasacroreadpkg = ( haspkginfo.ReturnsZero(/usr/bin/pkginfo -q CFSTacrs4) )

  hasacroread = ( hasacroreadrpm hasacroreadpkg )


As it is now (in cfengine-2.0.5, anyway), you can combine simple classes
in the class definitions, but you cannot combine classes with the results
of those builtins (attempts result in the error message, "Wildcards cannot
be used in this context").  You can't even negate the result of a builtin.

If you twist the logic around into knots (using negation & OR instead
of AND) and create some superfluous class definitions, one can sorta get
the desired result:

classes:
  hasrpm = ( FileExists(/bin/rpm) )
  norpm = ( !hasrpm )

  haspkginfo = ( FileExists(/usr/bin/pkginfo) )
  nopkginfo = ( !haspkginfo )

  mayhaveacroreadrpm = ( norpm ReturnsZero(/bin/rpm -q --quiet acroread) )
  mayhaveacroreadpkg = ( nopkginfo ReturnsZero(/usr/bin/pkginfo -q ADacrord) )

  hasacroread = ( hasrpm.mayhaveacroreadrpm haspkginfo.mayhaveacroreadpkg )


Note that the above works, but it shows the need (in my opinion) for
another feature -- that of evaluating only as many parts of the right-hand
side of the class definition as necessary.  In the above example, if "norpm"
is true, one can avoid attempting to execute the "/bin/rpm" command.  Version
2.0.5 goes ahead and tries it, giving a "script failed" warning on a system 
where rpm is not present, but the rest of the file continues just fine.
That's OK in this example, but if the command were to produce a change
in the system, that could be undesirable.


Oh, and in the name of completeness, here's yet another example of how one
can work around the lack of this functionality.  Basically, we use the shell
to do the work that cfengine can't do:

=============================================================

control:
  actionsequence = ( shellcommands )

  linux::
    shell = ( /bin/bash )
    pkgcmd = ( /bin/rpm )
    pkgcmdline = ( "${pkgcmd} -q --quiet" )
    acropkg = ( acroread )

  solaris::
    shell = ( /bin/ksh )
    pkgcmd = ( /usr/bin/pkginfo )
    pkgcmdline = ( "${pkgcmd} -q" )
    acropkg = ( ADacrord )


classes:
  hasacroread = ( ReturnsZero(${shell} -c "[ -x ${pkgcmd} ] && ${pkgcmdline} 
${acropkg}") )


shellcommands:
  hasacroread::
    "/bin/echo has acroread"

  !hasacroread::
    "/bin/echo no acroread present"

=============================================================

Regards,

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



> > -----Original Message-----
> > From: Wheeler, John [mailto:jwheeler@eb.com] 
> > Sent: Thursday, May 15, 2003 7:21 AM
> > To: Help-cfengine@gnu.org
> > Subject: RE: Cfengine Feature Wish List?
> > 
> > 
> > A bit more work, but couldn't you do:
> > 
> > import:
> >     redhat::
> >             redhatclassstuff.conf
> > 
> > 
> > 
> > <redhatclassstuff.conf>
> > 
> > classes:
> >     vimRPMinstalled = ( ReturnsZero(/bin/rpm -q --quiet
> > vim-enhanced) )
> >     
> > 
> > This should satisfy the first requirement: 
> > > One reasoning I have for this is because I don't want to run the RPM
> > > command if I am not on a Red Hat system.  For example Debian or
> > Solaris.






reply via email to

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