Forum: CFEngine Help Subject: Re: methods, usebundle and loops Author: zzamboni Link to topic: https://cfengine.com/forum/read.php?3,24644,24646#msg-24646
It's like toddni said - you are defining the same class on every call, and classes defined by a classes attribute are global. This is documented in https://cfengine.com/manuals/cf3-reference.html#classes-in-_002a: Synopsis: A list of classes to be defined globally So what you would have to do in a case like this is to define a different class for every value that you want to check. The following works: bundle agent echoname(name) { commands: "/bin/echo $(name)" ifvarclass => "!echo_run_$(name)", classes => if_repaired("echo_run_$(name)"); } In this particular case, as toddni said, it's not necessary to do the class-checking, because cfengine will automatically check if it has already run each command recently. Without the check, each name gets printed once, even if they are repeated in the list: bundle agent example { vars: "names" slist => { "paul", "george", "paul", "ringo", "ringo", "george", "john" }; methods: "any" usebundle => echoname("$(names)"); } bundle agent echoname(name) { commands: "/bin/echo $(name)"; } Of course, this may not be the case for a real example, so you may still need to do the ifvarclass/classes combination in your real promises. _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine