Puppet Class: puppetmaster::scripts

Defined in:
modules/puppetmaster/manifests/scripts.pp

Overview

Class: puppetmaster::scripts

This class installs some puppetmaster server side scripts required for the manifests

Parameters

keep_reports_minutes

Number of minutes to keep older reports for before deleting them. The cron to remove these is run only every 8 hours, however, to prevent excess load on the prod puppetmasters.

Parameters:

  • keep_reports_minutes (Any) (defaults to: 960)


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
# File 'modules/puppetmaster/manifests/scripts.pp', line 12

class puppetmaster::scripts(
    $keep_reports_minutes = 960, # 16 hours
) {
    $servers = hiera('puppetmaster::servers', {})

    file{'/usr/local/bin/puppet-merge':
        ensure  => present,
        owner   => 'root',
        group   => 'root',
        mode    => '0555',
        content => template('puppetmaster/puppet-merge.erb'),
    }

    # export and sanitize facts for puppet compiler
    require_package('python3-requests', 'python3-yaml')
    file {'/usr/local/bin/puppet-facts-export':
        ensure => present,
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
        source => 'puppet:///modules/puppetmaster/puppet-facts-export.py',
    }

    # Clear out older reports
    cron { 'removeoldreports':
        ensure  => present,
        command => "find /var/lib/puppet/reports -type f -mmin +${keep_reports_minutes} -delete >/dev/null 2>&1",
        user    => puppet,
        hour    => [0, 8, 16], # Run every 8 hours, to prevent excess load
        minute  => 27, # Run at a time when hopefully no other cron jobs are
    }

    # Helper script to clean stored data about a server we're reimaging.
    if $::realm == 'production' {
        file { '/usr/local/sbin/install-console':
            ensure => 'present',
            owner  => 'root',
            group  => 'root',
            mode   => '0544',
            source => 'puppet:///modules/puppetmaster/install-console',
        }
    }
}