Commit 32c44017 authored by Jerome Charaoui's avatar Jerome Charaoui

move package declarations in base resources and wrap with ensure_resource

parent 058ebe28
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,
}
}
}
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::rsync 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::sys inherits backupninja::client::defaults {
case $operatingsystem {
debian,ubuntu: {
if !defined(Package["debconf-utils"]) {
if $debconf_utils_ensure_version == '' { $debconf_utils_ensure_version = 'installed' }
package { 'debconf-utils':
ensure => $debconf_utils_ensure_version,
}
}
if !defined(Package["hwinfo"]) {
if $hwinfo_ensure_version == '' { $hwinfo_ensure_version = 'installed' }
package { 'hwinfo':
ensure => $hwinfo_ensure_version,
}
}
}
default: {}
}
}
......@@ -39,6 +39,7 @@
# testing debian repositories by the time of this writing.
define backupninja::duplicity( $order = 90,
$ensure = present,
$ensure_duplicity_version = 'installed',
# options to the config file
$options = false,
$nicelevel = false,
......@@ -96,6 +97,9 @@ define backupninja::duplicity( $order = 90,
$createkey = false,
$installkey = true ) {
# install client dependencies
ensure_resource('package', 'duplicity', {'ensure' => $ensure_duplicity_version})
# the client with configs for this machine
include backupninja::client::duplicity
......
......@@ -17,13 +17,15 @@
#
#
define backupninja::maildir(
$order = 99, $ensure = present, $when = 'everyday at 21:00', $srcdir = false,
$order = 99, $ensure = present, $ensure_rsync_version = 'installed',
$when = 'everyday at 21:00', $srcdir = false,
$destdir = false, $desthost = false, $destuser = false, $destid_file = false,
$remove = false, $multiconnection = yes, $keepdaily='4', $keepweekly='2',
$keepmonthly='2')
{
include backupninja::client::maildir
# install client dependencies
ensure_resource('package', 'rsync', {'ensure' => $ensure_rsync_version})
case $srcdir { false: { err("need to define a source directory to backup!") } }
case $destdir { false: { err("need to define a destination directory to backup!") } }
case $desthost { false: { err("need to define a destination host for backups!") } }
......
......@@ -16,8 +16,8 @@
# directories.
#
define backupninja::rdiff(
$order = 90, $ensure = present, $user = false,
$home = "/home/${user}-${name}", $host = false,
$order = 90, $ensure = present, $ensure_rdiffbackup_version = 'installed',
$user = false, $home = "/home/${user}-${name}", $host = false,
$type = 'local',
$exclude = [ "/home/*/.gnupg", "/home/*/.local/share/Trash", "/home/*/.Trash",
"/home/*/.thumbnails", "/home/*/.beagle", "/home/*/.aMule",
......@@ -28,7 +28,8 @@ define backupninja::rdiff(
$ssh_dir = false, $authorized_keys_file = false, $installuser = true, $installkey = true, $key = false,
$backuptag = false, $backupkeytype = "rsa", $backupkeystore = false, $extras = false, $nagios2_description = 'backups')
{
include backupninja::client::rdiff_backup
# install client dependencies
ensure_resource('package', 'rdiff-backup', {'ensure' => $ensure_rdiffbackup_version})
$directory = "$home/rdiff-backup/"
......
......@@ -2,7 +2,8 @@
# Based on backupninja::rdiff
define backupninja::rsync(
$order = 90, $ensure = present, $user = false, $home = false, $host = false,
$order = 90, $ensure = present, $ensure_rsync_version = 'installed',
$user = false, $home = false, $host = false,
$ssh_dir_manage = true, $ssh_dir = false, $authorized_keys_file = false,
$installuser = true, $installkey = true, $key = false, $backuptag = false,
$home = false, $backupkeytype = "rsa", $backupkeystore = false, $extras = false,
......@@ -29,7 +30,8 @@ define backupninja::rsync(
$rm = false, $cp = false, $touch = false, $mv = false, $fsck = false)
{
include backupninja::client::rsync
# install client dependencies
ensure_resource('package', 'rsync', {'ensure' => $ensure_rsync_version})
# Right now just local origin with remote destination is supported.
$from = 'local'
......
......@@ -12,6 +12,8 @@
#
define backupninja::sys($order = 30,
$ensure = present,
$ensure_debconfutils_version = 'installed',
$ensure_hwinfo_version = 'installed',
$parentdir = '/var/backups',
$packages = true,
$packagesfile = '/var/backups/dpkg-selections.txt',
......@@ -25,6 +27,16 @@ define backupninja::sys($order = 30,
$dolvm = false
) {
include backupninja::client::defaults
# install client dependencies
case $operatingsystem {
debian,ubuntu: {
ensure_resource('package', 'debconf-utils', {'ensure' => $ensure_debconfutils_version})
ensure_resource('package', 'hwinfo', {'ensure' => $ensure_hwinfo_version})
}
default: {}
}
file { "${backupninja::client::defaults::configdir}/${order}_${name}.sys":
ensure => $ensure,
content => template('backupninja/sys.conf.erb'),
......
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