aboutsummaryrefslogtreecommitdiff
path: root/manifests/client.pp
blob: c21e66920c64e317072a280640a4dc73d4d688d2 (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
123
124
125
126
127
128
129
130
class backupninja::client::defaults {
  $configdir = $cfg_override ? {
    '' => "/etc/backup.d",
    default => $cfg_override,
  }
  $real_keystore = $backupkeystore ? {
    '' => "$fileserver/keys/backupkeys",
    default => $backupkeystore,
  }
  $real_keytype = $backupkeytype ? {
    ''      => 'rsa',
    false   => '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
  }
}

class backupninja::client inherits backupninja::client::defaults {
  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::defaults::real_keymanage}",
	default => $installkey,
    }
    $key_owner = $keyowner ? {
    	false => "${backupninja::client::defaults::real_keyowner}",
	default => $keyowner,
    }
    $key_group = $keygroup ? {
    	false => "${backupninja::client::defaults::real_keygroup}",
	default => $keygroup,
    }
    $key_store = $keystore ? {
    	false => "${backupninja::client::defaults::real_keystore}",
	default => $keystore,
    }
    $key_type = $keytype ? {
    	''    => "${backupninja::client::defaults::real_keytype}",
    	false => "${backupninja::client::defaults::real_keytype}",
	default => $keytype,
    }

    $key_dest      = "${backupninja::client::defaults::real_keydestination}"
    $key_dest_file = "$key_dest/id_$key_type"

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

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

  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::defaults {

  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::defaults {

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