aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2009-07-16 18:23:05 -0300
committerSilvio Rhatto <rhatto@riseup.net>2009-07-16 18:23:05 -0300
commitbc167339c62ad2e06c8cdcd298364f20afa04658 (patch)
tree70219a48704f436a4305f69009cee5370ee8feec
parent05efcc415ed19793e10d71e95a1d412e5d2095d1 (diff)
downloadpuppet-backupninja-bc167339c62ad2e06c8cdcd298364f20afa04658.tar.gz
puppet-backupninja-bc167339c62ad2e06c8cdcd298364f20afa04658.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"
+ }
}
}
}