Puppet Class: profile::wmcs::nfs::daily_file_cleanup
- Defined in:
- modules/profile/manifests/wmcs/nfs/daily_file_cleanup.pp
Overview
Recursively remove old files from a directory, where 'old' and 'directory' are defined in hiera. This was initially created to clean up old files on the PAWS nfs share with the following args:
profile::wmcs::daily_file_cleanup::trash_path: /srv/paws/files-to-remove profile::wmcs::daily_file_cleanup::user_home_dir: /srv/paws/project/paws/userhomes profile::wmcs::daily_file_cleanup::age_in_days: 21
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 |
# File 'modules/profile/manifests/wmcs/nfs/daily_file_cleanup.pp', line 13
class profile::wmcs::nfs::daily_file_cleanup(
Stdlib::Unixpath $trash_path = lookup('profile::wmcs::daily_file_cleanup::trash_path'),
Stdlib::Unixpath $user_home_dir = lookup('profile::wmcs::daily_file_cleanup::user_home_dir'),
Integer $age_in_days = lookup('profile::wmcs::daily_file_cleanup::age_in_days'),
) {
file { '/usr/local/sbin/scan-and-shrink':
ensure => 'present',
owner => 'root',
group => 'root',
mode => '0744',
source => 'puppet:///modules/profile/wmcs/nfs/scan-and-shrink.py';
}
systemd::timer::job { 'scan_and_move_large_files':
ensure => present,
description => 'Moves large files via scan-and-shrink',
command => "/usr/local/sbin/scan-and-shrink --scanpath ${user_home_dir} --trashpath ${trash_path}",
interval => {
'start' => 'OnCalendar',
'interval' => '*-*-* 13:00:00',
},
logging_enabled => true,
user => 'root',
}
systemd::timer::job { 'daily_file_cleanup':
ensure => present,
description => "Delete files older than ${age_in_days} from ${trash_path}",
command => "/usr/bin/find ${trash_path} -mindepth 1 -mtime +${age_in_days} -delete",
interval => {
'start' => 'OnCalendar',
'interval' => '*-*-* 1:00:00',
},
logging_enabled => true,
user => 'root',
}
}
|