From 6e7d8e02f336e7e899d08c4e6ab17262fd8c81e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bauer?= Date: Sat, 1 Apr 2017 23:27:18 +0200 Subject: [PATCH] use prefix not by default --- manifests/config.pp | 8 ++++++-- manifests/init.pp | 33 +++++++++++++++++---------------- manifests/params.pp | 1 + 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 0f9edaf..86c5b94 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -162,10 +162,14 @@ class rsnapshot::config ( } } + if rsnapshot_prefix_use == false { + $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}", '\.', '_') + $cron_name = regsubst($host, '\.', '_', 'G') $cronfile = "${cron_dir}/${rsnapshot_prefix}${cron_name}" } else { @@ -182,7 +186,7 @@ class rsnapshot::config ( # create cron files for each backup level # merge possible cron definitions to one $real_cron = deep_merge($rsnapshot::params::cron, $rsnapshot::cron, $hash[cron]) - concat::fragment { "mailto for $host": + concat::fragment { "mailto for ${host}": content => "#This file is managed by puppet\nMAILTO=${real_cron[mailto]}\n\n", target => $cronfile, order => 1, diff --git a/manifests/init.pp b/manifests/init.pp index 5f17c91..74f970e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -5,22 +5,23 @@ # === Parameters # class rsnapshot ( - $hosts = $rsnapshot::params::hosts, - $conf_d = $rsnapshot::params::conf_d, - $logpath = $rsnapshot::params::config_logpath, - $lockpath = $rsnapshot::params::config_lockpath, - $default_backup = $rsnapshot::params::config_default_backup, - $package_name = $rsnapshot::params::package_name, - $package_ensure = $rsnapshot::params::package_ensure, - $cron = $rsnapshot::params::cron, - $backup_scripts = $rsnapshot::params::backup_scripts, - $include = $rsnapshot::params::config_include, - $exclude = $rsnapshot::params::config_exclude, - $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, - $check_mk_job = $rsnapshot::params::config_check_mk_job, + $hosts = $rsnapshot::params::hosts, + $conf_d = $rsnapshot::params::conf_d, + $logpath = $rsnapshot::params::config_logpath, + $lockpath = $rsnapshot::params::config_lockpath, + $default_backup = $rsnapshot::params::config_default_backup, + $package_name = $rsnapshot::params::package_name, + $package_ensure = $rsnapshot::params::package_ensure, + $cron = $rsnapshot::params::cron, + $backup_scripts = $rsnapshot::params::backup_scripts, + $include = $rsnapshot::params::config_include, + $exclude = $rsnapshot::params::config_exclude, + $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, + $check_mk_job = $rsnapshot::params::config_check_mk_job, ) inherits rsnapshot::params { diff --git a/manifests/params.pp b/manifests/params.pp index 40d5680..61c6a52 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -44,6 +44,7 @@ class rsnapshot::params { $config_loglevel = '4' $config_stop_on_stale_lockfile = undef # bool $config_rsnapshot_prefix = 'rsnapshot_' + $config_rsnapshot_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