Defined Type: tmpreaper::reap

Defined in:
modules/tmpreaper/manifests/reap.pp

Overview

Define: tmpreaper::reap

Purge a directory hierarchy of files that have not been accessed in a given period of time. Like `puppet::tidy`, but fast and secure.

Parameters

path

Path to tidy. Defaults to the resource name.

age

Defines the age threshold for removing files. If the file has not been accessed for <$age>, it becomes eligible for removal. The value should be a number suffixed by one character: 'd' for days, 'h' for hours, 'm' for minutes, or 's' for seconds. Defaults to '7d'.

include_symlinks

If true, remove symlinks too, not just regular files and directories. False by default.

include_all

If true, remove all file types, not just regular files, symlinks, and directories. Defaults to false.

protect

An optional array of shell patterns specifying files that should be protected from deletion.

Example

tmpreaper::reap { '/tmp':
    age              => '1d',
    protect          => ['*.log'],
    include_symlinks => true,
}

Parameters:

  • path (Any) (defaults to: $name)
  • age (Any) (defaults to: '7d')
  • protect (Any) (defaults to: [])
  • include_symlinks (Any) (defaults to: false)
  • include_all (Any) (defaults to: false)


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'modules/tmpreaper/manifests/reap.pp', line 37

define tmpreaper::reap(
    $path             = $name,
    $age              = '7d',
    $protect          = [],
    $include_symlinks = false,
    $include_all      = false,
) {
    include ::tmpreaper

    validate_re($age, '^\d+[smhd]$')
    validate_absolute_path($path)

    $args = template('tmpreaper/args.erb')

    exec { "/usr/sbin/tmpreaper ${args}":
        onlyif  => "/usr/sbin/tmpreaper --test ${args} 2>&1 | /bin/grep -q remove",
        require => Package['tmpreaper'],
    }
}