Passing an array of user groups to a define

417 views
Skip to first unread message

Erwin Bogaard

unread,
Nov 9, 2012, 8:19:31 AM11/9/12
to puppet...@googlegroups.com
As I try to get some flexibility in the creation of users, I switched to a define.
problem is, I can't pass an array of user groups anymore. This either results in
- wrong group creation: group1,group1group2,group2 (see that group1 and group2 are concatenated in the middle, undefined group)
- error: Group names must be provided as an array, not a comma-separated list.


I use the following define:

define users::definitions (
    $home       = "/home/$title",
    $usergroups = $title,
    $ifensure   = 'present',
    ) {
    user {
    "$title":
      home       => "$home",
      managehome => true,
      ensure     => "$ifensure",
      groups     => "$usergroups",
    }
...
}

And the following class to call the define:

class users {
    users::definitions {
    'rsnapshot':
      usergroups => [ 'group1', 'group2' ];
    }
}

Does anyone have an idea how to pass an array of groups to a define?

Eric Sorenson

unread,
Nov 9, 2012, 3:26:11 PM11/9/12
to puppet...@googlegroups.com
Erwin, the variable is probably coming into the define correctly, but you're quoting "$usergroups" in the user resource which will concatenate the values together... remove the quotes and all should be well..

Erwin Bogaard

unread,
Nov 9, 2012, 4:08:05 PM11/9/12
to puppet...@googlegroups.com
Hi Eric.
removing the quotes fixed it! If only all problems were that easy to fix ;-)
Thanks, Erwin
Reply all
Reply to author
Forward
0 new messages