On Jul 5, 2010, at 7:11 AM, Thomas Bellman wrote:

> On 2010-07-03, Jeff McCune wrote:
> 
>> In this module, if you use the following orginization puppet will
>> autoload everything:
>> 
>> manifests/init.pp contains class apache { }
>> manifests/disable.pp contains class apache::disable inherits apache {}
>> manifests/virtualhost.pp contains define apache::virtualhost(){}
> 
> Yuck!  Forcing each class or define into its own file sucks royally.
> No sane person wants their code organized like that.
> 
>> If you want additional namespaces, they go in directories.
>> class apache::service::disable would go in manifests/service/disable.pp
>> 
>> I highly recommend against using import today and in the future.
> 
> The cure is in this case worse, *much* worse, than the illness of having
> to do explicit imports.  I'd rather have two dozen import lines in site.pp
> (which is what I have now) than having to split my classes and defines into
> almost 200 files in two dozen directories.

I'll try to post an example soon, but you don't have to split it up into "200 
files" to take advantage of autoloading.  You would need to split it into "two 
dozen directories" though.

On the other hand, you can put everything into site.pp.  I'm sure you'll agree 
that this is a mistake too.  I use modules but I don't split a module's 
manifest (init.pp) into different files until the file starts to get large.

For instance, you could put all your classes into /modules/module-name/init.pp. 
 This works well if all but one or two class are really small.  This is what I 
do by default because if I put "include cups::client" in site.pp, puppet will 
auto import:
        /modules/cups/init.pp
        /modules/cups/client.pp
        /modules/cups/client/init.pp (I think this last one is true, but I 
don't know)

I like the different folders because it keeps the files and templates with the 
manifests, and t makes it easier to tell which files can safely be deleted.  

For me, the key to keeping things easy was to remember that I didn't need to 
break a module into more than one file, but I could if they got too big.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@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.

Reply via email to