Hey, guys! These days I''m keep on setting up my puppet automation environment, but I got a problem that made me confused. I have a define to add users ,which as follows : define usermgr::add_user ($usershell=''/bin/bash'', $groups) { 4 5 file 6 { "/home/$title": 7 owner => "$title", 8 group => "$title", 9 mode => 755, 10 ensure => directory; 11 } 12 13 user { 14 "$title": 15 shell => "$usershell", 16 groups => ["$groups"], 17 ensure => present, 18 home => "/home/$title", 19 } 20 21 22 file 23 { "/home/$title/.ssh": 24 owner => "$title", 25 group => "$title", 26 mode => 700, 27 ensure => directory, 28 require => File["/home/$title"]; 29 } then i want to pass some parameters to this define to add user tester who belongs to group root and adm: class usermgr::project1 { 6 usermgr::add_user { 7 "tester": 8 usershell => "/bin/bash", 9 groups => [''root'',''adm''] 10 } 11 } but it always failed as follows: err: //usermgr::project1/Usermgr::Add_user[tester]/User[flex1]/groups: change from tester to tester,rootadm failed: Could not set groups on user[tester]: Execution of ''/usr/sbin/usermod -G tester,rootadm tester'' returned 6: usermod: group ''rootadm'' does not exist the information seems like that the groups parameter is parsed wrong , does anyone have idea to parse this array parameter right ? Thanks so much:> -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. 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.
Not sure how to do it, but what I would try: (see inline) On 18.06.2010 13:46, daniel wrote:> Hey, guys! These days I''m keep on setting up my puppet automation > environment, but I got a problem that made me confused. > I have a define to add users ,which as follows : > > define usermgr::add_user ($usershell=''/bin/bash'', $groups) { > 4 > 5 file > 6 { "/home/$title": > 7 owner => "$title", > 8 group => "$title", > 9 mode => 755, > 10 ensure => directory; > 11 } > 12 > 13 user { > 14 "$title": > 15 shell => "$usershell", > 16 groups => ["$groups"], >Try changing this to groups => $groups> 17 ensure => present, > 18 home => "/home/$title", > 19 } > > 20 > 21 > 22 file > 23 { "/home/$title/.ssh": > 24 owner => "$title", > 25 group => "$title", > 26 mode => 700, > 27 ensure => directory, > 28 require => File["/home/$title"]; > 29 } > > then i want to pass some parameters to this define to add user tester > who belongs to group root and adm: > class usermgr::project1 { > 6 usermgr::add_user { > 7 "tester": > 8 usershell => "/bin/bash", > 9 groups => [''root'',''adm''] > 10 } > 11 } > > but it always failed as follows: > err: //usermgr::project1/Usermgr::Add_user[tester]/User[flex1]/groups: > change from tester to tester,rootadm failed: Could not set groups on > user[tester]: Execution of ''/usr/sbin/usermod -G tester,rootadm > tester'' returned 6: usermod: group ''rootadm'' does not exist > > the information seems like that the groups parameter is parsed > wrong , does anyone have idea to parse this array parameter right ? > > Thanks so much:> > >Silviu -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. 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.
On 06/20/2010 12:10 PM, Silviu Paragina wrote:> Not sure how to do it, but what I would try: (see inline) > > On 18.06.2010 13:46, daniel wrote: >> Hey, guys! These days I''m keep on setting up my puppet automation >> environment, but I got a problem that made me confused. >> I have a define to add users ,which as follows : >> >> define usermgr::add_user ($usershell=''/bin/bash'', $groups) { >> 4 >> 5 file >> 6 { "/home/$title": >> 7 owner => "$title", >> 8 group => "$title", >> 9 mode => 755, >> 10 ensure => directory; >> 11 } >> 12 >> 13 user { >> 14 "$title": >> 15 shell => "$usershell", >> 16 groups => ["$groups"], > Try changing this to groups => $groups >> 17 ensure => present, >> 18 home => "/home/$title", >> 19 } >> 20 >> 21 >> 22 file >> 23 { "/home/$title/.ssh": >> 24 owner => "$title", >> 25 group => "$title", >> 26 mode => 700, >> 27 ensure => directory, >> 28 require => File["/home/$title"]; >> 29 } >> >> then i want to pass some parameters to this define to add user tester >> who belongs to group root and adm: >> class usermgr::project1 { >> 6 usermgr::add_user { >> 7 "tester": >> 8 usershell => "/bin/bash", >> 9 groups => [''root'',''adm''] >> 10 } >> 11 } >> >> but it always failed as follows: >> err: //usermgr::project1/Usermgr::Add_user[tester]/User[flex1]/groups: >> change from tester to tester,rootadm failed: Could not set groups on >> user[tester]: Execution of ''/usr/sbin/usermod -G tester,rootadm >> tester'' returned 6: usermod: group ''rootadm'' does not exist >> >> the information seems like that the groups parameter is parsed >> wrong , does anyone have idea to parse this array parameter right ? >> >> Thanks so much:> >> > > > Silviu >You can''t set group on a resource if the group doesn''t exist, so in each resource that needs that group you would need to require => Group["whatever"]. -- -- Joe McDonagh Operations Engineer AIM: YoosingYoonickz IRC: joe-mac on freenode "When the going gets weird, the weird turn pro." -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. 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.
Joe is right, you need to generate the group(s), before you generate the user(s), before you setup their homedirectory. For example: group { "ldap": gid => 294, before => User["ldap"], } user { "ldap": uid => 294, gid => 294, comment => "Ldap Processor", home => "/home/ldap", shell => "/bin/sh", } file { "/home/ldap": owner => ldap, group => ldap, mode => 700, ensure => directory, require => User["ldap"], } It doesn''t help with your original issue of passing the array (though i believe Silviu has that covered), but hopefully it helps a little :) PS yes i realise what a pain having non standard LDAP uid and gid can be. Cheers chakkerz -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. 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.
Not to hijack your thread, but I''m having a similar issue with trying to pass an array to a define: class solr { $configFileList = ["admin-extra.html", "elevate.xml"] define configFiles ( $solrIndex, $fileName ) { file { "/var/solr/$solrIndex/conf/$fileName" : ensure => present, owner => "tomcat", source => "puppet://puppetmaster.dennisinteractive.co.uk/files/solr/conf/$fileName" } } } Then If I call it like so: solr::configFiles { $title : fileName => $configFileList, solrIndex => $title, require => File["/var/solr/$title/conf/xslt"], } It doesnt seem to pass the $configFileList through correctly. Any idea''s on what I should be doing? -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. 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.
On 6/21/2010 3:51 PM, Matt Keating wrote:> Not to hijack your thread, but I''m having a similar issue with trying > to pass an array to a define: > class solr { > > $configFileList = ["admin-extra.html", "elevate.xml"] > > define configFiles ( $solrIndex, $fileName ) { > file { "/var/solr/$solrIndex/conf/$fileName" :if you call this like below, $fileName is an array, which puppet will dutifully interpolate into your string, which is not what you want.> ensure => present, > owner => "tomcat", > source => > "puppet://puppetmaster.dennisinteractive.co.uk/files/solr/conf/$fileName" > } > } > } > Then If I call it like so: > > solr::configFiles { $title : > fileName => $configFileList, > solrIndex => $title, > require => File["/var/solr/$title/conf/xslt"], > } > > It doesnt seem to pass the $configFileList through correctly. Any > idea''s on what I should be doing?The following would be one possibility: define solr::config_file ($index) { file { "/var/solr/${index}/conf/${name}": # ... } } solr::config_file { $configFileList: index => $title; } Best Regards, David -- dasz.at OG Tel: +43 (0)664 2602670 Web: http://dasz.at Klosterneuburg UID: ATU64260999 FB-Nr.: FN 309285 g FB-Gericht: LG Korneuburg -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. 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.
On 06/21/2010 09:51 AM, Matt Keating wrote:> Not to hijack your thread, but I''m having a similar issue with trying > to pass an array to a define: > class solr { > > $configFileList = ["admin-extra.html", "elevate.xml"] > > define configFiles ( $solrIndex, $fileName ) { > file { "/var/solr/$solrIndex/conf/$fileName" : > ensure => present, > owner => "tomcat", > source => > "puppet://puppetmaster.dennisinteractive.co.uk/files/solr/conf/$fileName" > } > } > } > Then If I call it like so: > > solr::configFiles { $title : > fileName => $configFileList, > solrIndex => $title, > require => File["/var/solr/$title/conf/xslt"], > } > > It doesnt seem to pass the $configFileList through correctly. Any > idea''s on what I should be doing? > >Try wrapping fileName => [ $configFileList ] like that. Might work that way. -- -- Joe McDonagh Operations Engineer AIM: YoosingYoonickz IRC: joe-mac on freenode "When the going gets weird, the weird turn pro." -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. 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.