From 0d6a2ec42949af1c08c673fe2dc1cad7973d7649 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 16 Jul 2009 18:23:05 -0300 Subject: Checking whether an exported resource is defined Checking whether an exported resource is already defined at backupninja::server::sandbox, otherwise puppet will try to redefined them each time a backup resource type is invoked with the same arguments (such as $directory), raising an error. --- manifests/server.pp | 84 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 37 deletions(-) (limited to 'manifests') diff --git a/manifests/server.pp b/manifests/server.pp index 213022b..fa85492 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -63,57 +63,67 @@ class backupninja::server { false => "backupninja-$real_host", default => $backuptag, } - - @@file { "$real_dir": - ensure => directory, - mode => 0750, owner => $user, group => 0, - tag => "$real_backuptag", + + if !defined(File["$real_dir"]) { + @@file { "$real_dir": + ensure => directory, + mode => 0750, owner => $user, group => 0, + tag => "$real_backuptag", + } } case $installuser { true: { case $manage_ssh_dir { true: { - @@file { "${real_ssh_dir}": - ensure => directory, - mode => 0700, owner => $user, group => 0, - require => File["$real_dir"], - tag => "$real_backuptag", + if !defined(File["$real_ssh_dir"]) { + @@file { "${real_ssh_dir}": + ensure => directory, + mode => 0700, owner => $user, group => 0, + require => File["$real_dir"], + tag => "$real_backuptag", + } } } } - @@file { "${real_ssh_dir}/${real_authorized_keys_file}": - ensure => present, - mode => 0644, owner => 0, group => 0, - source => "$real_backupkeys/${user}_id_${keytype}.pub", - require => File["${real_ssh_dir}"], - tag => "$real_backuptag", + if !defined(File["$real_ssh_dir"]) { + @@file { "${real_ssh_dir}/${real_authorized_keys_file}": + ensure => present, + mode => 0644, owner => 0, group => 0, + source => "$real_backupkeys/${user}_id_${keytype}.pub", + require => File["${real_ssh_dir}"], + tag => "$real_backuptag", + } } case $uid { false: { - @@user { "$user": - ensure => "present", - gid => "$gid", - comment => "$name backup sandbox", - home => "$real_dir", - managehome => true, - shell => "/bin/sh", - password => '*', - require => Group['backupninjas'], - tag => "$real_backuptag" + if !defined(File["$real_ssh_dir"]) { + @@user { "$user": + ensure => "present", + gid => "$gid", + comment => "$name backup sandbox", + home => "$real_dir", + managehome => true, + shell => "/bin/sh", + password => '*', + require => Group['backupninjas'], + tag => "$real_backuptag" + } } } default: { - @@user { "$user": - ensure => "present", - uid => "$uid", - gid => "$gid", - comment => "$name backup sandbox", - home => "$real_dir", - managehome => true, - shell => "/bin/sh", - password => '*', - require => Group['backupninjas'], - tag => "$real_backuptag" + if !defined(File["$real_ssh_dir"]) { + @@user { "$user": + ensure => "present", + uid => "$uid", + gid => "$gid", + comment => "$name backup sandbox", + home => "$real_dir", + managehome => true, + shell => "/bin/sh", + password => '*', + require => Group['backupninjas'], + tag => "$real_backuptag" + } } } } -- cgit v1.2.3 From 3b2c88b24b73a6c31e6b5bc5de6108108d4a276c Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Wed, 26 Aug 2009 21:37:43 -0300 Subject: Fixing some definitions at backupninja::server::sandbox --- manifests/server.pp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'manifests') diff --git a/manifests/server.pp b/manifests/server.pp index fa85492..28b97d5 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -85,7 +85,7 @@ class backupninja::server { } } } - if !defined(File["$real_ssh_dir"]) { + if !defined(File["${real_ssh_dir}/${real_authorized_keys_file}"]) { @@file { "${real_ssh_dir}/${real_authorized_keys_file}": ensure => present, mode => 0644, owner => 0, group => 0, @@ -96,7 +96,7 @@ class backupninja::server { } case $uid { false: { - if !defined(File["$real_ssh_dir"]) { + if !defined(File["$real_user"]) { @@user { "$user": ensure => "present", gid => "$gid", @@ -111,8 +111,8 @@ class backupninja::server { } } default: { - if !defined(File["$real_ssh_dir"]) { - @@user { "$user": + if !defined(File["$real_user"]) { + @@user { "$real_user": ensure => "present", uid => "$uid", gid => "$gid", -- cgit v1.2.3 From c533d7aa3a2b95049fa625da9182854f3a2f5e53 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Wed, 26 Aug 2009 21:54:25 -0300 Subject: Fixing some definitions at backupninja::server::sandbox (2) --- manifests/server.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'manifests') diff --git a/manifests/server.pp b/manifests/server.pp index 28b97d5..790c931 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -96,8 +96,8 @@ class backupninja::server { } case $uid { false: { - if !defined(File["$real_user"]) { - @@user { "$user": + if !defined(User["$real_user"]) { + @@user { "$real_user": ensure => "present", gid => "$gid", comment => "$name backup sandbox", @@ -111,7 +111,7 @@ class backupninja::server { } } default: { - if !defined(File["$real_user"]) { + if !defined(User["$real_user"]) { @@user { "$real_user": ensure => "present", uid => "$uid", -- cgit v1.2.3 From 264f3ef1216d1e1e4ab0171e7b503bbb8c4658e1 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Thu, 27 Aug 2009 16:28:30 -0400 Subject: remove some stray comments --- manifests/dup.pp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'manifests') diff --git a/manifests/dup.pp b/manifests/dup.pp index 61491c6..26514ad 100644 --- a/manifests/dup.pp +++ b/manifests/dup.pp @@ -36,10 +36,10 @@ define backupninja::duplicity( $order = 90, $ensure = present, # options to the config file - $options = false, # - $nicelevel = 0, # - $testconnect = "yes", # - $tmpdir = "/var/tmp/duplicity", # + $options = false, + $nicelevel = 0, + $testconnect = "yes", + $tmpdir = "/var/tmp/duplicity", # [gpg] $sign = "no", $encryptkey = false, -- cgit v1.2.3 From 1ec565f20a431ab8b44d655cb59ab01706b5312f Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Thu, 27 Aug 2009 17:05:36 -0400 Subject: I unset the duplicity options that are set by default by backupninja already (it is unecessary to set them when they are already set to the defaults): testconnect, sign, keep, bandwidthlimit I also unset because they were not set to the defaults: $tmpdir = "/var/tmp/duplicity", $nicelevel = 19. The defaults for these are: $tmpdir = "/tmp", and $nicelevel = 0. The example configuration files included in backupninja are confusing about these, so I've just clarified those in the upstream source. Then there were a couple options that were set to values that I think should not be set: $password = "a_very_complicated_passphrase" -- I dont think this should be set by default at all, because people will accidentally use this passphrase by default (yuck). People should be forced to set this. I also reset the $destdir = "/backups" setting to be false. This value must be set, but I dont think it should be set by default. --- manifests/dup.pp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'manifests') diff --git a/manifests/dup.pp b/manifests/dup.pp index 26514ad..afcdab2 100644 --- a/manifests/dup.pp +++ b/manifests/dup.pp @@ -37,14 +37,14 @@ define backupninja::duplicity( $order = 90, $ensure = present, # options to the config file $options = false, - $nicelevel = 0, - $testconnect = "yes", - $tmpdir = "/var/tmp/duplicity", + $nicelevel = false, + $testconnect = false, + $tmpdir = false, # [gpg] - $sign = "no", + $sign = false, $encryptkey = false, $signkey = false, - $password = "a_very_complicated_passphrase", + $password = false, # [source] $include = [ "/var/spool/cron/crontabs", "/var/backups", @@ -67,10 +67,10 @@ define backupninja::duplicity( $order = 90, $vsinclude = false, # [dest] $incremental = "yes", - $keep = 60, - $bandwithlimit = "0", + $keep = false, + $bandwithlimit = false, $sshoptions = false, - $destdir = "/backups", + $destdir = false, $desthost = false, $destuser = false, # configs to backupninja client -- cgit v1.2.3 From aaa46561012ac8ab6070f8cd53a111346c586f5f Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Thu, 27 Aug 2009 17:10:56 -0400 Subject: fix the $desthost variable requirement, was incorrectly set to $host add a $destdir variable requirement --- manifests/dup.pp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'manifests') diff --git a/manifests/dup.pp b/manifests/dup.pp index afcdab2..f734e5d 100644 --- a/manifests/dup.pp +++ b/manifests/dup.pp @@ -88,7 +88,8 @@ define backupninja::duplicity( $order = 90, # the client with configs for this machine include backupninja::client - case $host { false: { err("need to define a host for remote backups!") } } + case $desthost { false: { err("need to define a destination host for remote backups!") } } + case $destdir { false: { err("need to define a destination directory for remote backups!") } } # guarantees there's a configured backup space for this backup backupninja::server::sandbox { "${user}-${name}": -- cgit v1.2.3 From e8b238bf014cefd1f4077b9d96113cf0463ab3b4 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Thu, 27 Aug 2009 17:13:11 -0400 Subject: set a requirement that the rdiff-backup directory variable must be set --- manifests/rdiff.pp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'manifests') diff --git a/manifests/rdiff.pp b/manifests/rdiff.pp index e3964d0..1207cb1 100644 --- a/manifests/rdiff.pp +++ b/manifests/rdiff.pp @@ -28,6 +28,9 @@ define backupninja::rdiff( $backuptag = false) { include backupninja::client + + case $directory { false: { err("need to define a directory for where the backups should go!") } } + case $type { 'remote': { case $host { false: { err("need to define a host for remote backups!") } } -- cgit v1.2.3 From 4c1bf41b5a0b7969043dd480f903d403d16c6994 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Thu, 27 Aug 2009 17:19:20 -0400 Subject: the $password variable also must be set, so spit an error if it is not defined --- manifests/dup.pp | 1 + 1 file changed, 1 insertion(+) (limited to 'manifests') diff --git a/manifests/dup.pp b/manifests/dup.pp index f734e5d..ca996b8 100644 --- a/manifests/dup.pp +++ b/manifests/dup.pp @@ -90,6 +90,7 @@ define backupninja::duplicity( $order = 90, case $desthost { false: { err("need to define a destination host for remote backups!") } } case $destdir { false: { err("need to define a destination directory for remote backups!") } } + case $password { false: { err("a password is necessary either to unlock the GPG key, or for symmetric encryption!") } } # guarantees there's a configured backup space for this backup backupninja::server::sandbox { "${user}-${name}": -- cgit v1.2.3 From 8c72b1b43a428ccebb2b629ed60f06ff71650c17 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Thu, 27 Aug 2009 17:49:26 -0400 Subject: add a note about the password variable needing to be enclosed in single quotes --- manifests/dup.pp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'manifests') diff --git a/manifests/dup.pp b/manifests/dup.pp index ca996b8..c4554ee 100644 --- a/manifests/dup.pp +++ b/manifests/dup.pp @@ -30,6 +30,10 @@ # # Some notes about this handler: # +# - When specifying a password, be sure to enclose it in single quotes, +# this is particularly important if you have any special characters, such +# as a $ which puppet will attempt to interpret resulting in a different +# password placed in the file than you expect! # - There's no support for a 'local' type in backupninja's duplicity # handler on version 0.9.6-4, which is the version available in stable and # testing debian repositories by the time of this writing. -- cgit v1.2.3