Hi help-cfengine,

Happy winter/summer solstice (depending on which hemisphere you live in)!

I am trying to create an associative array using strings containing
spaces as indices.  Problem is, it doesn't seem to work with getindices,
although cf-promises doesn't complain about it.

Here's some example code:

----

 body common control {
         bundlesequence => { "main" };
 }

 bundle agent main {
         vars:
                "myarray[entry one]"    string => "One";
                "myarray[entry two]"    string => "Two";
                "myarray[entry three]"  string => "Three";

                "myarray_indices"       slist => getindices(myarray);

        reports:

                cfengine_3_1_2::
                        "a myarray index:  $(myarray_indices)";

 }

----

This returns:  "R: a myarray index:  entr"  as opposed to what you might
expect.

Because it is possible to address arrays with these keys (e.g.
$(myarray[entry three]) works) I assume this is a problem with
getindices, but maybe array keys were not supposed to have spaces...  If
that's so, it would be nice if cf-promises raised an error if they were
used.

Since a frequent question is "what are you trying to do with this?", I'm
trying to create an edit_line bundle in the style of
"set_variable_values" from cfengine_stdlib.cf, using keys with
whitespace in them, for editing files like /etc/security/limits.conf. 
For example:

    vars:
        "limits_conf[oracle soft nproc]"  string => "2047";
        "limits_conf[oracle hard nproc]"  string => "16384";
        "limits_conf[oracle soft nofile]" string => "4096";

    files:

        "/etc/security/limits.conf"
            edit_line => set_variable_values_whitespace("main.limits_conf");

... hopefully you get the idea.  Thanks for any help.

Best,
Jim Lawson
University of Vermont



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

Reply via email to