Puppet Class: puppetboard

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

Summary

configure puppetboard

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • ensure (Wmflib::Ensure) (defaults to: 'present')

    ensurable parameter

  • puppetdb_host (Stdlib::Host) (defaults to: 'localhost')

    puppetdb host to connect to

  • puppetdb_port (Stdlib::Port) (defaults to: 8080)

    puppetdb port to use

  • puppetdb_ssl_verify (Puppetboard::SSL_verify) (defaults to: true)

    If we shold verify TLS

  • puppetdb_cert (Optional[Stdlib::Unixpath]) (defaults to: undef)

    the puppet cert to use for client auth

  • puppetdb_key (Optional[Stdlib::Unixpath]) (defaults to: undef)

    the puppet key to use for client auth

  • puppetdb_proto (Optional[Enum['http', 'https']]) (defaults to: undef)

    the protocol to use for connecting to puppetdb

  • puppetdb_timeout (Integer[1,120]) (defaults to: 20)

    the timeout to use for puppetdb connections

  • page_title (String) (defaults to: 'Puppetboard')

    The page title

  • default_environment (String) (defaults to: 'production')

    The default puppet environment

  • enable_catalog (Boolean) (defaults to: false)

    enable the catalog browser

  • enable_query (Boolean) (defaults to: true)

    enable the query interface

  • unresponsive_hours (Integer[1,24]) (defaults to: 2)

    how long untill a host is considered unresponsive

  • localise_timestamp (Boolean) (defaults to: true)

    If we should localize timestamps

  • log_level (Puppetboard::LogLevel) (defaults to: 'info')

    the log level to use

  • refresh_rate (Integer[1,360]) (defaults to: 30)

    the refresh rate

  • daily_reports_chart_enabled (Boolean) (defaults to: true)

    enable the daily report chart

  • daily_reports_chart_days (Integer[1,31]) (defaults to: 8)

    how many days for the daily report chart

  • with_event_numbers (Boolean) (defaults to: true)

    If set to True then Overview and Nodes list shows exact number of changed resources in the last report. Otherwise shows only 'some' string if there are resources with given status. Setting this to False gives performance benefits, especially in big Puppet environment

  • normal_table_count (Integer[10,500]) (defaults to: 100)

    Default number of nodes to show when displaying reports and catalog nodes

  • little_table_count (Integer[1,50]) (defaults to: 10)

    Default number of reports to show when when looking at a node.

  • table_count_selector (Array[Integer]) (defaults to: [10, 20, 50, 100, 500])

    Configure the dropdown to limit number of hosts to show per page.

  • graph_type (String) (defaults to: 'pie')

    Specify the type of graph to display. Default is pie, other good option is donut. Other choices can be found here: _C3JS_documentation`

  • graph_facts_override (Array[String]) (defaults to: [])

    A list of fact names to tell PuppetBoard to generate a pie-chart on the fact page. With some fact values being unique per node, like ipaddress, uuid, and serial number, as well as structured facts it was no longer feasible to generate a graph for everything.

  • displayed_metrics_override (Array[String]) (defaults to: [])
  • inventory_facts_override (Hash[String, String]) (defaults to: {})

    list of tuples that serve as the column header and the fact name to search for to create the inventory page. If a fact is not found for a node then undef is printed.

  • query_endpoints_override (Array[Puppetboard::Query_endpoints]) (defaults to: [])

    If enable_query is True, allow to fine tune the endpoints of PuppetDB APIs that can be queried. It must be a list of strings of PuppetDB endpoints for which the query is enabled. See the QUERY_ENDPOINTS constant in the puppetboard.app module for a list of the available endpoints.

  • overview_filter (Optional[String]) (defaults to: undef)

    This allows to filter out nodes in the overview by passing queries to the PuppetDB

  • secret_key (Optional[Sensitive[String[24]]]) (defaults to: undef)

    the secret key to use

See Also:



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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'modules/puppetboard/manifests/init.pp', line 44

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,
    }

}