Case Trouble w/ Boolean

57 views
Skip to first unread message

Jeremy Frady

unread,
Apr 9, 2014, 8:07:47 PM4/9/14
to puppet...@googlegroups.com
Hey there,

Thanks for taking the time to read this.  My end objective is to utilize a yaml boolean, in this case couchDbServer, as an entry for a case that dictates whether a file is present or not.  I do not want to use stdlib to achieve this.

Following is the code:

class datadog {

    $datadogApiKey = hiera('datadogApiKey', nil)
    $couchDbServer = hiera('couchDbServer', nil)

    yumrepo { 'datadog':
        baseurl     => 'http://yum.datadoghq.com/rpm/',
        descr       => 'Datadog, Inc.',
        enabled     => 1,
        gpgcheck    => 0,
    } ->
    package { 'datadog-agent':
        ensure      => 'installed',
    } ->
    file { 'datadog.conf':
        path        => '/etc/dd-agent/datadog.conf',
        ensure      => 'present',
        content     => template('datadog/datadog.conf.erb'),
    } ->
    file { 'couchdb.yaml':
        path        => '/etc/dd-agent/conf.d/couchdb.yaml',
        ensure      => 'present',
        content     => template('datadog/couchdb.yaml.erb'),
    } ->
    service { 'datadog-agent':
        ensure      => 'running',
        enable      => 'true',
        subscribe   => File[
                            '/etc/dd-agent/datadog.conf',
                            '/etc/dd-agent/conf.d/couchdb.yaml'
                       ],
    }
}

I've tried a ton of things, but none of it works.  Can someone please advise the proper solution?

Felix Frank

unread,
Apr 10, 2014, 5:50:57 AM4/10/14
to puppet...@googlegroups.com
Hi,

the sledge hammer approach:

file { 'couchdb.yaml':
path => '/etc/dd-agent/conf.d/couchdb.yaml',
ensure => $couchDbServer ? {
true => "present",
default => "absent",
},
content => template('datadog/couchdb.yaml.erb'),
}

But you probably want to look for a more elegant solution, such as
including different classes depending on the flags from hiera.

HTH,
Felix

On 04/10/2014 02:07 AM, Jeremy Frady wrote:
> My end objective is to utilize a yaml boolean, in this
> case couchDbServer, as an entry for a case that dictates whether a file
> is present or not.
Reply all
Reply to author
Forward
0 new messages