It's a known bug: dynamically-added array elements are only visible to getindices() and getvalues() until the next pass over the policy. See https://cfengine.com/bugtracker/view.php?id=904 for a description and workaround.
--Diego On Aug 28, 2012, at 3:02 AM, no-re...@cfengine.com wrote: > Forum: CFEngine Help > Subject: Contrived example : getindices returns an empty list > Author: jbd > Link to topic: https://cfengine.com/forum/read.php?3,27120,27120#msg-27120 > > Hello everybody, > > i'm running CFEngine 3.3.5. > > I've build the following contrived example, and I don't understand why the > imyarray list is empty (Also available here with the verbose cfagent output : > https://gist.github.com/3496634) : > > > body common control > > { > > bundlesequence => { "test" }; > > } > > > bundle agent test > > { > > vars: > > "indices" slist => { "a", "b", "c", "d" }; > "indices_$(indices)" string => "$(indices)"; > "myarray[$(indices_$(indices))]" string => "$(indices)"; > "imyarray" slist => getindices("myarray"); > > reports: > cfengine_3:: > "myarray : $(myarray[$(indices_$(indices))])"; > "imyarray : $(imyarray)"; > } > > > Output : > > # cf-agent -K -f ./test.cf > > > R: myarray : a > > > R: myarray : b > > > R: myarray : c > > > R: myarray : d > > > Any idea ? > > _______________________________________________ > Help-cfengine mailing list > Help-cfengine@cfengine.org > https://cfengine.org/mailman/listinfo/help-cfengine _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine