diff --git a/manifests/config.pp b/manifests/config.pp index 81900d3..ff942c4 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -5,6 +5,7 @@ class rsnapshot::config ( $hosts = $rsnapshot::hosts, $cron_dir = $rsnapshot::cron_dir, ) { + # these are global settings, no point in setting them per host $config_version = $rsnapshot::params::config_version $lockpath = pick($rsnapshot::lockpath, $rsnapshot::params::config_lockpath, '/var/run/rsnapshot') @@ -33,7 +34,7 @@ class rsnapshot::config ( $hosts_clean.each |String $host, $hash | { $backup_user = pick($hash['backup_user'], $rsnapshot::params::config_backup_user) $default_backup_dirs = pick($rsnapshot::default_backup, $rsnapshot::params::config_default_backup) - $backup_levels = pick($hash['backup_levels'], $rsnapshot::params::config_backup_levels, 'weekly') + $backup_levels = pick($hash['backup_levels'], $rsnapshot::backup_levels, 'weekly') $backup = $hash['backup'] $backup_defaults = pick($hash['backup_defaults'], $rsnapshot::params::config_backup_defaults) $cmd_cp = pick($hash['cmd_cp'], $rsnapshot::params::config_cmd_cp) @@ -66,9 +67,9 @@ class rsnapshot::config ( $one_fs = pick_undef($hash['one_fs'], $rsnapshot::params::config_one_fs) $interval = pick($hash['interval'], $rsnapshot::params::config_interval) $retain = pick_undef($hash['retain'], $rsnapshot::params::config_retain) - $include = pick_undef($hash['include'], $rsnapshot::params::config_include) - $exclude = pick_undef($hash['exclude'], $rsnapshot::params::config_exclude) - $include_file = pick_undef($hash['include_file'], $rsnapshot::params::config_include_file) + $include = $hash['include'] + $exclude = $hash['exclude'] + $include_file = pick($hash['include_file'], $rsnapshot::params::config_include_file, "${conf_d}/${host}.include") $exclude_file = pick($hash['exclude_file'], $rsnapshot::params::config_exclude_file, "${conf_d}/${host}.exclude") $link_dest = pick_undef($hash['link_dest'], $rsnapshot::params::config_link_dest) $sync_first = pick_undef($hash['sync_first'], $rsnapshot::params::config_sync_first) @@ -108,19 +109,26 @@ class rsnapshot::config ( $use_lazy_deletes_num = bool2num($use_lazy_deletes) } - if $include != '' { - file { $include_file: - ensure => 'file', - content => template('rsnapshot/include.erb'), - } + $real_include = $rsnapshot::include + $include + notify { "$real_include for $host": } + if empty($real_include) { + notify { "$host $real_include is empty": } + } else { + # file { $include_file: + # ensure => 'file', + # content => template('rsnapshot/include.erb'), + #} + notify { "${host} $real_include is not empty": } } - - if $exclude != '' { + + $real_exclude = $rsnapshot::exclude + $exclude + if $real_exclude != '' { file { $exclude_file: ensure => 'file', content => template('rsnapshot/exclude.erb'), } } + concat { $config: } concat::fragment { "${config} for ${host}": diff --git a/manifests/init.pp b/manifests/init.pp index aed59b6..8f1f5fd 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -14,8 +14,10 @@ class rsnapshot ( $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, ) inherits rsnapshot::params { $default_backup_scripts = $rsnapshot::params::backup_scripts + $backup_scripts diff --git a/manifests/params.pp b/manifests/params.pp index 2f9315b..d885dc3 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -48,8 +48,8 @@ class rsnapshot::params { 'weekly' => '4', 'monthly' => '6', } - $config_include = [] - $config_exclude = [] + $config_include = [ ] + $config_exclude = [ ] $config_include_file = undef $config_exclude_file = undef $config_link_dest = false diff --git a/templates/exclude.erb b/templates/exclude.erb index 1c9bb33..8318bd7 100644 --- a/templates/exclude.erb +++ b/templates/exclude.erb @@ -1,3 +1,3 @@ -<% @exclude.each do |exc| -%> +<% @real_exclude.each do |exc| -%> <%= exc %> <% end %> diff --git a/templates/include.erb b/templates/include.erb index de19070..0a19958 100644 --- a/templates/include.erb +++ b/templates/include.erb @@ -1,3 +1,3 @@ -<% @include.each do |inc| -%> +<% @real_include.each do |inc| -%> <%= inc %> <% end %>