1
0
mirror of https://github.com/krislamo/puppet-rsnapshot synced 2024-09-20 01:10:35 +00:00

add prefix feature

This commit is contained in:
Administrator 2017-04-02 09:14:46 +02:00
parent 960b0090e4
commit 87775af5c7
3 changed files with 24 additions and 20 deletions

View File

@ -12,6 +12,8 @@ class rsnapshot::config (
$conf_d = pick($rsnapshot::conf_d, $rsnapshot::params::conf_d, '/etc/rsnapshot') $conf_d = pick($rsnapshot::conf_d, $rsnapshot::params::conf_d, '/etc/rsnapshot')
$snapshot_root = pick($hosts['snapshot_root'], $rsnapshot::snapshot_root, '/backup') $snapshot_root = pick($hosts['snapshot_root'], $rsnapshot::snapshot_root, '/backup')
$logpath = pick($rsnapshot::logpath, $rsnapshot::params::config_logpath) $logpath = pick($rsnapshot::logpath, $rsnapshot::params::config_logpath)
$cronfile_prefix_use = pick($rsnapshot::cronfile_prefix_use, $rsnapshot::params::cronfile_prefix_use, false)
$cronfile_prefix = pick($rsnapshot::cronfile_prefix, $rsnapshot::params::cronfile_prefix, '')
# make sure lock path and conf path exist # make sure lock path and conf path exist
file { $conf_d: file { $conf_d:
ensure => 'directory', ensure => 'directory',
@ -162,23 +164,25 @@ class rsnapshot::config (
} }
} }
if rsnapshot_prefix_use == false { if $cronfile_prefix_use {
$rsnapshot_prefix = $rsnapshot::cronfile_prefix
} else {
$rsnapshot_prefix = '' $rsnapshot_prefix = ''
} }
# cron on Debian seems to ignore files that have dots in their name; replace # cron on Debian seems to ignore files that have dots in their name; replace
# them with underscores (issue #2) # them with underscores (issue #2)
if $::osfamily == 'Debian' { case $::osfamily {
'Debian': {
$cron_name = regsubst($host, '\.', '_', 'G') $cron_name = regsubst($host, '\.', '_', 'G')
$cronfile = "${cron_dir}/${rsnapshot_prefix}${cron_name}" $cronfile = "${cron_dir}/${rsnapshot_prefix}${cron_name}"
} }
else { 'RedHat': {
$cronfile = "${cron_dir}/${rsnapshot_prefix}${host}"
}
default: {
$cronfile = "${cron_dir}/${rsnapshot_prefix}${host}" $cronfile = "${cron_dir}/${rsnapshot_prefix}${host}"
} }
# Make sure old cron files without rsnapshot_prefix are removed
file { "${cron_dir}/${host}":
ensure => absent,
} }
concat { $cronfile: concat { $cronfile:

View File

@ -19,8 +19,8 @@ class rsnapshot (
$snapshot_root = $rsnapshot::params::config_snapshot_root, $snapshot_root = $rsnapshot::params::config_snapshot_root,
$backup_levels = $rsnapshot::params::config_backup_levels, $backup_levels = $rsnapshot::params::config_backup_levels,
$cron_service_name = $rsnapshot::params::cron_service_name, $cron_service_name = $rsnapshot::params::cron_service_name,
$rsnapshot_prefix = $rsnapshot::params::config_rsnapshot_prefix, $cronfile_prefix = $rsnapshot::params::config_cronfile_prefix,
$rsnapshot_prefix_use = $rsnapshot::params::config_rsnapshot_prefix_use, $cronfile_prefix_use = $rsnapshot::params::config_cronfile_prefix_use,
$check_mk_job = $rsnapshot::params::config_check_mk_job, $check_mk_job = $rsnapshot::params::config_check_mk_job,
) inherits rsnapshot::params { ) inherits rsnapshot::params {

View File

@ -43,8 +43,8 @@ class rsnapshot::params {
$config_verbose = '2' $config_verbose = '2'
$config_loglevel = '4' $config_loglevel = '4'
$config_stop_on_stale_lockfile = undef # bool $config_stop_on_stale_lockfile = undef # bool
$config_rsnapshot_prefix = 'rsnapshot_' $config_cronfile_prefix = 'rsnapshot_'
$config_rsnapshot_prefix_use = false $config_cronfile_prefix_use = false
$config_rsync_short_args = '-az' $config_rsync_short_args = '-az'
$config_rsync_long_args = undef # defaults are --delete --numeric-ids --relative --delete-excluded $config_rsync_long_args = undef # defaults are --delete --numeric-ids --relative --delete-excluded
$config_ssh_args = undef $config_ssh_args = undef
@ -127,6 +127,6 @@ class rsnapshot::params {
], ],
default => [], default => [],
}, },
} },
} }
} }