Forum: CFEngine Help
Subject: Re: Explanation for 3x iteration in a bundle
Author: sauer
Link to topic: https://cfengine.com/forum/read.php?3,24402,24412#msg-24412
So, cf-agent runs through the whole bundle three times, in the same order. In
your last example, you have vars, commands, and reports. On the first
iteration, red isn't defined in vars, so the var isn't defined. Your module
command runs and defines the red class. Then reports are evaluated, and since
red is defined at that time, the report is generated based on a variable which
is not set. Upon the second iteration, red is defined, so the variable gets
set, and the other promises have already been evaluated.
If you depend on the variable being set, one workaround would be to define a
class based on the existence of the variable. For example:
bundle agent test {
vars:
red::
"redvar" string => "redvar";
classes:
red::
"hasred" expression => isvariable("redvar");
commands:
"/root/setredclass.sh"
module => "true";
reports:
hasred::
"$(redvar) is the value of redvar.";
}
This kind of somewhat complicated issue is precisely why one of the solutions
guide or reference manual indicates that complex variable / class dependencies
are a bad idea. :)
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine