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
|
class backupninja::server {
$backupdir = $backupdir_override ? {
'' => "/backup",
default => $backupdir_override,
}
group { "backupninjas":
ensure => "present",
gid => 700
}
file { "$backupdir":
ensure => "directory",
mode => 710, owner => root, group => "backupninjas"
}
User <<| tag == "backupninja-$fqdn" |>>
File <<| tag == "backupninja-$fqdn" |>>
# this define allows nodes to declare a remote backup sandbox, that have to
# get created on the server
define sandbox($host = false, $dir = false, $uid = false, $gid = "backupninjas") {
$real_host = $host ? {
false => $fqdn,
default => $host,
}
$real_dir = $dir ? {
false => "${backupninja::server::backupdir}/$fqdn",
default => $dir,
}
@@file { "$real_dir":
ensure => "directory",
mode => 750, owner => $name, group => 0,
tag => "backupninja-$real_host",
}
case $uid {
false: {
@@user { "$name":
ensure => "present",
gid => "$gid",
comment => "$name backup sandbox",
home => "$real_dir",
managehome => true,
shell => "/bin/sh",
password => '*',
require => Group['backupninjas'],
tag => "backupninja-$real_host"
}
}
default: {
@@user { "$name":
ensure => "present",
uid => "$uid",
gid => "$gid",
comment => "$name backup sandbox",
home => "$real_dir",
managehome => true,
shell => "/bin/sh",
password => '*',
require => Group['backupninjas'],
tag => "backupninja-$real_host"
}
}
}
}
}
|