Puppet Class: profile::puppet::agent

Defined in:
modules/profile/manifests/puppet/agent.pp

Summary

install and configure puppet agent

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • puppetmaster (String) (defaults to: lookup('puppetmaster'))

    the puppet server

  • ca_server (Optional[String[1]]) (defaults to: lookup('puppet_ca_server'))

    the ca server

  • ca_source (Stdlib::Filesource) (defaults to: lookup('puppet_ca_source'))

    to source of the CA file

  • manage_ca_file (Boolean) (defaults to: lookup('manage_puppet_ca_file'))

    if true manage the puppet ca file

  • interval (Integer[1,59]) (defaults to: lookup('profile::puppet::agent::interval'))

    the, in minutes, interval to perform puppet runs

  • enable_puppet7 (Boolean) (defaults to: lookup('profile::puppet::agent::enable_puppet7'))

    install th component that configures puppet7

  • environment (Optional[String[1]]) (defaults to: lookup('profile::puppet::agent::environment'))

    the agent environment

  • serialization_format (Enum['pson', 'json', 'msgpack']) (defaults to: lookup('profile::puppet::agent::serialization_format'))

    the serilasation format of catalogs

  • dns_alt_names (Array[Stdlib::Fqdn]) (defaults to: lookup('profile::puppet::agent::dns_alt_names'))

    a list of dns alt names

  • certificate_revocation (Optional[Enum['chain', 'leaf']]) (defaults to: lookup('profile::puppet::agent::certificate_revocation'))

    The level of certificate revocation to perform



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
116
117
118
119
# File 'modules/profile/manifests/puppet/agent.pp', line 13

class profile::puppet::agent (
    String                          $puppetmaster           = lookup('puppetmaster'),
    Optional[String[1]]             $ca_server              = lookup('puppet_ca_server'),
    Stdlib::Filesource              $ca_source              = lookup('puppet_ca_source'),
    Boolean                         $manage_ca_file         = lookup('manage_puppet_ca_file'),
    Integer[1,59]                   $interval               = lookup('profile::puppet::agent::interval'),
    Boolean                         $enable_puppet7         = lookup('profile::puppet::agent::enable_puppet7'),
    Optional[String[1]]             $environment            = lookup('profile::puppet::agent::environment'),
    Enum['pson', 'json', 'msgpack'] $serialization_format   = lookup('profile::puppet::agent::serialization_format'),
    Array[Stdlib::Fqdn]             $dns_alt_names          = lookup('profile::puppet::agent::dns_alt_names'),
    Optional[Enum['chain', 'leaf']] $certificate_revocation = lookup('profile::puppet::agent::certificate_revocation'),
) {
    if $enable_puppet7 {
        if debian::codename::lt('bullseye') {
            # We only have packages for bullseye currently
            fail('puppet7 is only avalible for bullseye')
        }
        apt::package_from_component { 'puppet':
            component => 'component/puppet7',
            priority  => 1002,
        }
    }
    class { 'puppet::agent':
        ca_source              => $ca_source,
        manage_ca_file         => $manage_ca_file,
        server                 => $puppetmaster,
        ca_server              => $ca_server,
        dns_alt_names          => $dns_alt_names,
        environment            => $environment,
        certificate_revocation => $certificate_revocation,
    }
    class { 'puppet_statsd':
        statsd_host   => 'statsd.eqiad.wmnet',
        metric_format => 'puppet.<%= metric %>',
    }
    class { 'prometheus::node_puppet_agent': }
    include profile::puppet::client_bucket

    # Mode 0751 to make sure non-root users can access
    # /var/lib/puppet/state/agent_disabled.lock to check if puppet is enabled
    file { '/var/lib/puppet':
        ensure => directory,
        owner  => 'puppet',
        group  => 'puppet',
        mode   => '0751',
    }
    # WMF helper scripts
    file {
        default:
            ensure => file,
            mode   => '0555',
            owner  => 'root',
            group  => 'root';
        '/usr/local/share/bash/puppet-common.sh':
            source => 'puppet:///modules/profile/puppet/bin/puppet-common.sh';
        '/usr/local/sbin/puppet-run':
            content => template('profile/puppet/puppet-run.erb');
        '/usr/local/bin/puppet-enabled':
            source => 'puppet:///modules/profile/puppet/bin/puppet-enabled';
        '/usr/local/sbin/disable-puppet':
            mode   => '0550',
            source => 'puppet:///modules/profile/puppet/bin/disable-puppet';
        '/usr/local/sbin/enable-puppet':
            mode   => '0550',
            source => 'puppet:///modules/profile/puppet/bin/enable-puppet';
        '/usr/local/sbin/run-puppet-agent':
            mode   => '0550',
            source => 'puppet:///modules/profile/puppet/bin/run-puppet-agent';
        '/usr/local/sbin/run-no-puppet':
            mode   => '0550',
            source => 'puppet:///modules/profile/puppet/bin/run-no-puppet';
    }
    $timer_interval = "*:${interval.fqdn_rand}/${interval}:00"

    systemd::timer::job { 'puppet-agent-timer':
        ensure        => present,
        description   => "Run Puppet agent every ${interval} minutes",
        user          => 'root',
        ignore_errors => true,
        command       => '/usr/local/sbin/puppet-run',
        interval      => [
            { 'start' => 'OnCalendar', 'interval' => $timer_interval },
            { 'start' => 'OnStartupSec', 'interval' => '1min' },
        ],
    }

    logrotate::rule { 'puppet':
        ensure       => present,
        file_glob    => '/var/log/puppet /var/log/puppet.log',
        frequency    => 'daily',
        compress     => true,
        missing_ok   => true,
        not_if_empty => true,
        rotate       => 7,
    }

    rsyslog::conf { 'puppet-agent':
        source   => 'puppet:///modules/profile/puppet/rsyslog.conf',
        priority => 10,
        require  => File['/etc/logrotate.d/puppet'],
    }
    motd::script { 'last-puppet-run':
        ensure   => present,
        priority => 97,
        source   => 'puppet:///modules/profile/puppet/97-last-puppet-run',
    }
}