Puppet Class: puppetmaster::scripts

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

Summary

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

Overview

Parameters:

  • keep_reports_minutes (Integer) (defaults to: 960)

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

  • has_puppetdb (Boolean) (defaults to: true)

    inidcate if the system uses puppetdb

  • upload_facts (Boolean) (defaults to: true)
  • http_proxy (Optional[Stdlib::HTTPUrl]) (defaults to: undef)

    the http proxy to use

  • realm_override (Optional[String[1]]) (defaults to: undef)

    this is use to override the realm used for the facts upload. its only really used if you have two puppet masteres in the same projects servicing different clients e.g. cloudinfra



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

class puppetmaster::scripts(
    Integer                              $keep_reports_minutes = 960, # 16 hours
    Boolean                              $has_puppetdb         = true,
    Boolean                              $upload_facts         = true,
    Optional[Stdlib::HTTPUrl]            $http_proxy           = undef,
    Optional[String[1]]                  $realm_override       = undef,
){
    # export and sanitize facts for puppet compiler
    ensure_packages(['python3-requests', 'python3-yaml'])

    $puppet_facts_export_source = $has_puppetdb ? {
        false   => 'puppet:///modules/puppetmaster/puppet-facts-export-nodb.sh',
        default => 'puppet:///modules/puppetmaster/puppet-facts-export-puppetdb.py',
    }
    file { '/usr/local/bin/puppet-facts-export':
        ensure => file,
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
        source => $puppet_facts_export_source,
    }

    file { '/usr/local/sbin/puppet-facts-upload':
        ensure => stdlib::ensure($upload_facts, 'file'),
        owner  => 'root',
        group  => 'root',
        mode   => '0554',
        source => 'puppet:///modules/puppetmaster/puppet-facts-upload.py',
    }

    $proxy_arg = $http_proxy.then |$x| { "--proxy ${http_proxy}" }
    $realm_arg = $realm_override.then |$x| { "--realm ${realm_override}" }

    systemd::timer::job { 'upload_puppet_facts':
        ensure      => $upload_facts.bool2str('present', 'absent'),
        user        => 'root',
        description => 'Upload facts export to puppet compiler',
        command     => "/usr/local/sbin/puppet-facts-upload ${proxy_arg} ${realm_arg}",
        interval    => {'start' => 'OnUnitInactiveSec', 'interval' => '24h'},
    }

    # Clear out older reports
    systemd::timer::job { 'remove_old_puppet_reports':
        ensure      => 'present',
        user        => 'root',
        description => 'Clears out older puppet reports.',
        command     => "/usr/bin/find /var/lib/puppet/reports -type f -mmin +${keep_reports_minutes} -delete",
        interval    => {'start' => 'OnUnitInactiveSec', 'interval' => '8h'},
    }
}