aboutsummaryrefslogtreecommitdiff
path: root/manifests/client.pp
blob: daa2e16dcf5af52b1ccf71550fcdf44128fff649 (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
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 ? {
    '' => 'doit',
    default => $keymanage
  }
  err("$real_keystore $real_keytype $real_keydestination $real_keyowner $real_keygroup $real_keymanage")
  package { 'backupninja':
    ensure => '0.9.5-3';
  }
  file { $configdir:
    ensure => directory
  }
  define key ( $host=$user, $installkeys=false, $keyowner=false, $keygroup=false, $keystore=false, $keytype=false )
  {
    $install_keys = $installkeys ? {
    	false => "${backupninja::client::real_keymanage}",
	default => $installkeys,
    }
    $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_keys {
      'doit': {
        file { "${backupninja::client::real_keydestination}":
          ensure => directory,
          mode => 700, owner => $key_owner, group => $key_group,
        }
        file { "${backupninja::client::real_keydestination}/id_${key_type}":
          source => "${key_store}/${host}_id_${key_type}",
          mode => 0400, owner => $key_owner, group => $key_group,
          require => File["${backupninja::client::real_keydestination}"],
        }
      }
    }
  }
}