Forum: CFEngine Help
Subject: Re: problem programatically generating arrays from files
Author: phnakarin
Link to topic: https://cfengine.com/forum/read.php?3,22966,22967#msg-22967
Since CFE doesn't like the way you define variables, why don't you move
"no_e_fields" int =>
getfields("type\|env\|.*","${datafile}","\|","efields");
"no_h_fields" int =>
getfields("host${spl}type${spl}env.*","${datafile}","${spl}","hfields")
to bundle agent make_config(type, evn). I haven't tried the code but it should
look like the following; Hopefully, CFE doesn't complain.
bundle agent make_config(type, env)
{
vars:
"no_e_fields" int =>
getfields("type\|env\|.*","${my_app.datafile}","\|","efields");
"no_h_fields" int =>
getfields("host${my_app.spl}type${my_app.spl}env.*","${my_app.datafile}","${my_app.spl}","hfields"
"mykey" slist => getindices("efields");
"my_h_key" slist => getindices("hfields");
"w[$(hfields[$(my_h_key)])]" string =>
"${my_app.host_${type}_${env}[${my_h_key}]}";
"w[${efields[${mykey}]}]" string =>
"${my_app.env_${type}_${env}[${mykey}]}";
reports:
linux::
"${w}: installing ${w}-my_app in ${w} in /path/to/app//${w} ${w}";
}
Cheers,
--Nakarin
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine