On 13/01/2012 07:05, Nick Anderson wrote: > I cant seem to get the syntax right for accessing a list stored in an array. > > I define users and groups using arrays, I would like to be able to use > the same style when defining group members. > > then pass groups to a parameterized bundle to make sure the list of > members for that group get added to /etc/group. > > bundle agent main { > vars: > "groups[specialadmins][gid]" string => "1000"; > "groups[specialadmins][members]" slist => { "bill", "ted" }; > > methods: > "specialadmins" usebundle => add_group_members_locally("main.groups"); > } > > bundle agent add_group_members_locally(groups) { > vars: > "groupfile" string => "/tmp/group"; > "groupindex" slist => getindices("$(groups)"); > > files: > linux:: > "$(groupfile)" > edit_line => > append_user_field("$(groupindex)","4","@(groups[$(groupindex)][members])"; > > } > > I can get it to expand out to groups[specialadmins][members] but not the > slist stored there, I am sure I am mis understanding some concept here, > can someone enlighten me? > Hi Nick,
I never managed to use a list within an array; and on the IRC channel people are often reporting they are trying, but not succeeding I would be really interrested if someone came up with a simple solution. When I need to use something like this, I add another level in the array "groups[specialadmins][gid]" string => "1000"; "groups[specialadmins][members][1]" string => "bill" "groups[specialadmins][members][2]" string => "ted" Regards Nicolas CHARLES _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine