Puppet Class: puppetserver::puppetdb

Defined in:
modules/puppetserver/manifests/puppetdb.pp

Summary

configure a puppetserver to work with puppetdb automaticaly includes profile::puppetserver

Overview

SPDX-License-Identifier: Apache-2.0



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'modules/puppetserver/manifests/puppetdb.pp', line 3

class puppetserver::puppetdb {
    # We call this from profile::puppetserver
    assert_private()
    $urls = $puppetserver::puppetdb_urls
    $submit_only_urls = $puppetserver::puppetdb_submit_only_urls
    $enable = !$urls.empty
    # Always enable command_broadcast if we have more then 1 host
    $command_broadcast = ($urls + $submit_only_urls).length > 1

    ensure_packages('puppet-terminus-puppetdb', { 'ensure' => stdlib::ensure($enable, 'package') })

    $submit_only_config = $submit_only_urls.empty.bool2str(
        '', "submit_only_server_urls = ${submit_only_urls.join(' ')}"
    )

    $puppetdb_config = @("CONFIG")
    [main]
    server_urls = ${urls.join(',')}
    ${submit_only_config}
    command_broadcast = ${command_broadcast}
    | CONFIG

    $routes = {
        'master' => {
            'facts' => {
                'terminus' => 'puppetdb',
                'cache'    => 'yaml',
            },
        },
    }
    file {
        default:
            ensure => stdlib::ensure($enable, file),
            notify => Service['puppetserver'];
        "${puppetserver::config_dir}/puppetdb.conf":
            content => $puppetdb_config;
        "${puppetserver::config_dir}/routes.yaml":
            content => $routes.to_yaml;
    }
}