On Tuesday, April 9, 2013 4:47:40 AM UTC-5, Gavin Williams wrote:
>
> Hi there,
>
> I think you're quickest win for making the code cleaner and easier would
> be to create a ::params class, which sets the correct values for package,
> file and service based on your distro.
>
>
A ::params class is a reasonable approach, but the *quickest* win would be
to do the equivalent within the existing code, without creating a new
class. For example:
class syslog::install {
$syslog_package = $lsbmajdistrelease ? {
'5' => 'sysklogd',
'6' => 'rsyslog'
}
package { ${syslog_package}:
ensure => present
}
}
Note also that even if the data ($syslog_package in this example) were
pulled out to a separate ::params class, it would be undesirable to use
class inheritance to ensure the data are initialized. It is sufficient and
preferable in this case to simply 'include' the ::params class at the
beginning of the class using it. Class inheritance would be needed only if
the other classes were parameterized AND variables from the ::params class
were used as parameter default values.
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.