Hello all,

I have a question about class and subclass relationships and what is/isn't 
the ideal way to go about such a thing.  Please bear with me  as I'm still 
refining my understanding of containment. Let's say I have a puppet module 
which manages the install of puppet and has the following pieces (currently 
using puppet v.3.4.3):

*init.pp*
class puppet {
  # evaluate supporting classes
  include puppet::params
  include puppet::config
  include puppet::service
  
  anchor { 'puppet::begin' : } ->
  class { '::puppet::params' : } ->
  class { '::puppet::config' : } ~>
  class { '::puppet::service' : } ->
  anchor { 'puppet::end' : }
}

*params.pp*
class puppet::params {
# puppet general params
  $puppet_path            = '/etc/puppet'
  $puppet_config_template = 'puppet/puppet.conf.erb'
  $puppet_package         = 'puppet'
  $puppet_common_package  = 'puppet-common'
  $puppet_service_ensure  = 'running'
  $puppet_service_enable  = true
  $puppet_prod_version    = '3.6.2-1puppetlabs1'
  $puppet_dev_version     = '3.6.2-1puppetlabs1'
  validate_string($puppet_path)
  validate_string($puppet_config_template)
  validate_string($puppet_package)
  validate_string($puppet_common_package)
  validate_string($puppet_service_ensure)
  validate_bool($puppet_service_enable)
  validate_string($puppet_prod_version)
  validate_string($puppet_dev_version)
}

*config.pp*
class puppet::config (

  $puppet_config_path     = $::puppet::params::puppet_config_path,
  $puppet_config_template = $::puppet::params::puppet_config_template,
  $puppet_service         = $::puppet::params::puppet_service,
  
) inherits puppet::params {

  file { 'puppet.conf' :
    ensure  => present,
    path    => "${puppet_config_path}/",
    content => template("${puppet_config_template}"),
    notify  => Service["${puppet_service}"],
  }
}

*service.pp*
class puppet::service (

  $puppet_package         = $::puppet::params::puppet_package,
***truncated variables for sake of a long post***

) inherits puppet::config { 

  package { "${puppet_package}":
    ensure  => "${puppet_prod_version}",
  }

  package { "${puppet_common_package}":
    ensure  => "${puppet_prod_version}",
  }

  service { "${puppet_service}":
    ensure     => "${puppet_service_ensure}",
    name       => "${puppet_service}",
    enable     => "${puppet_service_enable}",
    hasrestart => true,
    hasstatus  => true,
    subscribe  => Package["${puppet_config_template}"],
  }
}

Based on the above, I've left a few things which I feel don't belong but 
for the sake of my questions, they're included.

Per the above init.pp, I've added an anchor to force ordering.  My 
understanding is that this has nothing to do with application-order and 
more to do with parse-order.  With that said, I have a few questions:

1.  By adding the 'include' in init.pp, my understanding is that simply 
says to 'evaluate' the subclasses but does not indicate an order to which 
subclasses are to be applied.  Is that correct?

2.  I think the 'inherits' function is depreciated but should each instance 
be replaced with a 'contain' (based on the order I want) throughout my 
subclass manifests?  My understanding is that I should never 'contain' more 
than one subclass within the same module as puppet will be confused on 
ordering.

3.  I rather like the idea of the anchor in the init.pp because I only have 
one place to go to, in order to see the relationship of the subclasses. 
With the introduction of the 'contain' feature, I feel like the anchor is 
no longer needed; however, is there a preferred way of ordering these 
subclasses without using the anchor pattern?

As always, thanks in advance for your help.

Cheers,

Mike

  


-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/daeb1827-7d94-4921-ae09-31f2ea480e9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to