Forum: Cfengine Help
Subject: Re: Force variables to be defined after classes?
Author: [email protected]
Link to topic: https://cfengine.com/forum/read.php?3,18656,18677#msg-18677
A simple example I can give is when I am in a agent bundle, and I want to
define a variable one-way-or-the-other depending upon the classes within the
same bundle.
Since Cfengine is so much dependent upon classes based, I think of classes as
the first class citizen of decision making and in some cases it makes sense for
them to be evaluated first.
This would break some instances, as some class definitions are dependent upon
reading a variable. So maybe add an additional function of
"evaluate_class_first()" when you wanted this behavior?
bundle agent test
{
vars:
some_class::
"foo" string => "time to upgrade"
other_class::
"foo" string => "no need to upgrade"
classes:
"some_class" expression => something
"other_class" expression => some_other_thing
reports:
cfengine_3::
"the variable of $(foo) here should be whatever was defined in the
local class";
}
Yes, I suppose you could call
bundle common test
{
classes:
methods:
"any" usebundle => real_bundle_i_wanted_to_execute_in_the_first_case
}
###
bundle agent real_bundle_i_wanted_to_execute_in_the_first_case
{
vars:
::
"foo" string => "blah"
}
So, i suppose that would work, but it adds a layer of misdirection and
confusion.
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine