Nick, There is a bit of magic to properly resolve class-variable dependencies. This is mentioned in the reference guide: https://cfengine.com/manuals/cf3-Reference#Agent-normal-ordering
CFEngine tries to keep variable and class promises before starting to consider any other kind of promise. In this way, global variable and classes can be set, as well as creating classes promises, upon which later agent-bundle vars promises may depend. And this is witnessed in the verbose output from your example: nova> ========================================================= nova> classes in bundle test (1) nova> ========================================================= nova> nova> ?> defining explicit local bundle class debug nova> Initiate variable convergence... nova> !! Duplicate selection of value for variable "filename" in scope test nova> !! Rule from ./test-debug.cf at/before line 19 Note the "Initiate variable convergence" right after the class definition, which means variables are reevaluated (in my testing, any class definitions will trigger the variable convergence step). This is where you get the "Duplicate selection of value" - note that CFEngine warns you, but still assigns the new value. Thus by the time it gets to the files: promises, the variable already has the correct value. Best regards, --Diego On Jul 31, 2012, at 10:26 AM, Nick Anderson <n...@cmdln.org> wrote: > On 07/31/2012 10:18 AM, Tokarski Boleslaw wrote: >> Normal ordering specifies that vars are run before classes. So before >> anything else happens below this, debug is not declared, so "filename" >> is set to "/tmp/nodebug". >> >> Then, the class debug is declared, on the second CFEngine iteration this >> should point that "filename" var is to be redefined to "/tmp/debug". >> However, the default "vars" policy is "constant", as per: >> https://cfengine.com/manuals/cf3-Reference#policy-in-vars >> so it cannot be redefined, but it is supposed to, thus the warning about >> re-declaration. > > Sure, I understand the warnings about redeclaration. > > The thing is, /tmp/debug is created on the first pass of files, when > $(filename) should be set to /tmp/nodebug because the debug class is not > defined. > > > cf3> ========================================================= > cf3> classes in bundle test (1) > cf3> ========================================================= > cf3> > cf3> ?> defining explicit local bundle class debug > cf3> Initiate variable convergence... > cf3> !! Duplicate selection of value for variable "filename" in scope test > cf3> !! Rule from ./test_variable_convergance.cf at/before line 20 > cf3> > cf3> + Private classes augmented: > cf3> + debug > cf3> > cf3> - Private classes diminished: > cf3> > cf3> > cf3> > cf3> ========================================================= > cf3> files in bundle test (1) > cf3> ========================================================= > cf3> > cf3> > cf3> ......................................................... > cf3> Promise's handle: > cf3> Promise made by: "/tmp/debug" > cf3> ......................................................... > cf3> > cf3> -> Using literal pathtype for /tmp/debug > cf3> -> No mode was set, choose plain file default 600 > cf3> -> Created file /tmp/debug, mode = 600 > cf3> ?> defining promise result class repaired__tmp_debug > cf3> -> Handling file existence constraints on /tmp/debug > > _______________________________________________ > Help-cfengine mailing list > Help-cfengine@cfengine.org > https://cfengine.org/mailman/listinfo/help-cfengine
_______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine