Nick,

You are indeed hitting a bug, this one: 
https://cfengine.com/bugtracker/view.php?id=904

The workaround is to condition the getindices() so that it happens only on the 
second pass, with something like this:

    secondpass::
      "array_keys" slist => getindices("local_array");

  classes:
      "secondpass" expression => "any";

Then it works fine.

--Diego


On Sep 9, 2012, at 10:09 AM, Nick Anderson <n...@cmdln.org> wrote:

> Is it expected behavior that you cannot create new index values with a list?
> 
> If I do a simple array creation with a list it seems to work
> https://gist.github.com/3684884 (set_array_values_with_list.cf)
> 
> cf-agent -KIf ./set_array_values_with_list.cf
> R: Array: local_array[id1]=value
> R: Array: local_array[id2]=value
> R: Array: local_array[id3]=value
> 
> 
> But if I am overriding array variables, It does not appear that I can create 
> new ones. See how local_array[blue] is not set or reported, but 
> local_array[red] value is successfully overridden to dog.
> 
> https://gist.github.com/3684847 (override_array_defaults.cf)
> 
> cf-agent -KIf ./override_array_defaults.cf
> R: Why does local_array[blue] not get set from the param?
> R:
> R: Param: main.array[red]=dog
> R: Param: main.array[blue]=fish
> R:
> R: Array: local_array[one]=fish
> R: Array: local_array[two]=fish
> R: Array: local_array[red]=dog
> 
> To me it looks like a bug.
> <override_array_defaults.cf><set_array_values_with_list.cf>_______________________________________________
> 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

Reply via email to