client.pp 3.39 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
79
80
    $key_dest      = "${backupninja::client::defaults::real_keydestination}"
    $key_dest_file = "$key_dest/id_$key_type"

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

101
class backupninja::client::maildir inherits backupninja::client::defaults {
102

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

111
class backupninja::client::rdiff_backup inherits backupninja::client::defaults {
112
113

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

121
class backupninja::client::duplicity inherits backupninja::client::defaults {
122
123
124
125
126
127
128
129
130

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