m4lk4v@gmail.com
2013-Jul-12 18:21 UTC
[Puppet Users] is there a way to declare all classes in a namespace?
Say I have the following classes: foo foo::bar::one foo::bar::two Is there a way to declare all classes in the foo::bar namespace at once? I would like a way to easily add resources to a namespace in a module by just adding a proper file in modules/foo/bar/three.pp and then letting some statement in class foo just declare the new foo::bar::three class without my having to edit class foo and statically declare. Thanks for any info. -- 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. For more options, visit https://groups.google.com/groups/opt_out.
llowder
2013-Jul-12 20:20 UTC
[Puppet Users] Re: is there a way to declare all classes in a namespace?
On Friday, July 12, 2013 11:21:09 AM UTC-7, m4l...@gmail.com wrote:> > Say I have the following classes: > > foo > foo::bar::one > foo::bar::two > > Is there a way to declare all classes in the foo::bar namespace at once? >Not really, but you can have foo::bar look like: class foo::bar { include foo::bar::one include foo::bar::two ... include foo::bar::eleventy } And then you only need to change a single place, and everywhere that needs it can just do "include foo::bar". There are no automagic ways to do that, and having an automagic way to do it seems really dangerous and like a really bad idea to me.> I would like a way to easily add resources to a namespace in a module by > just adding a proper file in modules/foo/bar/three.pp and then letting some > statement in class foo just declare the new foo::bar::three class without > my having to edit class foo and statically declare. > > Thanks for any info. >-- 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. For more options, visit https://groups.google.com/groups/opt_out.
jcbollinger
2013-Jul-12 21:35 UTC
[Puppet Users] Re: is there a way to declare all classes in a namespace?
On Friday, July 12, 2013 3:20:05 PM UTC-5, llowder wrote:> > > > On Friday, July 12, 2013 11:21:09 AM UTC-7, m4l...@gmail.com wrote: >> >> Say I have the following classes: >> >> foo >> foo::bar::one >> foo::bar::two >> >> Is there a way to declare all classes in the foo::bar namespace at once? >> > > > Not really, but you can have foo::bar look like: > > class foo::bar { > include foo::bar::one > include foo::bar::two > ... > include foo::bar::eleventy > } > > And then you only need to change a single place, and everywhere that needs > it can just do "include foo::bar". > > There are no automagic ways to do that, and having an automagic way to do > it seems really dangerous and like a really bad idea to me. > >I agree. Moreover, if you''re creating so many classes that the requested behavior would be a significant win, then the classes at issue are probably very repetitive, a set of variations on a common theme. Such a collection of classes probably wants to be a bunch of instances of a single defined type instead. However, if the OP really has to have this, then it should be pretty easy to write a code-generator that will automatically update his top-level class to declare all the other classes in the module. That''s not quite what was requested, but it''s about as close as you can get. 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. For more options, visit https://groups.google.com/groups/opt_out.