On 01/13/2012 07:05 AM, 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?
>
getindices only really understands single dimensional arrays. Have you tried
add_group_members_locally("main.groups[specialadmins]");
?
--
CTO and Founder
CFEngine
http://www.cfengine.com
http://www.markburgess.org
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine