Farooque M Haris
2010-Mar-22 14:58 UTC
[Puppet Users] Problem with Variables and Class Inheritance
I am trying to create set of users from different set of lists in the following way; *Secondary Classes* ------------------------- class /*DevelopersManager */#Secondary Class 1 { *$fileList* = "developerUserlist.txt" *$group* = "users" *$home *= "/home" include StaffManager } class /*AdminsManager */#Secondary Class 2 { *$fileList* = "adminUserlist.txt" *$group* = "staff" *$home *= "/home" include StaffManager } *Master Class* --------------------- class StaffManager { $list = generate("/bin/cat", "/etc/puppet/modules/metafiles/*$fileList*") $userList = split($list,'','') # usernames are listed as comma separated items createUsers{ $userList: } # this creates Virtual User resource realizeUsers{ $userList: } # this realizes Virtual User resource # both these functions are working fine } *Node.pp ---------- *node client1.mydomain.com { include AdminsManager # Line 1 include DevelopersManager # Line 2 } Problem: ---------- with above code Puppet server only create _Admin Resources_ but not Developer Resources. It is not showing anything as to why its not creating it. however, if I change the order of */include/* in nodes.pp i.e. if I put ''Line 2'' before ''Line 1'' then it only creates DeveloperUsers. Its a general behaviour of Puppet but I like to know how make this work. I have 9 different categories of users and each category has many users. Is there any better approach you guys suggest? or is there any work around to deal with this Puppet behaviour? waiting for your reponse Thanks -- 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.
Alan Barrett
2010-Mar-24 18:09 UTC
Re: [Puppet Users] Problem with Variables and Class Inheritance
On Mon, 22 Mar 2010, Farooque M Haris wrote:> class /*DevelopersManager */#Secondary Class 1 > { > *$fileList* = "developerUserlist.txt" > *$group* = "users" > *$home *= "/home" > > include StaffManager > } > > class /*AdminsManager */#Secondary Class 2 > { > *$fileList* = "adminUserlist.txt" > *$group* = "staff" > *$home *= "/home" > > include StaffManager > }Apart from the strange stars and slashes (which I guess are an attempt at highlighting), this won''t work because, no matter how many "include" statements you have, each class is really included no more than once. Whichever of the two "include StaffManager" lines happens to take effect first will do what you expect (making those variables available for use by the StaffManager class). Whichever of the two "include StaffManager" lines happens to take effect last will do nothing, because that the StaffManager class will already have been included. To do what I think you want, you need something like this: define StaffManager($filelist, $group, $home) { # do stuff with $filelist, $group, and $home } class DevelopersManager { StaffManager { "developers": filelist => "developerUserlist.txt", group => "users", home => "/home", } } class AdminsManager { StaffManager { "admins": filelist => "adminsUserlist.txt", group => "staff", home => "/home", } } --apb (Alan Barrett) -- 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.
M.F Haris
2010-Mar-25 08:32 UTC
Re: [Puppet Users] Problem with Variables and Class Inheritance
Thanks Alan, Yesterday, I did it exactly the same way and it is running fine. I hope this will be helpful for other puppet newbies too. Am 24.03.2010 19:09, schrieb Alan Barrett:> On Mon, 22 Mar 2010, Farooque M Haris wrote: > >> class /*DevelopersManager */#Secondary Class 1 >> { >> *$fileList* = "developerUserlist.txt" >> *$group* = "users" >> *$home *= "/home" >> >> include StaffManager >> } >> >> class /*AdminsManager */#Secondary Class 2 >> { >> *$fileList* = "adminUserlist.txt" >> *$group* = "staff" >> *$home *= "/home" >> >> include StaffManager >> } >> > Apart from the strange stars and slashes (which I guess are an attempt > at highlighting), this won''t work because, no matter how many "include" > statements you have, each class is really included no more than once. > Whichever of the two "include StaffManager" lines happens to take effect > first will do what you expect (making those variables available for use > by the StaffManager class). Whichever of the two "include StaffManager" > lines happens to take effect last will do nothing, because that the > StaffManager class will already have been included. > > To do what I think you want, you need something like this: > > define StaffManager($filelist, $group, $home) { > # do stuff with $filelist, $group, and $home > } > > class DevelopersManager { > StaffManager { "developers": > filelist => "developerUserlist.txt", > group => "users", > home => "/home", > } > } > > class AdminsManager { > StaffManager { "admins": > filelist => "adminsUserlist.txt", > group => "staff", > home => "/home", > } > } > > --apb (Alan Barrett) > > >-- 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.