diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2009-08-28 17:17:25 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2009-08-28 17:17:25 -0300 |
commit | b432d94fa72162aa9635217b703ad100b9d39fa2 (patch) | |
tree | 238a150b9968c52c3b17aab62cbc5e615b80f94e | |
parent | f96267fe354a9df417afdc09899c58edf3e67d24 (diff) | |
download | puppet-backupninja-b432d94fa72162aa9635217b703ad100b9d39fa2.tar.gz puppet-backupninja-b432d94fa72162aa9635217b703ad100b9d39fa2.tar.bz2 |
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.
-rw-r--r-- | manifests/client.pp | 33 | ||||
-rw-r--r-- | manifests/dup.pp | 6 | ||||
-rw-r--r-- | manifests/labelmount.pp | 10 | ||||
-rw-r--r-- | manifests/maildir.pp | 6 | ||||
-rw-r--r-- | manifests/mysql.pp | 6 | ||||
-rw-r--r-- | manifests/rdiff.pp | 6 | ||||
-rw-r--r-- | manifests/sh.pp | 6 | ||||
-rw-r--r-- | manifests/svn.pp | 6 | ||||
-rw-r--r-- | manifests/sys.pp | 6 |
9 files changed, 44 insertions, 41 deletions
diff --git a/manifests/client.pp b/manifests/client.pp index fa64510..f8c5e23 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -1,4 +1,4 @@ -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' } diff --git a/manifests/dup.pp b/manifests/dup.pp index 411a44d..6e0330a 100644 --- a/manifests/dup.pp +++ b/manifests/dup.pp @@ -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}"] } } diff --git a/manifests/labelmount.pp b/manifests/labelmount.pp index d9158c4..6b1f772 100644 --- a/manifests/labelmount.pp +++ b/manifests/labelmount.pp @@ -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 diff --git a/manifests/maildir.pp b/manifests/maildir.pp index 8444a9e..d871654 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 + 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}"] } } diff --git a/manifests/mysql.pp b/manifests/mysql.pp index e7c0eb4..e6cfe90 100644 --- a/manifests/mysql.pp +++ b/manifests/mysql.pp @@ -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}"] } } diff --git a/manifests/rdiff.pp b/manifests/rdiff.pp index 904c68f..9f81d8f 100644 --- a/manifests/rdiff.pp +++ b/manifests/rdiff.pp @@ -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}"] } } diff --git a/manifests/sh.pp b/manifests/sh.pp index a49a3d1..fa6aca5 100644 --- a/manifests/sh.pp +++ b/manifests/sh.pp @@ -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}"] } } diff --git a/manifests/svn.pp b/manifests/svn.pp index 903be74..3ab59c9 100644 --- a/manifests/svn.pp +++ b/manifests/svn.pp @@ -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}"] } } diff --git a/manifests/sys.pp b/manifests/sys.pp index 106da9b..973f880 100644 --- a/manifests/sys.pp +++ b/manifests/sys.pp @@ -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}"] } } |