From 058ebe28086cd53f6fe86b794d6b658c95124ed7 Mon Sep 17 00:00:00 2001 From: Jerome Charaoui Date: Thu, 19 Mar 2015 17:05:32 -0400 Subject: fix autoload, first attempt --- manifests/client.pp | 106 ----------------------------- manifests/client/defaults.pp | 45 ++++++++++++ manifests/client/duplicity.pp | 9 +++ manifests/client/maildir.pp | 9 +++ manifests/client/rdiff_backup.pp | 9 +++ manifests/client/rsync.pp | 9 +++ manifests/client/sys.pp | 19 ++++++ manifests/config.pp | 18 ----- manifests/cron.pp | 17 +++++ manifests/dup.pp | 143 --------------------------------------- manifests/duplicity.pp | 143 +++++++++++++++++++++++++++++++++++++++ manifests/init.pp | 17 ----- 12 files changed, 260 insertions(+), 284 deletions(-) create mode 100644 manifests/client/defaults.pp create mode 100644 manifests/client/duplicity.pp create mode 100644 manifests/client/maildir.pp create mode 100644 manifests/client/rdiff_backup.pp create mode 100644 manifests/client/rsync.pp create mode 100644 manifests/client/sys.pp create mode 100644 manifests/cron.pp delete mode 100644 manifests/dup.pp create mode 100644 manifests/duplicity.pp delete mode 100644 manifests/init.pp diff --git a/manifests/client.pp b/manifests/client.pp index c41f6e7..f0531a0 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -1,49 +1,3 @@ -class backupninja::client::defaults { - $configdir = $cfg_override ? { - '' => "/etc/backup.d", - default => $cfg_override, - } - $real_keystore = $backupkeystore ? { - '' => "$fileserver/keys/backupkeys", - default => $backupkeystore, - } - $real_keytype = $backupkeytype ? { - '' => 'rsa', - false => '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 ? { - '' => true, - default => $keymanage - } - $real_ssh_dir_manage = $ssh_dir_manage ? { - '' => true, - default => $ssh_dir_manage - } - if !defined(Package["backupninja"]) { - if $backupninja_ensure_version == '' { $backupninja_ensure_version = 'installed' } - package { 'backupninja': - ensure => $backupninja_ensure_version - } - } - file { $configdir: - ensure => directory, - mode => 750, owner => 0, group => 0; - } -} - class backupninja::client inherits backupninja::client::defaults { define key( $user = false, $host = false, $createkey=false, $installkey=false, @@ -117,63 +71,3 @@ class backupninja::client inherits backupninja::client::defaults { } } } - -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::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::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: {} - } -} - -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, - } - } -} diff --git a/manifests/client/defaults.pp b/manifests/client/defaults.pp new file mode 100644 index 0000000..9dc8747 --- /dev/null +++ b/manifests/client/defaults.pp @@ -0,0 +1,45 @@ +class backupninja::client::defaults { + $configdir = $cfg_override ? { + '' => "/etc/backup.d", + default => $cfg_override, + } + $real_keystore = $backupkeystore ? { + '' => "$fileserver/keys/backupkeys", + default => $backupkeystore, + } + $real_keytype = $backupkeytype ? { + '' => 'rsa', + false => '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 ? { + '' => true, + default => $keymanage + } + $real_ssh_dir_manage = $ssh_dir_manage ? { + '' => true, + default => $ssh_dir_manage + } + if !defined(Package["backupninja"]) { + if $backupninja_ensure_version == '' { $backupninja_ensure_version = 'installed' } + package { 'backupninja': + ensure => $backupninja_ensure_version + } + } + file { $configdir: + ensure => directory, + mode => 750, owner => 0, group => 0; + } +} diff --git a/manifests/client/duplicity.pp b/manifests/client/duplicity.pp new file mode 100644 index 0000000..938ff3f --- /dev/null +++ b/manifests/client/duplicity.pp @@ -0,0 +1,9 @@ +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, + } + } +} diff --git a/manifests/client/maildir.pp b/manifests/client/maildir.pp new file mode 100644 index 0000000..65f8aee --- /dev/null +++ b/manifests/client/maildir.pp @@ -0,0 +1,9 @@ +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, + } + } +} diff --git a/manifests/client/rdiff_backup.pp b/manifests/client/rdiff_backup.pp new file mode 100644 index 0000000..9b098bf --- /dev/null +++ b/manifests/client/rdiff_backup.pp @@ -0,0 +1,9 @@ +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, + } + } +} diff --git a/manifests/client/rsync.pp b/manifests/client/rsync.pp new file mode 100644 index 0000000..ec92b56 --- /dev/null +++ b/manifests/client/rsync.pp @@ -0,0 +1,9 @@ +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, + } + } +} diff --git a/manifests/client/sys.pp b/manifests/client/sys.pp new file mode 100644 index 0000000..c038060 --- /dev/null +++ b/manifests/client/sys.pp @@ -0,0 +1,19 @@ +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: {} + } +} diff --git a/manifests/config.pp b/manifests/config.pp index 89105b3..34e3a0e 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -18,21 +18,3 @@ define backupninja::config( mode => 0644 } } - -# Write the backupninja cron job, allowing you to specify an alternate backupninja -# command (if you want to wrap it in any other commands, e.g. to allow it to use -# the monkeysphere for authentication), or a different schedule to run it on. -define backupninja::cron( - $backupninja_cmd = '/usr/sbin/backupninja', - $backupninja_test_cmd = $backupninja_cmd, - $cronfile = "/etc/cron.d/backupninja", - $min = "0", $hour = "*", $dom = "*", $month = "*", - $dow = "*") -{ - file { $cronfile: - content => template('backupninja/backupninja.cron.erb'), - owner => root, - group => root, - mode => 0644 - } -} diff --git a/manifests/cron.pp b/manifests/cron.pp new file mode 100644 index 0000000..bd4e857 --- /dev/null +++ b/manifests/cron.pp @@ -0,0 +1,17 @@ +# Write the backupninja cron job, allowing you to specify an alternate backupninja +# command (if you want to wrap it in any other commands, e.g. to allow it to use +# the monkeysphere for authentication), or a different schedule to run it on. +define backupninja::cron( + $backupninja_cmd = '/usr/sbin/backupninja', + $backupninja_test_cmd = $backupninja_cmd, + $cronfile = "/etc/cron.d/backupninja", + $min = "0", $hour = "*", $dom = "*", $month = "*", + $dow = "*") +{ + file { $cronfile: + content => template('backupninja/backupninja.cron.erb'), + owner => root, + group => root, + mode => 0644 + } +} diff --git a/manifests/dup.pp b/manifests/dup.pp deleted file mode 100644 index 99b64f8..0000000 --- a/manifests/dup.pp +++ /dev/null @@ -1,143 +0,0 @@ -# Run duplicity-backup as part of a backupninja run. -# -# Valid attributes for this type are: -# -# order: -# -# The prefix to give to the handler config filename, to set order in -# which the actions are executed during the backup run. -# -# ensure: -# -# Allows you to delete an entry if you don't want it any more (but be -# sure to keep the configdir, name, and order the same, so that we can -# find the correct file to remove). -# -# options, nicelevel, testconnect, tmpdir, sign, encryptkey, signkey, -# password, include, exclude, vsinclude, incremental, keep, bandwidthlimit, -# sshoptions, destdir, desthost, desuser: -# -# As defined in the backupninja documentation. The options will be -# placed in the correct sections automatically. The include and -# exclude options should be given as arrays if you want to specify -# multiple directories. -# -# directory, ssh_dir_manage, ssh_dir, authorized_keys_file, installuser, -# installkey, backuptag: -# -# Options for the bakupninja::server::sandbox define, check that -# definition for more info. -# -# Some notes about this handler: -# -# - When specifying a password, be sure to enclose it in single quotes, -# this is particularly important if you have any special characters, such -# as a $ which puppet will attempt to interpret resulting in a different -# password placed in the file than you expect! -# - There's no support for a 'local' type in backupninja's duplicity -# handler on version 0.9.6-4, which is the version available in stable and -# testing debian repositories by the time of this writing. -define backupninja::duplicity( $order = 90, - $ensure = present, - # options to the config file - $options = false, - $nicelevel = false, - $testconnect = false, - $tmpdir = false, - # [gpg] - $sign = false, - $encryptkey = false, - $signkey = false, - $password = false, - # [source] - $include = [ "/var/spool/cron/crontabs", - "/var/backups", - "/etc", - "/root", - "/home", - "/usr/local/*bin", - "/var/lib/dpkg/status*" ], - $exclude = [ "/home/*/.gnupg", - "/home/*/.local/share/Trash", - "/home/*/.Trash", - "/home/*/.thumbnails", - "/home/*/.beagle", - "/home/*/.aMule", - "/home/*/.gnupg", - "/home/*/.gpg", - "/home/*/.ssh", - "/home/*/gtk-gnutella-downloads", - "/etc/ssh/*" ], - $vsinclude = false, - # [dest] - $incremental = "yes", - $increments = false, - $keep = false, - $keepincroffulls = false, - $bandwidthlimit = false, - $sshoptions = false, - $destdir = false, - $desthost = false, - $destuser = false, - $desturl = false, - # configs to backupninja client - $backupkeystore = false, - $backupkeystorefspath = '', - $backupkeytype = "rsa", - $backupkeydest = false, - $backupkeydestname = false, - # options to backupninja server sandbox - $ssh_dir_manage = true, - $ssh_dir = false, - $authorized_keys_file = false, - $installuser = true, - $backuptag = false, - # key options - $createkey = false, - $installkey = true ) { - - # the client with configs for this machine - include backupninja::client::duplicity - - 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!") } } - case $password { false: { err("a password is necessary either to unlock the GPG key, or for symmetric encryption!") } } - - # guarantees there's a configured backup space for this backup - backupninja::server::sandbox { "${user}-${name}": - user => $destuser, - host => $desthost, - dir => $destdir, - manage_ssh_dir => $ssh_dir_manage, - ssh_dir => $ssh_dir, - authorized_keys_file => $authorized_keys_file, - installuser => $installuser, - backuptag => $backuptag, - backupkeys => $backupkeystore, - keytype => $backupkeytype, - } - - # the client's ssh key - backupninja::client::key { "${destuser}-${name}": - user => $destuser, - host => $desthost, - createkey => $createkey, - installkey => $installkey, - keytype => $backupkeytype, - keystore => $backupkeystore, - keystorefspath => $backupkeystorefspath, - keydest => $backupkeydest, - keydestname => $backupkeydestname - } - - # the backupninja rule for this duplicity backup - 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::defaults::configdir}"] - } -} - diff --git a/manifests/duplicity.pp b/manifests/duplicity.pp new file mode 100644 index 0000000..99b64f8 --- /dev/null +++ b/manifests/duplicity.pp @@ -0,0 +1,143 @@ +# Run duplicity-backup as part of a backupninja run. +# +# Valid attributes for this type are: +# +# order: +# +# The prefix to give to the handler config filename, to set order in +# which the actions are executed during the backup run. +# +# ensure: +# +# Allows you to delete an entry if you don't want it any more (but be +# sure to keep the configdir, name, and order the same, so that we can +# find the correct file to remove). +# +# options, nicelevel, testconnect, tmpdir, sign, encryptkey, signkey, +# password, include, exclude, vsinclude, incremental, keep, bandwidthlimit, +# sshoptions, destdir, desthost, desuser: +# +# As defined in the backupninja documentation. The options will be +# placed in the correct sections automatically. The include and +# exclude options should be given as arrays if you want to specify +# multiple directories. +# +# directory, ssh_dir_manage, ssh_dir, authorized_keys_file, installuser, +# installkey, backuptag: +# +# Options for the bakupninja::server::sandbox define, check that +# definition for more info. +# +# Some notes about this handler: +# +# - When specifying a password, be sure to enclose it in single quotes, +# this is particularly important if you have any special characters, such +# as a $ which puppet will attempt to interpret resulting in a different +# password placed in the file than you expect! +# - There's no support for a 'local' type in backupninja's duplicity +# handler on version 0.9.6-4, which is the version available in stable and +# testing debian repositories by the time of this writing. +define backupninja::duplicity( $order = 90, + $ensure = present, + # options to the config file + $options = false, + $nicelevel = false, + $testconnect = false, + $tmpdir = false, + # [gpg] + $sign = false, + $encryptkey = false, + $signkey = false, + $password = false, + # [source] + $include = [ "/var/spool/cron/crontabs", + "/var/backups", + "/etc", + "/root", + "/home", + "/usr/local/*bin", + "/var/lib/dpkg/status*" ], + $exclude = [ "/home/*/.gnupg", + "/home/*/.local/share/Trash", + "/home/*/.Trash", + "/home/*/.thumbnails", + "/home/*/.beagle", + "/home/*/.aMule", + "/home/*/.gnupg", + "/home/*/.gpg", + "/home/*/.ssh", + "/home/*/gtk-gnutella-downloads", + "/etc/ssh/*" ], + $vsinclude = false, + # [dest] + $incremental = "yes", + $increments = false, + $keep = false, + $keepincroffulls = false, + $bandwidthlimit = false, + $sshoptions = false, + $destdir = false, + $desthost = false, + $destuser = false, + $desturl = false, + # configs to backupninja client + $backupkeystore = false, + $backupkeystorefspath = '', + $backupkeytype = "rsa", + $backupkeydest = false, + $backupkeydestname = false, + # options to backupninja server sandbox + $ssh_dir_manage = true, + $ssh_dir = false, + $authorized_keys_file = false, + $installuser = true, + $backuptag = false, + # key options + $createkey = false, + $installkey = true ) { + + # the client with configs for this machine + include backupninja::client::duplicity + + 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!") } } + case $password { false: { err("a password is necessary either to unlock the GPG key, or for symmetric encryption!") } } + + # guarantees there's a configured backup space for this backup + backupninja::server::sandbox { "${user}-${name}": + user => $destuser, + host => $desthost, + dir => $destdir, + manage_ssh_dir => $ssh_dir_manage, + ssh_dir => $ssh_dir, + authorized_keys_file => $authorized_keys_file, + installuser => $installuser, + backuptag => $backuptag, + backupkeys => $backupkeystore, + keytype => $backupkeytype, + } + + # the client's ssh key + backupninja::client::key { "${destuser}-${name}": + user => $destuser, + host => $desthost, + createkey => $createkey, + installkey => $installkey, + keytype => $backupkeytype, + keystore => $backupkeystore, + keystorefspath => $backupkeystorefspath, + keydest => $backupkeydest, + keydestname => $backupkeydestname + } + + # the backupninja rule for this duplicity backup + 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::defaults::configdir}"] + } +} + diff --git a/manifests/init.pp b/manifests/init.pp deleted file mode 100644 index fba8cc4..0000000 --- a/manifests/init.pp +++ /dev/null @@ -1,17 +0,0 @@ -import "client.pp" -import "config.pp" -import "dup.pp" -import "labelmount.pp" -import "maildir.pp" -import "mysql.pp" -import "pgsql.pp" -import "rdiff.pp" -import "server.pp" -import "sh.pp" -import "svn.pp" -import "sys.pp" - -class backupninja { - -} - -- cgit v1.2.3