FAQ
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,
) {
package {'carbon': }

file {'/etc/carbon/carbon.conf':
content => template("graphite/carbon.conf.erb"),

require => Package['carbon'],
notify => Service['carbon-cache'],
}

service {'carbon-cache':
enable => true,
ensure => running,

require => Package['carbon'],
}
}

carbon.conf.erb contains this:

UDP_RECEIVER_PORT = <%= cache_udp_port %>

And I use the class like this:

class {'graphite::carbon': }

The problem I'm having is that, without making any changes *AT ALL* UDP_RECEIVER_PORT will sometimes have the default port of "2003" and other times "undef". This is with Puppet 2.7.17 in standalone mode.

Am I doing something wrong with the definition of cache_udp_port? I want it to default to the value provided for cache_port, which defaults to 2003.

Thanks,
Brian

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
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.

Search Discussions

  • Stefan Schulte at Jan 6, 2013 at 5:29 pm

    On Sun, Jan 06, 2013 at 08:54:23AM -0500, Brian Lalor 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,
    ) {
    package {'carbon': }

    file {'/etc/carbon/carbon.conf':
    content => template("graphite/carbon.conf.erb"),

    require => Package['carbon'],
    notify => Service['carbon-cache'],
    }

    service {'carbon-cache':
    enable => true,
    ensure => running,

    require => Package['carbon'],
    }
    }

    carbon.conf.erb contains this:

    UDP_RECEIVER_PORT = <%= cache_udp_port %>

    And I use the class like this:

    class {'graphite::carbon': }

    The problem I'm having is that, without making any changes *AT ALL* UDP_RECEIVER_PORT will sometimes have the default port of "2003" and other times "undef". This is with Puppet 2.7.17 in standalone mode.

    Am I doing something wrong with the definition of cache_udp_port? I want it to default to the value provided for cache_port, which defaults to 2003.

    Thanks,
    Brian
    No you are doing nothing wrong except that variable interpolation is
    random so you get random results if the default value of parameterA
    depends on the value of parameterB.

    This has been accepted as a bug so you may want to watch
    http://projects.puppetlabs.com/issues/9848

    -Stefan

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    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.
  • Brian Lalor at Jan 6, 2013 at 5:32 pm

    On Jan 6, 2013, at 12:32 PM, Stefan Schulte wrote:

    No you are doing nothing wrong except that variable interpolation is
    random so you get random results if the default value of parameterA
    depends on the value of parameterB.

    This has been accepted as a bug so you may want to watch
    http://projects.puppetlabs.com/issues/9848
    Damn. Thanks for confirming it's not just me. :-)

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    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.
  • Jcbollinger at Jan 7, 2013 at 2:45 pm

    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,

    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedJan 6, '13 at 1:54p
activeJan 7, '13 at 2:45p
posts4
users3
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase