Alexander Winkler
2013-Feb-19 13:24 UTC
[Puppet Users] Class Order: Cant add user without group
Hello, I am trying to establish an Puppet infrastructure starting with user and group management. For that reason, i created 2 modules: userloader and group. Userloader contains a ''function'' as template to add users, the module group all groups to add. If the groups are on every system, adding my people within the site.pp works well. But I don''t want to have every group on every system, they should be created dynamically. So i tried to add an user with the group "fubar". It failed, because "fubar" is not a group on the system. my group module does contain "fubar", just without "ensure => present". My config setup: Thats my "userloader" (often described as user_add): define userloader ($uid, $gid, $groups, $comment, $password, $sshkeytype,> $sshkey) { > $user_home = $operatingsystem ? { > Solaris => ''/export/home'', > SLES => ''/home'', > } > $sshkeytypeChecked = $sshkeytype ? { > '''' => ''ssh-rsa'', > default => $sshkeytype, > } > $sshkeyChecked = $sshkey ? { > '''' => ''notDefined'', > default => $sshkey, > } > user { $title: > uid => $uid, > gid => $gid, > groups => $groups, > comment => $comment, > password => $password, > home => "${user_home}/${title}", > managehome => true, > shell => ''/bin/bash'', > ensure => present, > } > ssh_authorized_key { $title: > user => $title, > type => $sshkeytypeChecked, > key => $sshkeyChecked, > name => $comment, > ensure => present, > } > }Thats my group module with all groups: class group {> ### primary groups > group { groupA: > gid => 1000, > ensure => present, > } > ### secondary groups > group { secgroupX: > gid => 1200, > ensure => present, > } > group { secgroupY: > gid => 1205, > } > }And finally my testuser: userloader { ''testuser'':> uid => 1234, > gid => 1000, > groups => [secgroupX,secgroupY], > comment => ''any name'', > password => ''XXXXX'', > sshkeytype => ''xxx'', > sshkey => ''xxx'', > }Could anybody tell me how to add the secgroupY dynamically? (only if it''s needed) Thank you, Alex -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Felix Frank
2013-Feb-20 12:06 UTC
Re: [Puppet Users] Class Order: Cant add user without group
Hi, On 02/19/2013 02:24 PM, Alexander Winkler wrote:> Could anybody tell me how to add the secgroupY dynamically? (only if > it''s needed)that''s what virtual resources are for. # on all nodes: @group { groupA: gid => 1000, ensure => present, } ### secondary groups @group { secgroupX: gid => 1200, ensure => present, } @group { secgroupY: gid => 1205, ensure present, } # create these on all nodes realize(Group["groupA", "secgroupX") Then a wrapper for dynamic realization: define realize_groups() { realize(Group["$name"]) } And finally in the userloader define: define userloader ($uid, $gid, $groups, $comment, $password, $sshkeytype, $sshkey) { ... if $groups { realize_groups { $groups: } } ... } -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.