From 396d71cb8e005c6d5ea55a5201a0fb95bc9619de Mon Sep 17 00:00:00 2001 From: Norbert Varzariu Date: Wed, 20 Jan 2016 10:27:29 +0100 Subject: [PATCH 1/4] testing --- manifests/config.pp | 30 +++++++++++++++++++----------- manifests/init.pp | 2 ++ manifests/params.pp | 4 ++-- templates/exclude.erb | 2 +- templates/include.erb | 2 +- 5 files changed, 25 insertions(+), 15 deletions(-) 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 %> From 941036d9867e1304b78eb06e6f68c97da72e484f Mon Sep 17 00:00:00 2001 From: Norbert Varzariu Date: Wed, 20 Jan 2016 10:38:27 +0100 Subject: [PATCH 2/4] testing --- manifests/config.pp | 14 +++++--------- manifests/params.pp | 4 ++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index ff942c4..621d234 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -110,15 +110,11 @@ class rsnapshot::config ( } $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 $real_include != '' { + file { $include_file: + ensure => 'file', + content => template('rsnapshot/include.erb'), + } } $real_exclude = $rsnapshot::exclude + $exclude diff --git a/manifests/params.pp b/manifests/params.pp index d885dc3..2f9315b 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 From ab9ec44ced686946ec213bc70c06d30f5c043365 Mon Sep 17 00:00:00 2001 From: Norbert Varzariu Date: Wed, 20 Jan 2016 11:41:59 +0100 Subject: [PATCH 3/4] ensure in-/exclude file is absent if no in-/excludes given --- manifests/config.pp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 621d234..210fb84 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -67,8 +67,8 @@ 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 = $hash['include'] - $exclude = $hash['exclude'] + $include = pick($hash['include'], []) + $exclude = pick($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) @@ -110,7 +110,7 @@ class rsnapshot::config ( } $real_include = $rsnapshot::include + $include - if $real_include != '' { + unless empty($real_include) { file { $include_file: ensure => 'file', content => template('rsnapshot/include.erb'), @@ -118,7 +118,7 @@ class rsnapshot::config ( } $real_exclude = $rsnapshot::exclude + $exclude - if $real_exclude != '' { + unless empty($real_exclude) { file { $exclude_file: ensure => 'file', content => template('rsnapshot/exclude.erb'), From e39f638dfa99dcf976005a52207813b4715d224e Mon Sep 17 00:00:00 2001 From: Norbert Varzariu Date: Wed, 20 Jan 2016 11:45:31 +0100 Subject: [PATCH 4/4] bump version to 0.4.1 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 61ca00a..a23c9e5 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "loomsen-rsnapshot", - "version": "0.4.0", + "version": "0.4.1", "author": "loomsen", "summary": "Configures rsnapshot.", "license": "Apache-2.0",