Puppet Class: puppetboard

Defined in:
modules/puppetboard/manifests/init.pp

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • ensure (Wmflib::Ensure) (defaults to: 'present')
  • puppetdb_host (Stdlib::Host) (defaults to: 'localhost')
  • puppetdb_port (Stdlib::Port) (defaults to: 8080)
  • puppetdb_ssl_verify (Puppetboard::SSL_verify) (defaults to: true)
  • puppetdb_cert (Optional[Stdlib::Unixpath]) (defaults to: undef)
  • puppetdb_key (Optional[Stdlib::Unixpath]) (defaults to: undef)
  • puppetdb_proto (Optional[Enum['http', 'https']]) (defaults to: undef)
  • puppetdb_timeout (Integer[1,120]) (defaults to: 20)
  • page_title (String) (defaults to: 'Puppetboard')
  • default_environment (String) (defaults to: 'production')
  • enable_catalog (Boolean) (defaults to: false)
  • enable_query (Boolean) (defaults to: true)
  • unresponsive_hours (Integer[1,24]) (defaults to: 2)
  • localise_timestamp (Boolean) (defaults to: true)
  • log_level (Puppetboard::LogLevel) (defaults to: 'info')
  • refresh_rate (Integer[1,360]) (defaults to: 30)
  • daily_reports_chart_enabled (Boolean) (defaults to: true)
  • daily_reports_chart_days (Integer[1,31]) (defaults to: 8)
  • with_event_numbers (Boolean) (defaults to: true)
  • normal_table_count (Integer[10,500]) (defaults to: 100)
  • little_table_count (Integer[1,50]) (defaults to: 10)
  • table_count_selector (Array[Integer]) (defaults to: [10, 20, 50, 100, 500])
  • graph_type (String) (defaults to: 'pie')
  • graph_facts_override (Array[String]) (defaults to: [])
  • displayed_metrics_override (Array[String]) (defaults to: [])
  • inventory_facts_override (Hash[String, String]) (defaults to: {})
  • query_endpoints_override (Array[Puppetboard::Query_endpoints]) (defaults to: [])
  • overview_filter (Optional[String]) (defaults to: undef)
  • secret_key (Optional[Sensitive[String[24]]]) (defaults to: undef)


2
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'modules/puppetboard/manifests/init.pp', line 2

class puppetboard (
    # puppetdb settings
    Wmflib::Ensure                      $ensure                      = 'present',
    Stdlib::Host                        $puppetdb_host               = 'localhost',
    Stdlib::Port                        $puppetdb_port               = 8080,
    Puppetboard::SSL_verify             $puppetdb_ssl_verify         = true,
    Optional[Stdlib::Unixpath]          $puppetdb_cert               = undef,
    Optional[Stdlib::Unixpath]          $puppetdb_key                = undef,
    Optional[Enum['http', 'https']]     $puppetdb_proto              = undef,
    Integer[1,120]                      $puppetdb_timeout            = 20,
    # Application settings
    String                              $page_title                  = 'Puppetboard',
    String                              $default_environment         = 'production',
    Boolean                             $enable_catalog              = false,
    Boolean                             $enable_query                = true,
    Integer[1,24]                       $unresponsive_hours          = 2,
    Boolean                             $localise_timestamp          = true,
    Puppetboard::LogLevel               $log_level                   = 'info',
    Integer[1,360]                      $refresh_rate                = 30,
    Boolean                             $daily_reports_chart_enabled = true,
    Integer[1,31]                       $daily_reports_chart_days    = 8,
    Boolean                             $with_event_numbers          = true,
    Integer[10,500]                     $normal_table_count          = 100,
    Integer[1,50]                       $little_table_count          = 10,
    Array[Integer]                      $table_count_selector        = [10, 20, 50, 100, 500],
    String                              $graph_type                  = 'pie',
    Array[String]                       $graph_facts_override        = [],
    Array[String]                       $displayed_metrics_override  = [],
    Hash[String, String]                $inventory_facts_override    = {},
    Array[Puppetboard::Query_endpoints] $query_endpoints_override    = [],
    Optional[String]                    $overview_filter             = undef,
    Optional[Sensitive[String[24]]]     $secret_key                  = undef,

) {
    ensure_packages('puppetboard')
    $displayed_metrics_defaults = ['resources.total', 'events.failure', 'events.success',
                                  'resources.skipped', 'events.noop']
    $graph_facts_defaults = ['architecture', 'clientversion', 'domain', 'lsbcodename',
                            'lsbdistcodename', 'lsbdistid', 'lsbdistrelease', 'lsbmajdistrelease',
                            'netmask', 'osfamily', 'puppetversion', 'processorcount']
    $query_endpoints_default = ['pql', 'nodes', 'resources', 'facts', 'factsets', 'fact-paths',
                                'reports', 'events', 'edges', 'environments']
    $inventory_facts_defaults = {
        'Hostname'       => 'fqdn',
        'IP Address'     => 'ipaddress',
        'OS'             => 'lsbdistdescription',
        'Architecture'   => 'hardwaremodel',
        'Kernel Version' => 'kernelrelease',
        'Puppet Version' => 'puppetversion',
    }
    $displayed_metrics = $displayed_metrics_override.empty ? {
        false   => $displayed_metrics_override,
        default => $displayed_metrics_defaults,
    }
    $graph_facts = $graph_facts_override.empty ? {
        false   => $graph_facts_override,
        default => $graph_facts_defaults,
    }
    $enabled_query_endpoints = $query_endpoints_override.empty ? {
        false   => $query_endpoints_override,
        default => $query_endpoints_default,
    }
    $inventory_facts = Tuple($inventory_facts_override.empty ? {
        false   => $inventory_facts_override,
        default => $inventory_facts_defaults,
    })
    $_secret_key = $secret_key ? {
        undef   => 'os.urandom(24)',
        default => "'${secret_key.unwrap}'",
    }

    $config = {
        'PUPPETDB_HOST'               => $puppetdb_host,
        'PUPPETDB_PORT'               => $puppetdb_port,
        'PUPPETDB_PROTO'              => $puppetdb_proto,
        'PUPPETDB_SSL_VERIFY'         => $puppetdb_ssl_verify,
        'PUPPETDB_KEY'                => $puppetdb_key,
        'PUPPETDB_CERT'               => $puppetdb_cert,
        'PUPPETDB_TIMEOUT'            => $puppetdb_timeout,
        'DEFAULT_ENVIRONMENT'         => $default_environment,
        'UNRESPONSIVE_HOURS'          => $unresponsive_hours,
        'ENABLE_QUERY'                => $enable_query,
        'ENABLED_QUERY_ENDPOINTS'     => $enabled_query_endpoints,
        'LOCALISE_TIMESTAMP'          => $localise_timestamp,
        'LOGLEVEL'                    => $log_level,
        'NORMAL_TABLE_COUNT'          => $normal_table_count,
        'LITTLE_TABLE_COUNT'          => $little_table_count,
        'TABLE_COUNT_SELECTOR'        => $table_count_selector,
        'DISPLAYED_METRICS'           => $displayed_metrics,
        'ENABLE_CATALOG'              => $enable_catalog,
        'OVERVIEW_FILTER'             => $overview_filter,
        'PAGE_TITLE'                  => $page_title,
        'GRAPH_TYPE'                  => $graph_type,
        'GRAPH_FACTS'                 => $graph_facts,
        'INVENTORY_FACTS'             => $inventory_facts,
        'REFRESH_RATE'                => $refresh_rate,
        'DAILY_REPORTS_CHART_ENABLED' => $daily_reports_chart_enabled,
        'DAILY_REPORTS_CHART_DAYS'    => $daily_reports_chart_days,
        'WITH_EVENT_NUMBERS'          => $with_event_numbers,
    }.reduce('') |$memo, $value| {
        "${memo}${value[0]} = ${value[1].wmflib::to_python}\n"
    }
    $config_content = @("CONFIG")
    import os
    SECRET_KEY = ${_secret_key}
    ${config}
    | CONFIG
    $config_file = '/etc/puppetboard/settings.py'
    file {$config_file:
        ensure  => stdlib::ensure($ensure, 'file'),
        content => $config_content,
    }

}