diff --git a/manifests/config.pp b/manifests/config.pp index 86c5b94..e5237c2 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -2,8 +2,8 @@ # # manage host configs class rsnapshot::config ( - $hosts = $rsnapshot::hosts, - $cron_dir = $rsnapshot::cron_dir, + $hosts = $rsnapshot::hosts, + $cron_dir = $rsnapshot::cron_dir, ) { # these are global settings, no point in setting them per host @@ -12,6 +12,8 @@ class rsnapshot::config ( $conf_d = pick($rsnapshot::conf_d, $rsnapshot::params::conf_d, '/etc/rsnapshot') $snapshot_root = pick($hosts['snapshot_root'], $rsnapshot::snapshot_root, '/backup') $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 file { $conf_d: ensure => 'directory', @@ -162,23 +164,25 @@ class rsnapshot::config ( } } - if rsnapshot_prefix_use == false { - $rsnapshot_prefix = '' + if $cronfile_prefix_use { + $rsnapshot_prefix = $rsnapshot::cronfile_prefix + } else { + $rsnapshot_prefix = '' } # cron on Debian seems to ignore files that have dots in their name; replace # them with underscores (issue #2) - if $::osfamily == 'Debian' { - $cron_name = regsubst($host, '\.', '_', 'G') - $cronfile = "${cron_dir}/${rsnapshot_prefix}${cron_name}" - } - else { - $cronfile = "${cron_dir}/${rsnapshot_prefix}${host}" - } - - # Make sure old cron files without rsnapshot_prefix are removed - file { "${cron_dir}/${host}": - ensure => absent, + case $::osfamily { + 'Debian': { + $cron_name = regsubst($host, '\.', '_', 'G') + $cronfile = "${cron_dir}/${rsnapshot_prefix}${cron_name}" + } + 'RedHat': { + $cronfile = "${cron_dir}/${rsnapshot_prefix}${host}" + } + default: { + $cronfile = "${cron_dir}/${rsnapshot_prefix}${host}" + } } concat { $cronfile: diff --git a/manifests/init.pp b/manifests/init.pp index 74f970e..f586bcc 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -19,8 +19,8 @@ class rsnapshot ( $snapshot_root = $rsnapshot::params::config_snapshot_root, $backup_levels = $rsnapshot::params::config_backup_levels, $cron_service_name = $rsnapshot::params::cron_service_name, - $rsnapshot_prefix = $rsnapshot::params::config_rsnapshot_prefix, - $rsnapshot_prefix_use = $rsnapshot::params::config_rsnapshot_prefix_use, + $cronfile_prefix = $rsnapshot::params::config_cronfile_prefix, + $cronfile_prefix_use = $rsnapshot::params::config_cronfile_prefix_use, $check_mk_job = $rsnapshot::params::config_check_mk_job, ) inherits rsnapshot::params { diff --git a/manifests/params.pp b/manifests/params.pp index 61c6a52..b106631 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -43,8 +43,8 @@ class rsnapshot::params { $config_verbose = '2' $config_loglevel = '4' $config_stop_on_stale_lockfile = undef # bool - $config_rsnapshot_prefix = 'rsnapshot_' - $config_rsnapshot_prefix_use = false + $config_cronfile_prefix = 'rsnapshot_' + $config_cronfile_prefix_use = false $config_rsync_short_args = '-az' $config_rsync_long_args = undef # defaults are --delete --numeric-ids --relative --delete-excluded $config_ssh_args = undef @@ -127,6 +127,6 @@ class rsnapshot::params { ], default => [], }, - } + }, } }