Commit b432d94f authored by Silvio Rhatto's avatar Silvio Rhatto

New backupninja::client::defaults to avoid duplicates.

Adding part of client.pp code into new class
backupninja::client::defaults in an attempt to avoid duplicate
definitions inside backupninja::client::key.
parent f96267fe
class backupninja::client {
class backupninja::client::defaults {
$configdir = $cfg_override ? {
'' => "/etc/backup.d",
default => $cfg_override,
......@@ -38,6 +38,9 @@ class backupninja::client {
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)
......@@ -51,40 +54,40 @@ class backupninja::client {
default => $host
}
$install_key = $installkey ? {
false => "${backupninja::client::real_keymanage}",
false => "${backupninja::client::defaults::real_keymanage}",
default => $installkey,
}
$key_owner = $keyowner ? {
false => "${backupninja::client::real_keyowner}",
false => "${backupninja::client::defaults::real_keyowner}",
default => $keyowner,
}
$key_group = $keygroup ? {
false => "${backupninja::client::real_keygroup}",
false => "${backupninja::client::defaults::real_keygroup}",
default => $keygroup,
}
$key_store = $keystore ? {
false => "${backupninja::client::real_keystore}",
false => "${backupninja::client::defaults::real_keystore}",
default => $keystore,
}
$key_type = $keytype ? {
'' => "${backupninja::client::real_keytype}",
false => "${backupninja::client::real_keytype}",
'' => "${backupninja::client::defaults::real_keytype}",
false => "${backupninja::client::defaults::real_keytype}",
default => $keytype,
}
case $install_key {
true: {
if !defined(File["${backupninja::client::real_keydestination}"]) {
file { "${backupninja::client::real_keydestination}":
if !defined(File["${backupninja::client::defaults::real_keydestination}"]) {
file { "${backupninja::client::defaults::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}":
if !defined(File["${backupninja::client::defaults::real_keydestination/id_${key_type}"]) {
file { "${backupninja::client::defaults::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}"],
require => File["${backupninja::client::defaults::real_keydestination}"],
}
}
}
......@@ -92,7 +95,7 @@ class backupninja::client {
}
}
class backupninja::client::maildir inherits backupninja::client {
class backupninja::client::maildir inherits backupninja::client::defaults {
if !defined(Package["rsync"]) {
if $rsync_ensure_version == '' { $rsync_ensure_version = 'installed' }
......@@ -102,7 +105,7 @@ class backupninja::client::maildir inherits backupninja::client {
}
}
class backupninja::client::rdiff_backup inherits backupninja::client {
class backupninja::client::rdiff_backup inherits backupninja::client::defaults {
if !defined(Package["rdiff-backup"]) {
if $rdiff_backup_ensure_version == '' { $rdiff_backup_ensure_version = 'installed' }
......@@ -112,7 +115,7 @@ class backupninja::client::rdiff_backup inherits backupninja::client {
}
}
class backupninja::client::duplicity inherits backupninja::client {
class backupninja::client::duplicity inherits backupninja::client::defaults {
if !defined(Package["duplicity"]) {
if $duplicity_ensure_version == '' { $duplicity_ensure_version = 'installed' }
......
......@@ -90,7 +90,7 @@ define backupninja::duplicity( $order = 90,
$installkey = true ) {
# the client with configs for this machine
include backupninja::client
include backupninja::client::defaults
case $desthost { false: { err("need to define a destination host for remote backups!") } }
case $destdir { false: { err("need to define a destination directory for remote backups!") } }
......@@ -119,13 +119,13 @@ define backupninja::duplicity( $order = 90,
}
# the backupninja rule for this duplicity backup
file { "${backupninja::client::configdir}/${order}_${name}.dup":
file { "${backupninja::client::defaults::configdir}/${order}_${name}.dup":
ensure => $ensure,
content => template('backupninja/dup.conf.erb'),
owner => root,
group => root,
mode => 0600,
require => File["${backupninja::client::configdir}"]
require => File["${backupninja::client::defaults::configdir}"]
}
}
......@@ -23,23 +23,23 @@ define backupninja::labelmount($order = 10,
$label,
$dest
) {
include backupninja::client
file { "${backupninja::client::configdir}/${order}_${name}.labelmount":
include backupninja::client::defaults
file { "${backupninja::client::defaults::configdir}/${order}_${name}.labelmount":
ensure => $ensure,
content => template('backupninja/labelmount.conf.erb'),
owner => root,
group => root,
mode => 0600,
require => File["${backupninja::client::configdir}"]
require => File["${backupninja::client::defaults::configdir}"]
}
file { "${backupninja::client::configdir}/99_${name}.umount":
file { "${backupninja::client::defaults::configdir}/99_${name}.umount":
ensure => $ensure,
content => template('backupninja/umount.conf.erb'),
owner => root,
group => root,
mode => 0600,
require => File["${backupninja::client::configdir}"]
require => File["${backupninja::client::defaults::configdir}"]
}
# Copy over the handler scripts themselves, since they're not in the
......
......@@ -22,7 +22,7 @@ define backupninja::maildir(
$remove = false, $multiconnection = yes, $keepdaily='4', $keepweekly='2',
$keepmonthly='2')
{
include backupninja::client
include backupninja::client::defaults
case $srcdir { false: { err("need to define a source directory to backup!") } }
case $destdir { false: { err("need to define a destination directory to backup!") } }
......@@ -30,12 +30,12 @@ define backupninja::maildir(
case $destuser { false: { err("need to define a destination user for backups!") } }
case $destid_file { false: { err("need to define a ssh key id file to use!") } }
file { "${backupninja::client::configdir}/${order}_${name}.maildir":
file { "${backupninja::client::defaults::configdir}/${order}_${name}.maildir":
ensure => $ensure,
content => template('backupninja/maildir.conf.erb'),
owner => root,
group => root,
mode => 0600,
require => File["${backupninja::client::configdir}"]
require => File["${backupninja::client::defaults::configdir}"]
}
}
......@@ -20,13 +20,13 @@ define backupninja::mysql(
$sqldump = false, $compress = false, $configfile = '/etc/mysql/debian.cnf',
$vsname = false)
{
include backupninja::client
file { "${backupninja::client::configdir}/${order}_${name}.mysql":
include backupninja::client::defaults
file { "${backupninja::client::defaults::configdir}/${order}_${name}.mysql":
ensure => $ensure,
content => template('backupninja/mysql.conf.erb'),
owner => root,
group => root,
mode => 0600,
require => File["${backupninja::client::configdir}"]
require => File["${backupninja::client::defaults::configdir}"]
}
}
......@@ -27,7 +27,7 @@ define backupninja::rdiff(
$ssh_dir = false, $authorized_keys_file = false, $installuser = true, $installkey = true,
$backuptag = false, $home = false, $backupkeytype = "rsa")
{
include backupninja::client
include backupninja::client::defaults
case $directory { false: { err("need to define a directory for where the backups should go!") } }
......@@ -55,13 +55,13 @@ define backupninja::rdiff(
}
}
}
file { "${backupninja::client::configdir}/${order}_${name}.rdiff":
file { "${backupninja::client::defaults::configdir}/${order}_${name}.rdiff":
ensure => $ensure,
content => template('backupninja/rdiff.conf.erb'),
owner => root,
group => root,
mode => 0600,
require => File["${backupninja::client::configdir}"]
require => File["${backupninja::client::defaults::configdir}"]
}
}
......@@ -14,13 +14,13 @@ define backupninja::sh($order = 50,
$ensure = present,
$command_string
) {
include backupninja::client
file { "${backupninja::client::configdir}/${order}_${name}.sh":
include backupninja::client::defaults
file { "${backupninja::client::defaults::configdir}/${order}_${name}.sh":
ensure => $ensure,
content => template('backupninja/sh.conf.erb'),
owner => root,
group => root,
mode => 0600,
require => File["${backupninja::client::configdir}"]
require => File["${backupninja::client::defaults::configdir}"]
}
}
......@@ -17,13 +17,13 @@ define backupninja::svn($order = 20,
$tmp = '/var/backups/svn.tmp',
$vsname = false
) {
include backupninja::client
file { "${backupninja::client::configdir}/${order}_${name}.svn":
include backupninja::client::defaults
file { "${backupninja::client::defaults::configdir}/${order}_${name}.svn":
ensure => $ensure,
content => template('backupninja/svn.conf.erb'),
owner => root,
group => root,
mode => 0600,
require => File["${backupninja::client::configdir}"]
require => File["${backupninja::client::defaults::configdir}"]
}
}
......@@ -22,13 +22,13 @@ define backupninja::sys($order = 30,
$hardwarefile = '/var/backups/hardware.txt',
$dohwinfo = yes
) {
include backupninja::client
file { "${backupninja::client::configdir}/${order}_${name}.sys":
include backupninja::client::defaults
file { "${backupninja::client::defaults::configdir}/${order}_${name}.sys":
ensure => $ensure,
content => template('backupninja/sys.conf.erb'),
owner => root,
group => root,
mode => 0600,
require => File["${backupninja::client::configdir}"]
require => File["${backupninja::client::defaults::configdir}"]
}
}
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