On Friday, September 7, 2012 8:02:50 AM UTC-5, Jakov Sosic wrote:
>
> Hi. 
>
> What is the best way to mix classes? 
>
> For example, I have a class apache, which sets up web server, and have 
> class cobbler which needs to add few files to /etc/httpd/conf.d. 
>
> What's the best way to do this? Include apache class in cobbler class? 
>


That is what I would do, provided that class 'apache' is not parametrized.  
I.e.:

class cobbler {
  include 'apache'
  # ...
}

Unfortunately, that approach doesn't work well if class 'apache' is 
parametrized.  If class 'apache' is parametrized, or if for some reason you 
don't want to make the module containing your cobbler class explicitly 
dependent on the module containing class 'apache', then you can declare the 
dependency externally via Puppet's chaining operators:

class { 'apache':
  # some parameters
}

include 'cobbler'

Class['apache'] -> Class['cobbler']

You can also set up finer-grained relationships between classes and 
individual resources, or between pairs of resources, using the 'before' and 
'requires' metaparameters, including across class and even module 
boundaries, but that kind of deep coupling can present a maintenance 
problem.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/1u24nTMTAJAJ.
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.

Reply via email to