aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2009-07-16 18:23:05 -0300
committerMicah Anderson <micah@riseup.net>2009-08-27 15:53:27 -0400
commit0d6a2ec42949af1c08c673fe2dc1cad7973d7649 (patch)
treeebb0c9c7b19fbb951a45b78ca5fe4e4292480b38
parentd890916504b8fe282392f0a1cddc58f12a0e983b (diff)
downloadpuppet-backupninja-0d6a2ec42949af1c08c673fe2dc1cad7973d7649.tar.gz
puppet-backupninja-0d6a2ec42949af1c08c673fe2dc1cad7973d7649.tar.bz2
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.
-rw-r--r--manifests/server.pp84
1 files changed, 47 insertions, 37 deletions
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"
+ }
}
}
}