On Sunday, January 6, 2013 7:54:23 AM UTC-6, blalor wrote:
Morning, all. I've got a problem with a custom class and template that
has me stumped. I've created the following class:
class graphite::carbon(
$cache_port = 2003,
$cache_enable_udp = false,
$cache_udp_port = $cache_port,
Morning, all. I've got a problem with a custom class and template that
has me stumped. I've created the following class:
class graphite::carbon(
$cache_port = 2003,
$cache_enable_udp = false,
$cache_udp_port = $cache_port,
Class parameter defaults must not be other parameters of the same class
because the order of binding values to parameters is not defined and not
necessarily consistent. Instead, assign a dummy default value to
$cache_udp_port, and use the $cache_port value instead when you find
$cache_udp_port with that dummy value.
For example,
carbon.pp:
class graphite::carbon(
$cache_port = 2003,
$cache_enable_udp = false,
$cache_udp_port = 'NOTSET',
) {
file {'/etc/carbon/carbon.conf':
content => template('graphite/carbon.conf.erb'),
}
}
carbon.conf.erb:
UDP_RECEIVER_PORT = <%= ((@cache_udp_port == 'NOTSET') && @cache_port)
@cache_udp_port %>
Naturally, if you need the resolved cache_udp_port in more than one place
then do the test once and record the result in a (separate) variable.
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/-/ePZlEJ1b2rsJ.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.