Forum: Cfengine Help
Subject: Re: Array as bundle parameter
Author: zzamboni
Link to topic: https://cfengine.com/forum/read.php?3,19779,19784#msg-19784

Hi Daniel,

> I try to pass an array as bundle parameter without
> success

>             edit_line => insert_array_lines("$(line)"),
> ...
> bundle edit_line insert_array_lines(v)
> ...
>       "idx" slist => getindices("$(v)");

> [1]  like in 
> http://blog.zzamboni.org/editing-sshd-configuration-files-with-cfengin?c=1

You didn't do it exactly like in the example, though :) You need to pass the 
name of the array as a string, so it can be dereferenced inside the 
insert_array_lines bundle. In particular, getindices() also receives the name 
of the array, not the array itself. So the call should be like this:

    edit_line => insert_array_lines("line");

compare with the following line from the example in my blog:

  "sshd"    usebundle => edit_sshd("$(sshdconfig)", "configfiles.sshd");

In this case "configfiles.sshd" is the fully-qualified name of the array to use 
for the parameters.

Best regards,

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to