Hi, Here's what the docs say: "Okay, we can pass parameters into classes now and change their behavior. Great! But classes are still always singletons; you can’t declare more than one copy and get two different sets of behavior simultaneously. And you’ll eventually want to do that! What if you had a collection of resources that created a vhost definition for a web server, or cloned a Git repository, or managed a user account complete with group, SSH key, home directory contents, sudoers entry, and .bashrc/.vimrc/etc. files? What if you wanted more than one Git repo, user account, or vhost on a single machine?
Well, you’d whip up a defined resource type." So have a look at changing the bar class to a define instead. Cheers, Den On 06/03/2012, at 7:23, "chris_sny...@sra.com" <chris_sny...@sra.com> wrote: > I apologize if this horse has already been beaten to death, but I'm > new here and very, very confused. I'm just starting to work with > Puppet and I can not make heads or tails of the language: specifically > how to use parameterized classes. I've spent a week reading the docs > and testing manifests and I can't make any progress. I have a feeling > that my confusion comes from the fact I have a programming background > and that my understanding of certain terms (i.e. 'class' and 'scope') > don't mean the same thing for Puppet as they do everywhere else. > (And I thought I understood the concept of 'declarative language', but > maybe not.) > > Here's an example of what I feel should work: > > class bar ($x='default') { > notify { "x=${x}": } > } > > class foo { > notify { 'Inside class foo': } > class { 'bar' : x => 'inside foo', } > } > > class baz { > notify { 'Inside class baz': } > class { 'bar' : x => 'inside baz', } > } > > class { 'foo' : } > class { 'baz' : } > > However, when I run this I get the following error: > > Duplicate definition: Class[Bar] is already defined in file > test5.pp at line 10; cannot redefine at test5.pp:15 > > As I understand it, each class definition has it's own scope. So why > can't I declare the same parameterized class from two different > classes, especially when the parameters are different? If you can't > do this then what's the point of having them? > > My understanding of the docs and how the scoping rules are moving > towards 2.8, seems to imply that 'include' is bad and 'parameterized > classes' are good. I'm cool with that, in fact I prefer that - it > matches more of style of coding for other languages. > > Can somebody please explain what is going on? > > thx > Chris. > > -- > 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+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.