aboutsummaryrefslogtreecommitdiff
path: root/manifests/client.pp
blob: c3d186d84572ed15ba3e67bee62473635e72fee9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
class backupninja::client {
  $configdir = $cfg_override ? {
    '' => "/etc/backup.d",
    default => $cfg_override,
  }
  $real_keystore = $backupkeystore ? {
    '' => "$fileserver/keys/backupkeys",
    default => $backupkeystore,
  }
  $real_keytype = $backupkeytype ? {
    '' => 'rsa',
    default => $backupkeytype,
  }
  $real_keydestination = $keydestination ? {
    '' => '/root/.ssh',
    default => $keydestination,
  }
  $real_keyowner = $keyowner ? {
    '' => 0,
    default => $keyowner,
  }
  $real_keygroup = $keygroup ? {
    '' => 0,
    default => $keygroup,
  }
  $real_keymanage = $keymanage ? {
    '' => true,
    default => $keymanage
  }
  $real_ssh_dir_manage = $ssh_dir_manage ? {
    '' => true,
    default => $ssh_dir_manage
  }
  package { 'backupninja':
    ensure => '0.9.6-4';
  }
  file { $configdir:
    ensure => directory
  }
  define key(
    $user = false, $host = false, $installkey=false, $keyowner=false,
    $keygroup=false, $keystore=false, $keytype=false)
  {
    $real_user = $user ? {
      false => $name,
      default => $user
    }
    $real_host = $host ? {
      false => $user,
      default => $host
    }
    $install_key = $installkey ? {
    	false => "${backupninja::client::real_keymanage}",
	default => $installkey,
    }
    $key_owner = $keyowner ? {
    	false => "${backupninja::client::real_keyowner}",
	default => $keyowner,
    }
    $key_group = $keygroup ? {
    	false => "${backupninja::client::real_keygroup}",
	default => $keygroup,
    }
    $key_store = $keystore ? {
    	false => "${backupninja::client::real_keystore}",
	default => $keystore,
    }
    $key_type = $keytype ? {
    	false => "${backupninja::client::real_keytype}",
	default => $keytype,
    }

    case $install_key {
      true: {
        if !defined(File["${backupninja::client::real_keydestination}"]) {
          file { "${backupninja::client::real_keydestination}":
            ensure => directory,
            mode => 0700, owner => $key_owner, group => $key_group,
          }
        }
        if !defined(File["${backupninja::client::real_keydestination/id_${key_type}"]) {
          file { "${backupninja::client::real_keydestination}/id_${key_type}":
            source => "${key_store}/${real_user}_id_${key_type}",
            mode => 0400, owner => $key_owner, group => $key_group,
            require => File["${backupninja::client::real_keydestination}"],
          }
        }
      }
    }
  }
}

class backupninja::client::maildir inherits backupninja::client {

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

class backupninja::client::rdiff_backup inherits backupninja::client {

  if !defined(Package["rdiff-backup"]) {
    if $rdiff_backup_ensure_version == '' { $rdiff_backup_ensure_version = 'installed' }
    package { 'rdiff-backup':
      ensure => $rdiff_backup_ensure_version,
    }
  }
}

class backupninja::client::duplicity inherits backupninja::client {

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