> How do I know if vars or classes come first during cfengine evaluation?
Read the documentation on Normal Order
There is a wealth of information on docs.cfengine.com. Find documentation about the order of agent promise evaluation (Normal Order) in the Language Concepts section of the Reference manual.
Run the agent with –verbose or -v and grep for pass 1.
Write a test policy that has both vars and classes promises.
|
|
/tmp/test.cf
Grep the verbose output.
|
|
verbose: V: BEGIN variables (pass 1) verbose: C: BEGIN classes / conditions (pass 1)
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.
|
|
R: CFEngine 3.11.0 R: Vars come first R: Without intermediary vars: ifelse: Vars come first
You can use the with
attribute and ifelse()
to reduce the policy a bit.
|
|
R: CFEngine 3.11.0 R: Without intermediary vars: ifelse: Classes come first
with
and ifelse()
to demonstrate evaluation order in cfengine 3