help-cfengine
[Top][All Lists]
Advanced

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

Re: bug in iteration?


From: Mark . Burgess
Subject: Re: bug in iteration?
Date: Fri, 9 Jan 2004 09:58:17 +0100 (MET)

On 31 Dec, Luke A. Kanies wrote:
> Hi all,
> 
> I'm messing with iteration in the shellcommands, and I've found some
> strange behaviour.
> 
> If I have the following config:
> 
> groups:
>    one = ( myhost )
>    two = ( myhost )
> 
> control:
>    AllowRedefinitionOf = ( variable name )
>    testcmd = ( "/bin/echo" )
> 
>    one::
>       name = ( one )
>       variable = ( "${name}" )
> 
>    two::
>       name = ( two )
>       variable = ( "${variable}:${name}" )
> 
>    actionsequence = (
>       shellcommands.testing
>    )
> 
> 
> shellcommands:
> 
>    testing::
>       "${testcmd} ${variable}"
> 
> and I run cfagent against it I get:
> 
> 
> cfengine:pixie:/bin/echo one: one
> cfengine:pixie:/bin/echo two: two
> 
> But I make the following change:
> 
>    one::
>       name = ( one )
>       variable = ( "${variable}:${name}" )
> 
> I get the following output:
> 
> cfengine:pixie:/bin/echo ${var: :one:one:two
> cfengine:pixie:/bin/echo one: one
> cfengine:pixie:/bin/echo two: two
> 
> In other words, if a variable starts with the iteration character, then
> the first time the shellcommand is run it is run with the entire contents
> of the variable, the iteration character is removed, and then the variable
> is iterated over normally.
> 
> This seems like a bug to me, but can anyone confirm that?
> 
> Also, can anyone explain to me why 'one' is getting added to the variable
> twice?  Is it because cfengine makes two passes?  If so, why isn't 'two'
> being added twice?
> 
> And if anyone can provide a better way to set dummy classes than the way I
> am using, I'd love to hear about it.  I would like a simple method of
> setting a bunch of classes, conceptually similar to this:
> 
> groups:
> 
>    hostname::
>       class1 = class2 = class3 = class4 = 1
> 
> I know, this type of syntax doesn't work in cfengine, but I want a
> relatively simple way to set a bunch of classes based on whether another
> class is set.  Cfengine seems to prefer I use modules to do that, and I
> would really prefer not to.
> 
> Thanks,
> Luke
> 

This seems to work ok in 2.1.0p1



control:

   testcmd = ( "/bin/echo" )

   name = ( ":::one:two::three" )
   actionsequence = ( shellcommands  )

shellcommands:

      "${testcmd} ${name}"



nexus$ ./cfagent -f ../../Tests/cftest -K
cfengine:nexus:/bin/echo one: one
cfengine:nexus:/bin/echo two: two
cfengine:nexus:/bin/echo three: three


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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]