Forum: CFEngine Help
Subject: Re: Passing parameters to methods bundle
Author: zzamboni
Link to topic: https://cfengine.com/forum/read.php?3,26825,26833#msg-26833
(I've added this comment to the bug report)
This seems to be a pass-related evaluation issue. If the variable assignments
are conditioned to occur on the second pass, then everything works fine. This
example produces the correct results:
body common control {
bundlesequence => { "main" };
}
bundle agent main {
methods:
"any" usebundle => test("root","5","10");
}
bundle agent test(user,num1,num2){
vars:
secondpass::
"list1" rlist => { "$(num1)", "100" };
"list2" rlist => { "$(num2)", "100" };
"x" real => product("list1");
"y" real => sum("list2");
"no_of_fields" int =>
getfields("^$(user):.*","/etc/passwd",":","userdata");
"list3" rlist => { "$(userdata[3])", "100" };
"z" real => sum("list3");
classes:
"secondpass" expression => "any";
reports:
cfengine_3::
"x = $(x)";
"y = $(y)";
"z = $(z)";
}
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine