Martin Simons <mjcm....@gmail.com> writes:
> Dear CFEngineer,
>
> Some of you who know me, know I'm fond of arrays.
>
> To be honest, I am puzzled. I thought this would work, where do I go wrong?
I made a few of minor modifications to your policy:
bundle agent main
{
methods:
"common";
}
bundle agent common {
vars:
# Get the index from the named variable, not its expansion.
"index" slist => getindices("data.array");
methods:
"" usebundle => usevar( $(data.test) )
;
# Pass the NAME of the variable, not its expansion.
"" usebundle => use_array( "data.array" );
reports:
"$(this.bundle): data.test = $(data.test)";
"$(this.bundle): index value = $(index)";
}
bundle agent usevar(var) {
reports:
"$(this.bundle): $(var)";
}
bundle agent use_array(array) {
vars:
"index" slist => getindices( $(array) );
reports:
"$(this.bundle): $(index)";
"$(this.bundle): $(array[$(index)])";
}
bundle agent data {
vars:
"test" string => "Test variable for common";
"array[one]" string => "one";
"array[two]" string => "two";
}
R: usevar: Test variable for common R: use_array: two R: use_array: one R: common: data.test = Test variable for common R: common: index value = two R: common: index value = one
–
Nick Anderson
Doer of things, CFEngine