Ask Your Question

How do I properly manage my classes

asked 2013-03-21 16:21:52 -0500

nathanlong85 gravatar image

updated 2013-03-22 09:20:20 -0500

What I mean by this is how do I break apart my classes? Do I stick everything in init.pp or break them up?

As an example, in Pro Puppet they talk about breaking an SSH module up into different files. So I'd have init.pp, install.pp, config.pp and service.pp. So then in my init.pp I'd define an ssh class that includes ssh::install, ssh::config and ssh::service.

Then I look at modules on PuppetForge that were created by Puppetlabs and it looks the opposite. Take the NTP module for example. They do ... (more)

edit retag flag offensive close merge delete


Regarding your question about parameters: I had a similar question that may give you an interesting opportunity:

Stefan gravatar imageStefan ( 2013-03-26 14:25:52 -0500 )edit

1 Answer

Sort by » oldest newest most voted

answered 2013-03-21 17:11:43 -0500

Stefan gravatar image

Don't put everything in init.pp. Try to break the class into different chunks. If you want to know how/when to break up your class it may help to define logical blocks (e.g. configs, users, packages, databases, filesystems) in a way to keep explicit relationships to a minmum.

Example: If you put everything in init.pp and you manage an application with one package and 2 configuration files, you'll end up with

package { 'my_app': ensure => present }
file { '/opt/my_app/config1':
  require => Package['my_app'],
file { '/opt/my_app/config2':
  require => Package['my_app'],
service { 'my_app':
  require => [
    File['/opt/my_app ...
edit flag offensive delete link more


Thanks for the response Stefan! So it sounds like if you have lots of related resources you'll want to start breaking them up? Or if it starts to get ...(more)

nathanlong85 gravatar imagenathanlong85 ( 2013-03-21 22:15:47 -0500 )edit

Yes you can start with a single file. Splitting in three classes can still make sense to give another module an anchor for relationships, e.g. a webapp that comes ...(more)

Stefan gravatar imageStefan ( 2013-03-26 14:23:23 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-03-21 16:21:52 -0500

Seen: 144 times

Last updated: Mar 22 '13