verbose: V: BEGIN variables (pass 1)
verbose: C: BEGIN classes / conditions (pass 1)
Grepping for promises that run on the frist pass
Write policy that tells you
This policy uses conditionals to determine if classes are evaluated before
variables, or if variables are evaluated first. It shows the determination
using reports guarded on the class that describes which is evaluated first.
bundleagentmain#@ brief Demonstrate if vars or classes come first
{classes:"classes_are_first"expression=>not(isvariable("main.classes_are_first"));"vars_are_first"expression=>isvariable("main.vars_are_first");vars:"classes_are_first"string=>"Classes come first";"vars_are_first"string=>"Vars come first",if=>not("vars_are_first");reports:"CFEngine $(sys.cf_version)";"$(classes_are_first)"if=>"classes_are_first";"$(vars_are_first)"if=>"vars_are_first";}
Policy to demonstrate evaluation order in cfengine 3
You can use the with attribute and ifelse() to reduce the policy a bit.
bundleagentmain#@ brief Demonstrate if vars or classes come first
{classes:"classes_are_first"expression=>not(isvariable("main.variable"));"vars_are_first"expression=>isvariable("main.vars_are_first");vars:"classes_are_first"string=>"Classes come first";"vars_are_first"string=>"Vars come first",if=>not("vars_are_first");reports:"CFEngine $(sys.cf_version)";"Without intermediary vars: $(with)"with=>ifelse(classes_are_first,"ifelse: Classes come first",vars_are_first,"ifelse: Vars come first","Logic Error");}
Policy to demonstrate evaluation order in cfengine 3