Puppet Class: profile::puppet::client_bucket

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

Overview

SPDX-License-Identifier: Apache-2.0 cleans up puppet client bucket (T165885)

Parameters:

  • ensure (Wmflib::Ensure) (defaults to: lookup('profile::puppet::client_bucket::ensure'))
  • file_age (Integer) (defaults to: lookup('profile::puppet::client_bucket::file_age'))
  • max_size (Stdlib::Datasize) (defaults to: lookup('profile::puppet::client_bucket::max_size'))


3
4
5
6
7
8
9
10
11
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
# File 'modules/profile/manifests/puppet/client_bucket.pp', line 3

class profile::puppet::client_bucket(
    Wmflib::Ensure   $ensure   = lookup('profile::puppet::client_bucket::ensure'),
    Integer          $file_age = lookup('profile::puppet::client_bucket::file_age'),
    Stdlib::Datasize $max_size = lookup('profile::puppet::client_bucket::max_size'),
){
    file { '/var/lib/puppet/clientbucket':
        ensure => directory,
        mode   => '0750',
    }

    systemd::timer::job { 'clean_puppet_client_bucket':
        ensure             => $ensure,
        description        => 'Delete old files from the puppet client bucket',
        command            => "/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +${file_age} -atime +${file_age} -delete",
        interval           => {
            'start'    => 'OnUnitInactiveSec',
            'interval' => '24h',
        },
        logging_enabled    => false,
        monitoring_enabled => false,
        user               => 'root',
        require            => File['/var/lib/puppet/clientbucket'],
    }
    $script = @("SCRIPT"/L)
    #!/bin/bash
    if [ -z "$(/usr/bin/find /var/lib/puppet/clientbucket -type f -size +${max_size} | head -c1)" ]
    then
        printf "OK: client bucket file ok\n"
        exit 0
    fi
    printf "WARNING: large files in client bucket\n"
    exit 2
    | SCRIPT

    nrpe::plugin { 'check_client_bucket':
        ensure  => $ensure,
        content => $script,
    }

    sudo::user { 'nrpe_check_client_bucket_large_file':
        ensure => absent,
    }

    nrpe::monitor_service { 'client_bucket_large_file':
        ensure       => absent,
        description  => 'Check for large files in client bucket',
        notes_url    => 'https://wikitech.wikimedia.org/wiki/Puppet#check_client_bucket_large_file',
        nrpe_command => '/usr/local/lib/nagios/plugins/check_client_bucket',
        sudo_user    => 'root',
    }
}