MrTeleBird
2013-Mar-22 08:49 UTC
[Puppet Users] how to call a class from different module than current
Hi dear Users, I''ve been looking in internet and on the puppet wiki website but i am still confused about this. Lets say I have 2 Modules: A and B What I want to do is call a class on module A directly from module B. I know it is possible to call different classes within a module by using inheritance and using different .pp config files. But how I do not know how to do the "same" between different modules. Thanks! -- 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.
Russell Parsloe
2013-Mar-22 10:53 UTC
[Puppet Users] Re: how to call a class from different module than current
You can just call the full reference to the class. So if you want to call the class *dofunkystuff *from *modulea *in *moduleb*, put this in one of your module B manifests: include modulea::dofunkystuff Is this what you needed? -- 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.
jcbollinger
2013-Mar-22 14:14 UTC
[Puppet Users] Re: how to call a class from different module than current
On Friday, March 22, 2013 3:49:38 AM UTC-5, MrTeleBird wrote:> > Hi dear Users, > > I''ve been looking in internet and on the puppet wiki website but i am > still confused about this. > > Lets say I have 2 Modules: A and B > > What I want to do is call a class on module A directly from module B. >Puppet classes are not executable and cannot be "called". They can be "declared", or the term "included" means about the same thing. Or "assigned", sometimes.> > I know it is possible to call different classes within a module by using > inheritance and using different .pp config files. But how I do not know how > to do the "same" between different modules. > >That is totally NOT the purpose of class inheritance, except in the form of class inheritance used by a parameterized class A to ensure that another class, B, is evaluated before A''s parameter defaults. Even that''s pretty much a hack, but it seems to have gained general acceptance. Laying out your classes and type definitions each in their own manifest (.pp) file, arranged in the way that the autoloader expects them to be, on the other hand, is certainly a big piece of the puzzle. It''s not necessary in the strictest sense, but what you''re asking is not really practical if you don''t. With that said, the bottom line is what Russell said: any class or type definition, in any module, can be referenced from any manifest by its qualified name. Generally, module_name::[inner_namespace:: ...]class_name is sufficient, but for absolute certainty use the absolute form: ::module_name::[inner_namespace:: ...]class_name (note the leading :: ). If you refer to classes or defined types that have not yet been parsed, however, then Puppet must be able to find their definitions based only on their names, which is where the autoloader comes in. John -- 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.
MrTeleBird
2013-Mar-25 09:23 UTC
[Puppet Users] Re: how to call a class from different module than current
Hi John! yes, exactly that was the answer I was looking for. I think the next time I will not forget just to think easy ;-) cheers, Cesar -- 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.