aboutsummaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
authorMicah Anderson <micah@riseup.net>2009-12-07 16:17:04 -0500
committerMicah Anderson <micah@riseup.net>2009-12-07 16:17:04 -0500
commitbd68fde7adaf7dbe82dd7842dbfd9734d3e5c688 (patch)
treea6539457bfb248d86e060a591e6750a2590c2a80 /manifests
parentad99d7611f716eada0620417f7d62c095ef38fd1 (diff)
parentb380f1de1fe62d34f0788fedfb53c1354b0a31a3 (diff)
downloadpuppet-backupninja-bd68fde7adaf7dbe82dd7842dbfd9734d3e5c688.tar.gz
puppet-backupninja-bd68fde7adaf7dbe82dd7842dbfd9734d3e5c688.tar.bz2
Merge remote branch 'anarcat/master'
Diffstat (limited to 'manifests')
-rw-r--r--manifests/maildir.pp2
-rw-r--r--manifests/mysql.pp8
-rw-r--r--manifests/rdiff.pp27
-rw-r--r--manifests/server.pp71
4 files changed, 76 insertions, 32 deletions
diff --git a/manifests/maildir.pp b/manifests/maildir.pp
index d871654..ab7ff55 100644
--- a/manifests/maildir.pp
+++ b/manifests/maildir.pp
@@ -22,7 +22,7 @@ define backupninja::maildir(
$remove = false, $multiconnection = yes, $keepdaily='4', $keepweekly='2',
$keepmonthly='2')
{
- include backupninja::client::defaults
+ include backupninja::client::maildir
case $srcdir { false: { err("need to define a source directory to backup!") } }
case $destdir { false: { err("need to define a destination directory to backup!") } }
diff --git a/manifests/mysql.pp b/manifests/mysql.pp
index e6cfe90..83d8f8f 100644
--- a/manifests/mysql.pp
+++ b/manifests/mysql.pp
@@ -17,9 +17,15 @@
define backupninja::mysql(
$order = 10, $ensure = present, $user = false, $dbusername = false, $dbpassword = false,
$dbhost = 'localhost', $databases = 'all', $backupdir = false, $hotcopy = false,
- $sqldump = false, $compress = false, $configfile = '/etc/mysql/debian.cnf',
+ $sqldump = false, $compress = false, $configfile = true,
$vsname = false)
{
+
+ $real_configfile = $configfile ? {
+ true => "/etc/mysql/debian.cnf",
+ default => $configfile,
+ }
+
include backupninja::client::defaults
file { "${backupninja::client::defaults::configdir}/${order}_${name}.mysql":
ensure => $ensure,
diff --git a/manifests/rdiff.pp b/manifests/rdiff.pp
index b32a262..2624ecd 100644
--- a/manifests/rdiff.pp
+++ b/manifests/rdiff.pp
@@ -16,36 +16,39 @@
# directories.
#
define backupninja::rdiff(
- $order = 90, $ensure = present, $user = false, $directory = false, $host = false,
+ $order = 90, $ensure = present, $user = false, $home = false, $host = false,
$type = 'local',
$exclude = [ "/home/*/.gnupg", "/home/*/.local/share/Trash", "/home/*/.Trash",
"/home/*/.thumbnails", "/home/*/.beagle", "/home/*/.aMule",
"/home/*/gtk-gnutella-downloads" ],
$include = [ "/var/spool/cron/crontabs", "/var/backups", "/etc", "/root",
"/home", "/usr/local/*bin", "/var/lib/dpkg/status*" ],
- $vsinclude = false, $keep = 30, $sshoptions = false, $options = false, $ssh_dir_manage = true,
- $ssh_dir = false, $authorized_keys_file = false, $installuser = true, $installkey = true,
- $backuptag = false, $home = false, $backupkeytype = "rsa", $backupkeystore = false)
+ $vsinclude = false, $keep = 30, $sshoptions = false, $options = '--force', $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)
{
- include backupninja::client::defaults
+ include backupninja::client::rdiff-backup
- case $directory { false: { err("need to define a directory for where the backups should go!") } }
-
case $type {
'remote': {
case $host { false: { err("need to define a host for remote backups!") } }
-
+ $real_backuptag = $backuptag ? {
+ false => "backupninja-$host",
+ default => $backuptag
+ }
+
$real_home = $home ? {
- false => $directory,
+ false => "/home/${user}-${name}",
default => $home,
}
+ $directory = "$real_home/rdiff-backup/"
backupninja::server::sandbox
{
- "${user}-${name}": user => $user, host => $host, dir => $real_home,
- manage_ssh_dir => $ssh_dir_manage, ssh_dir => $ssh_dir,
+ "${user}-${name}": user => $user, host => $fqdn, dir => $real_home,
+ manage_ssh_dir => $ssh_dir_manage, ssh_dir => $ssh_dir, key => $key,
authorized_keys_file => $authorized_keys_file, installuser => $installuser,
- backuptag => $backuptag, keytype => $backupkeytype, backupkeys => $backupkeystore,
+ backuptag => $real_backuptag, keytype => $backupkeytype, backupkeys => $backupkeystore,
}
backupninja::client::key
diff --git a/manifests/server.pp b/manifests/server.pp
index 790c931..9db950a 100644
--- a/manifests/server.pp
+++ b/manifests/server.pp
@@ -23,18 +23,36 @@ class backupninja::server {
mode => 0710, owner => root, group => "backupninjas"
}
+ file { "/usr/local/bin/checkbackups":
+ ensure => "present",
+ source => "puppet://$servername/backupninja/checkbackups.pl",
+ mode => 0755, owner => root, group => root,
+ }
+
+ cron { checkbackups:
+ command => "/usr/local/bin/checkbackups -d $real_backupdir | /usr/sbin/send_nsca -H nagios.koumbit.net -c /etc/send_nsca.cfg | grep -v 'sent to host successfully'",
+ user => "root",
+ hour => "8-23",
+ minute => 59,
+ require => [ File["/usr/local/bin/checkbackups"], Package['nsca'] ]
+ }
+
User <<| tag == "backupninja-$real_backupserver_tag" |>>
File <<| tag == "backupninja-$real_backupserver_tag" |>>
+ Ssh_authorized_key <<| tag == "backupninja-$real_backupserver_tag" |>>
+
+ package { "rsync": ensure => installed }
+ include backupninja::rdiff-installed
# this define allows nodes to declare a remote backup sandbox, that have to
# get created on the server
define sandbox(
$user = false, $host = false, $installuser = true, $dir = false, $manage_ssh_dir = true,
- $ssh_dir = false, $authorized_keys_file = false, $backupkeys = false, $keytype = "rsa",
- $uid = false, $gid = "backupninjas", $backuptag = false)
+ $ssh_dir = false, $authorized_keys_file = false, $key = false, $keytype = 'dss', $backupkeys = false, $uid = false,
+ $gid = "backupninjas", $backuptag = false)
{
- $real_user = $name ? {
+ $real_user = $user ? {
false => $name,
default => $user,
'' => $name,
@@ -63,11 +81,14 @@ class backupninja::server {
false => "backupninja-$real_host",
default => $backuptag,
}
-
+
+ # configure a passive service check for backups
+ nagios2::passive_service { "backups-$real_host": nagios2_host_name => $real_host, nagios2_description => 'backups', servicegroups => "backups" }
+
if !defined(File["$real_dir"]) {
@@file { "$real_dir":
ensure => directory,
- mode => 0750, owner => $user, group => 0,
+ mode => 0750, owner => $real_user, group => 0,
tag => "$real_backuptag",
}
}
@@ -78,22 +99,36 @@ class backupninja::server {
if !defined(File["$real_ssh_dir"]) {
@@file { "${real_ssh_dir}":
ensure => directory,
- mode => 0700, owner => $user, group => 0,
- require => File["$real_dir"],
+ mode => 0700, owner => $real_user, group => 0,
+ require => [User[$real_user], File["$real_dir"]],
tag => "$real_backuptag",
}
}
}
}
- if !defined(File["${real_ssh_dir}/${real_authorized_keys_file}"]) {
- @@file { "${real_ssh_dir}/${real_authorized_keys_file}":
- ensure => present,
- mode => 0644, owner => 0, group => 0,
- source => "$real_backupkeys/${user}_id_${keytype}.pub",
- require => File["${real_ssh_dir}"],
- tag => "$real_backuptag",
+ case $key {
+ false: {
+ if !defined(File["${real_ssh_dir}/${real_authorized_keys_file}"]) {
+ @@file { "${real_ssh_dir}/${real_authorized_keys_file}":
+ ensure => present,
+ mode => 0644, owner => 0, group => 0,
+ source => "$real_backupkeys/${real_user}_id_${keytype}.pub",
+ require => File["${real_ssh_dir}"],
+ tag => "$real_backuptag",
+ }
+ }
+ }
+ default: {
+ @@ssh_authorized_key{ $real_user:
+ type => $keytype,
+ key => $key,
+ user => $real_user,
+ target => "${real_ssh_dir}/${real_authorized_keys_file}",
+ tag => "$real_backuptag",
+ require => User[$real_user],
+ }
}
- }
+ }
case $uid {
false: {
if !defined(User["$real_user"]) {
@@ -105,13 +140,13 @@ class backupninja::server {
managehome => true,
shell => "/bin/sh",
password => '*',
- require => Group['backupninjas'],
+ require => Group['backupninjas'],
tag => "$real_backuptag"
}
}
}
default: {
- if !defined(User["$real_user"]) {
+ if !defined(User["$real_user"]) {
@@user { "$real_user":
ensure => "present",
uid => "$uid",
@@ -121,7 +156,7 @@ class backupninja::server {
managehome => true,
shell => "/bin/sh",
password => '*',
- require => Group['backupninjas'],
+ require => Group['backupninjas'],
tag => "$real_backuptag"
}
}