Forum: CFEngine Help
Subject: Trouble with dynamic inputs
Author: neilhwatson
Link to topic: https://cfengine.com/forum/read.php?3,24015,24015#msg-24015
I'm experimenting with dynamic inputs. Something in the way inputs are
determined confounds me. Consider this test.
bundle common g {
vars:
team_defined::
"inputs" slist => { "1.cf" };
!team_defined::
"inputs" slist => { "2.cf" };
classes:
"team1" or => {
"host1_sub1_example_com",
"host2_sub1_example_com",
"host3_sub1_example_com",
};
"team2" or => {
"host1_sub2_example_com",
"host2_sub2_example_com",
"host3_sub2_example_com",
};
"team3" or => {
"host1_sub3_example_com",
"host2_sub3_example_com",
"host3_sub3_example_com",
};
"team_defined" expression => classmatch("team.*");
}
body common control {
bundlesequence => { "main" };
inputs => { "cfengine_stdlib.cf", @{g.inputs} };
version => "NHW testing";
}
bundle agent main {
reports:
cfengine_3::
"Main bundle";
}
If either of the three teams classes are defined I expect inputs to include the
file 1.cf. If none of those classes are defined I expect inputs to include
2.cf instead.
cf-promises -vf ./test.cf -D team1
....
cf3> ?> defining additional global class team_defined
cf3> > Parsing file ./cfengine_stdlib.cf
cf3> Initiate variable convergence...
cf3> !! Redefinition of a constant list "inputs".
cf3> Old value: {'2.cf'}
cf3> New value: {'1.cf'}
cf3> Promise (version NHW testing) belongs to bundle 'g'
in file './test.cf' near line 6
cf3> -> Checking common class promises...
cf3> Can't stat file "./2.cf" for parsing
cf-promises -vf ./test.cf
...
cf3> Initiate variable convergence...
cf3> -> Checking common class promises...
cf3> Can't stat file "./2.cf" for parsing
In both cases 2.cf is in inputs; never 1.cf. I think that Cfengine uses
$(g.inputs) during the first pass and does not make the correction when
$(g.inputs) would change during the second pass. Thoughts? Alternatives?
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine