client.pp 3.5 KB
Newer Older
1
class backupninja::client::defaults {
2 3 4 5
  $configdir = $cfg_override ? {
    '' => "/etc/backup.d",
    default => $cfg_override,
  }
6
  $real_keystore = $backupkeystore ? {
Riseup's avatar
Riseup committed
7
    '' => "$fileserver/keys/backupkeys",
8 9 10
    default => $backupkeystore,
  }
  $real_keytype = $backupkeytype ? {
11 12
    ''      => 'rsa',
    false   => 'rsa',
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
    default => $backupkeytype,
  }
  $real_keydestination = $keydestination ? {
    '' => '/root/.ssh',
    default => $keydestination,
  }
  $real_keyowner = $keyowner ? {
    '' => 0,
    default => $keyowner,
  }
  $real_keygroup = $keygroup ? {
    '' => 0,
    default => $keygroup,
  }
  $real_keymanage = $keymanage ? {
28
    '' => true,
29 30
    default => $keymanage
  }
31 32 33 34
  $real_ssh_dir_manage = $ssh_dir_manage ? {
    '' => true,
    default => $ssh_dir_manage
  }
35
  package { 'backupninja':
36
    ensure => '0.9.6-4';
37 38 39 40
  }
  file { $configdir:
    ensure => directory
  }
41 42 43
}

class backupninja::client inherits backupninja::client::defaults {
Micah Anderson's avatar
Micah Anderson committed
44 45 46
  define key(
    $user = false, $host = false, $installkey=false, $keyowner=false,
    $keygroup=false, $keystore=false, $keytype=false)
47
  {
48 49 50 51 52 53 54 55
    $real_user = $user ? {
      false => $name,
      default => $user
    }
    $real_host = $host ? {
      false => $user,
      default => $host
    }
56
    $install_key = $installkey ? {
57
    	false => "${backupninja::client::defaults::real_keymanage}",
58
	default => $installkey,
Riseup's avatar
Riseup committed
59 60
    }
    $key_owner = $keyowner ? {
61
    	false => "${backupninja::client::defaults::real_keyowner}",
Riseup's avatar
Riseup committed
62 63 64
	default => $keyowner,
    }
    $key_group = $keygroup ? {
65
    	false => "${backupninja::client::defaults::real_keygroup}",
Riseup's avatar
Riseup committed
66 67 68
	default => $keygroup,
    }
    $key_store = $keystore ? {
69
    	false => "${backupninja::client::defaults::real_keystore}",
Riseup's avatar
Riseup committed
70 71 72
	default => $keystore,
    }
    $key_type = $keytype ? {
73 74
    	''    => "${backupninja::client::defaults::real_keytype}",
    	false => "${backupninja::client::defaults::real_keytype}",
Riseup's avatar
Riseup committed
75 76 77
	default => $keytype,
    }

78
    case $install_key {
79
      true: {
80 81
        if !defined(File["${backupninja::client::defaults::real_keydestination}"]) {
          file { "${backupninja::client::defaults::real_keydestination}":
82 83 84
            ensure => directory,
            mode => 0700, owner => $key_owner, group => $key_group,
          }
85
        }
86 87
        if !defined(File["${backupninja::client::defaults::real_keydestination/id_${key_type}"]) {
          file { "${backupninja::client::defaults::real_keydestination}/id_${key_type}":
88 89
            source => "${key_store}/${real_user}_id_${key_type}",
            mode => 0400, owner => $key_owner, group => $key_group,
90
            require => File["${backupninja::client::defaults::real_keydestination}"],
91
          }
92 93 94 95
        }
      }
    }
  }
96
}
97

98
class backupninja::client::maildir inherits backupninja::client::defaults {
99

100 101 102 103 104 105 106 107
  if !defined(Package["rsync"]) {
    if $rsync_ensure_version == '' { $rsync_ensure_version = 'installed' }
    package { 'rsync':
      ensure => $rsync_ensure_version,
    }
  } 
}

108
class backupninja::client::rdiff_backup inherits backupninja::client::defaults {
109 110

  if !defined(Package["rdiff-backup"]) {
111
    if $rdiff_backup_ensure_version == '' { $rdiff_backup_ensure_version = 'installed' }
112
    package { 'rdiff-backup':
113
      ensure => $rdiff_backup_ensure_version,
114 115 116
    }
  }
}
117

118
class backupninja::client::duplicity inherits backupninja::client::defaults {
119 120 121 122 123 124 125 126 127

  if !defined(Package["duplicity"]) {
    if $duplicity_ensure_version == '' { $duplicity_ensure_version = 'installed' }
    package { 'duplicity':
      ensure => $duplicity_ensure_version,
    }
  }
}