Puppet Class: profile::debmonitor::client

Defined in:
modules/profile/manifests/debmonitor/client.pp

Overview

Class: profile::debmonitor::client This profile installs the Debmonitor client and its configuration.

Actions:

Expose Puppet certs for the debmonitor user
Install DebMonitor client's configuration
Install DebMonitor client

Sample Usage:

include ::profile::debmonitor::client

Parameters:

  • debmonitor_server (Stdlib::Host) (defaults to: lookup('debmonitor'))

    the main debmonitor server

  • ssl_ca (Enum['puppet', 'cfssl']) (defaults to: lookup('profile::debmonitor::client::ssl_ca'))

    use the puppet issued certs or request a cert from cfssl

  • ssl_ca_label (Optional[String]) (defaults to: lookup('profile::debmonitor::client::ssl_ca_label'))

    if using cfssl this is the ca label to use for certificate requests



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
# File 'modules/profile/manifests/debmonitor/client.pp', line 15

class profile::debmonitor::client (
    Stdlib::Host            $debmonitor_server = lookup('debmonitor'),
    Enum['puppet', 'cfssl'] $ssl_ca            = lookup('profile::debmonitor::client::ssl_ca'),
    Optional[String]        $ssl_ca_label      = lookup('profile::debmonitor::client::ssl_ca_label'),
){

    $base_path = '/etc/debmonitor'

    # On Debmonitor server hosts this is already defined by service::uwsgi.
    if !defined(File[$base_path]) {
        # Create directory for the exposed Puppet certs.
        file { $base_path:
            ensure => directory,
            owner  => 'debmonitor',
            group  => 'debmonitor',
            mode   => '0555',
        }
    }

    # Create user and group to which expose the Puppet certs.
    group { 'debmonitor':
        ensure => present,
        system => true,
    }

    user { 'debmonitor':
        ensure     => present,
        gid        => 'debmonitor',
        shell      => '/bin/bash',
        home       => '/nonexistent',
        managehome => false,
        system     => true,
        comment    => 'DebMonitor system user',
    }

    if $ssl_ca == 'puppet' {
        # TODO: consider using profile::pki::get_cert
        puppet::expose_agent_certs { $base_path:
            user            => 'debmonitor',
            group           => 'debmonitor',
            provide_private => true,
            require         => File[$base_path],
            before          => Package['debmonitor-client'],
        }

        $cert = "${base_path}/ssl/cert.pem"
        $private_key = "${base_path}/ssl/server.key"
    } else {
        unless $ssl_ca_label {
            fail('must specify \$ssl_label when using \$ssl_ca == \'cfssl\'')
        }
        $ssl_paths = profile::pki::get_cert($ssl_ca_label, $facts['networking']['fqdn'], {
            owner  => 'debmonitor',
            group  => 'debmonitor',
            outdir => "${base_path}/ssl",
            before => Package['debmonitor-client']
        })
        $cert        = $ssl_paths['cert']
        $private_key = $ssl_paths['key']
    }

    # Create the Debmonitor client configuration file.
    file { '/etc/debmonitor.conf':
        ensure  => present,
        owner   => 'debmonitor',
        group   => 'debmonitor',
        mode    => '0440',
        content => template('profile/debmonitor/client/debmonitor.conf.erb'),
        before  => Package['debmonitor-client'],
    }

    # We have to install debmonitor-client after /etc/debmonitor.conf and the
    # ssl certs are configured. This is due to the fact that:
    #  * during installation we install the debmonitor apt->hook
    #  * post installation we run the apt->hook installed above
    # If the certs and config file are not in place this will fail. The ssl and
    # file resources have an explicit Before statements and we also place the
    # installation here so the manifest order represent the catalogue order
    ensure_packages(['debmonitor-client'])

    $hour = Integer(seeded_rand(24, $::fqdn))
    $minute = Integer(seeded_rand(60, $::fqdn))

    systemd::timer::job { 'debmonitor-client':
        ensure        => 'present',
        user          => 'debmonitor',
        description   => 'reconciliation job in case any debmonitor update fails',
        command       => '/usr/bin/debmonitor-client',
        send_mail     => true,
        ignore_errors => true,
        interval      => {'start' => 'OnCalendar', 'interval' => "*-*-* ${hour}:${minute}:30"},
        require       => Package['debmonitor-client'],
    }
}