Erwin Bogaard
2012-Nov-09 13:19 UTC
[Puppet Users] Passing an array of user groups to a define
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? -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/ahHYu4WJclkJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Eric Sorenson
2012-Nov-09 20:26 UTC
[Puppet Users] Re: Passing an array of user groups to a define
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.. On Friday, November 9, 2012 5:19:31 AM UTC-8, Erwin Bogaard wrote:> > 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? >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/HQGmI46087UJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Erwin Bogaard
2012-Nov-09 21:08 UTC
[Puppet Users] Re: Passing an array of user groups to a define
Hi Eric. removing the quotes fixed it! If only all problems were that easy to fix ;-) Thanks, Erwin On Friday, November 9, 2012 9:26:11 PM UTC+1, Eric Sorenson wrote:> > 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.. > > On Friday, November 9, 2012 5:19:31 AM UTC-8, Erwin Bogaard wrote: >> >> 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? >> >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/K4nVjDO1l94J. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.