On 02/21/2012 02:01 PM, no-re...@cfengine.com wrote:
> Forum: CFEngine Help
> Subject: Re: getindices with an array of lists
> Author: neilhwatson
> Link to topic: https://cfengine.com/forum/read.php?3,24975,24982#msg-24982
> 
> Good news Mark.  Back to the original question. Are you saying that, 
> currently, in spite of passing the array to the bundle, the list contained 
> within is still considered non-local and thus not available?


>From Wes Hardins post.

bundle edit_line ypconf
{
vars:
"nis_idx" slist =>
getindices("mysite.siteconf[$(mysite.site)][nis_config][server]");

insert_lines:
"domain $(mysite.siteconf[$(mysite.site)][nis_config][domain]) server
$(mysite.siteconf[$(mysite.site)][nis_config][server][$(nis_idx)])"
comment => "Add a line for each server in the default domain.";
}

You can see his nis_idx variable is a list that is set from a globally
referenced list inside an array.

I am able to get the list imported from the passed array, but I have yet
to discover the proper incantation to iterate over it.

Neil see the attached test.

-- 
Nick Anderson <n...@cmdln.org>
body common control {

    bundlesequence => {
        "main",
    };

    inputs => {
        "cfengine_stdlib.cf",
    };
}

bundle agent main {

    vars:

        "shorewall[interfaces]" slist => {
                                    "#ZONE   INTERFACE       BROADCAST        
OPTIONS",
                                    "inet    br0             detect          
bridge",
                                    "priv    virbr0          detect          
bridge",
                                    };

        "shorewall[zones]" slist => {
                                    "fw     firewall",
                                    "inet   ipv4",
                                    "priv   ipv4",
                                    };

    methods:
        "any" usebundle => test ( "main.shorewall" );

}

bundle agent test (shorewall){

    vars:
       "shorewall_index" slist => getindices( "${shorewall}" );
       "my_$(shorewall_index)" slist => 
{"@($(test.shorewall)[$(shorewall_index)])"};

    reports:
        cfengine::
            "$(my_zones)";
            "my_$(shorewall_index) => $(my_$(shorewall_index))";
            "$(shorewall_index) => ";
}
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to