Commit f68560e7 authored by varac's avatar varac

liniting main class, moving key() to seperate class

parent 49751354
# configure backupninja
class backupninja (
$ensure_backupninja_version = 'installed',
$ensure_rsync_version = 'installed',
......@@ -23,7 +24,6 @@ class backupninja (
$reportuser = undef,
$reportdirectory = undef,
$logfile = '/var/log/backupninja.log',
$configdir = '/etc/backup.d',
$scriptdir = '/usr/share/backupninja',
$libdir = '/usr/lib/backupninja',
$usecolors = true,
......@@ -37,55 +37,16 @@ class backupninja (
# set up backupninja config directory
file { $configdir:
ensure => directory,
mode => 750, owner => 0, group => 0;
}
define key(
$user = $name,
$createkey = false,
$keymanage = $backupninja::keymanage,
$keyowner = $backupninja::keyowner,
$keygroup = $backupninja::keygroup,
$keystore= $backupninja::keystore,
$keystorefspath = $backupninja::keystorefspath,
$keytype = $backupninja::keytype,
$keydest = $backupninja::keydest,
$keydestname = "id_${backupninja::keytype}" )
{
# generate the key
if $createkey == true {
if $keystorefspath == false {
err("need to define a destination directory for sshkey creation!")
}
$ssh_keys = ssh_keygen("${keystorefspath}/${keydestname}")
}
# deploy/manage the key
if $keymanage == true {
$keydestfile = "${keydest}/${keydestname}"
ensure_resource('file', $keydest, {
'ensure' => 'directory',
'mode' => '0700',
'owner' => $keyowner,
'group' => $keygroup
})
ensure_resource('file', $keydestfile, {
'ensure' => 'present',
'source' => "${keystore}/${user}_id_${keytype}",
'mode' => '0700',
'owner' => $keyowner,
'group' => $keygroup,
'require' => File["$keydest"],
})
}
mode => '0750',
owner => 0,
group => 0;
}
file { $configfile:
file { $configfile:
content => template('backupninja/backupninja.conf.erb'),
owner => root,
group => 0,
mode => '0644'
owner => root,
group => 0,
mode => '0644'
}
}
# generate and deploy backupninja sshkeys
define backupninja::key(
$user = $name,
$createkey = false,
$keymanage = $backupninja::keymanage,
$keyowner = $backupninja::keyowner,
$keygroup = $backupninja::keygroup,
$keystore= $backupninja::keystore,
$keystorefspath = $backupninja::keystorefspath,
$keytype = $backupninja::keytype,
$keydest = $backupninja::keydest,
$keydestname = "id_${backupninja::keytype}" )
{
# generate the key
if $createkey == true {
if $keystorefspath == false {
err('need to define a destination directory for sshkey creation!')
}
$ssh_keys = ssh_keygen("${keystorefspath}/${keydestname}")
}
# deploy/manage the key
if $keymanage == true {
$keydestfile = "${keydest}/${keydestname}"
ensure_resource('file', $keydest, {
'ensure' => 'directory',
'mode' => '0700',
'owner' => $keyowner,
'group' => $keygroup
})
ensure_resource('file', $keydestfile, {
'ensure' => 'present',
'source' => "${keystore}/${user}_id_${keytype}",
'mode' => '0700',
'owner' => $keyowner,
'group' => $keygroup,
'require' => File[$keydest],
})
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment