aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerome Charaoui <jcharaoui@cmaisonneuve.qc.ca>2015-03-27 15:29:17 -0400
committerJerome Charaoui <jcharaoui@cmaisonneuve.qc.ca>2015-04-17 17:12:16 -0400
commit48711301ebfe809189a004f19ba347f221cbf8e9 (patch)
tree855363e495d3dced31bb10396973b961095d8367
parent32c44017f80fe617935d35cd4207599baf9ab7d8 (diff)
downloadpuppet-backupninja-48711301ebfe809189a004f19ba347f221cbf8e9.tar.gz
puppet-backupninja-48711301ebfe809189a004f19ba347f221cbf8e9.tar.bz2
implement parameters w/ defaults in client class, removing the need for client::defaults
-rw-r--r--manifests/client.pp112
-rw-r--r--manifests/client/defaults.pp45
-rw-r--r--manifests/duplicity.pp17
-rw-r--r--manifests/labelmount.pp9
-rw-r--r--manifests/maildir.pp4
-rw-r--r--manifests/mysql.pp5
-rw-r--r--manifests/pgsql.pp6
-rw-r--r--manifests/rdiff.pp7
-rw-r--r--manifests/rsync.pp6
-rw-r--r--manifests/sh.pp5
-rw-r--r--manifests/svn.pp5
-rw-r--r--manifests/sys.pp5
12 files changed, 81 insertions, 145 deletions
diff --git a/manifests/client.pp b/manifests/client.pp
index f0531a0..3239cde 100644
--- a/manifests/client.pp
+++ b/manifests/client.pp
@@ -1,73 +1,63 @@
-class backupninja::client inherits backupninja::client::defaults {
+class backupninja::client (
+ $ensure_backupninja_version = 'installed',
+ $configdir = '/etc/backup.d',
+ $keystore = "${::fileserver}/keys/backupkeys",
+ $keystorefspath = false,
+ $keytype = 'rsa',
+ $keydest = '/root/.ssh',
+ $keyowner = 0,
+ $keygroup = 0,
+ $keymanage = true,
+) {
+
+ # install client dependencies
+ ensure_resource('package', 'backupninja', {'ensure' => $ensure_backupninja_version})
+
+ # set up backupninja config directory
+ file { $configdir:
+ ensure => directory,
+ mode => 750, owner => 0, group => 0;
+ }
+
define key(
- $user = false, $host = false, $createkey=false, $installkey=false,
- $keyowner=false, $keygroup=false, $keystore=false, $keystorefspath='',
- $keytype=false,
- $keydest=false, $keydestname=false )
+ $user = $name,
+ $createkey = false,
+ $keymanage = $backupninja::keymanage,
+ $keyowner = $backupninja::keyowner,
+ $keygroup = $backupninja::keygroup,
+ $keystore= $backupninja::keystore,
+ $keystorefspath = $backupninja::keystorefspath,
+ $keytype = $backupninja::keytype,
+ $keydest = $backupninja::keydest,
+ $keydestname = "id_${backupninja::keytpe}" )
{
- $real_user = $user ? {
- false => $name,
- default => $user
- }
- $real_host = $host ? {
- false => $user,
- default => $host
- }
- $install_key = $installkey ? {
- false => "${backupninja::client::defaults::real_keymanage}",
- default => $installkey,
- }
- $key_owner = $keyowner ? {
- false => "${backupninja::client::defaults::real_keyowner}",
- default => $keyowner,
- }
- $key_group = $keygroup ? {
- false => "${backupninja::client::defaults::real_keygroup}",
- default => $keygroup,
- }
- $key_store = $keystore ? {
- false => "${backupninja::client::defaults::real_keystore}",
- default => $keystore,
- }
- $key_type = $keytype ? {
- '' => "${backupninja::client::defaults::real_keytype}",
- false => "${backupninja::client::defaults::real_keytype}",
- default => $keytype,
- }
- $key_dest = $keydest ? {
- false => "${backupninja::client::defaults::real_keydestination}",
- default => $keydest,
- }
- $key_dest_name = $keydestname ? {
- false => "id_$key_type",
- default => $keydestname,
- }
- $key_dest_file = "${key_dest}/${key_dest_name}"
+ # generate the key
if $createkey == true {
if $keystorefspath == false {
err("need to define a destination directory for sshkey creation!")
}
- $ssh_keys = ssh_keygen("${keystorefspath}/${key_dest_name}")
+ $ssh_keys = ssh_keygen("${keystorefspath}/${keydestname}")
}
-
- case $install_key {
- true: {
- if !defined(File["$key_dest"]) {
- file { "$key_dest":
- ensure => directory,
- mode => 0700, owner => $key_owner, group => $key_group,
- }
- }
- if !defined(File["$key_dest_file"]) {
- file { "$key_dest_file":
- source => "${key_store}/${key_dest_name}",
- mode => 0400, owner => $key_owner, group => $key_group,
- require => File["$key_dest"],
- }
- }
- }
+ # deploy/manage the key
+ if $keymanage == true {
+ $keydestfile = "${keydest}/${keydestname}"
+ ensure_resource('file', $keydest, {
+ 'ensure' => 'directory',
+ 'mode' => '0700',
+ 'owner' => $keyowner,
+ 'group' => $keygroup
+ })
+ ensure_resource('file', $keydestfile, {
+ 'ensure' => 'present',
+ 'source' => "${keystore}/${keydestname}",
+ 'mode' => '0700',
+ 'owner' => $keyowner,
+ 'group' => $keygroup,
+ 'require' => 'File["$key_dest"]'
+ })
}
}
+
}
diff --git a/manifests/client/defaults.pp b/manifests/client/defaults.pp
deleted file mode 100644
index 9dc8747..0000000
--- a/manifests/client/defaults.pp
+++ /dev/null
@@ -1,45 +0,0 @@
-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/duplicity.pp b/manifests/duplicity.pp
index 8313eb9..fa68324 100644
--- a/manifests/duplicity.pp
+++ b/manifests/duplicity.pp
@@ -82,11 +82,11 @@ define backupninja::duplicity( $order = 90,
$destuser = false,
$desturl = false,
# configs to backupninja client
- $backupkeystore = false,
- $backupkeystorefspath = '',
- $backupkeytype = "rsa",
- $backupkeydest = false,
- $backupkeydestname = false,
+ $backupkeystore = $backupninja::keystore,
+ $backupkeystorefspath = $backupninja::keystorefspath,
+ $backupkeytype = $backupninja::keytype,
+ $backupkeydest = $backupninja::keydest,
+ $backupkeydestname = $backupninja::keydestname,
# options to backupninja server sandbox
$ssh_dir_manage = true,
$ssh_dir = false,
@@ -100,9 +100,6 @@ define backupninja::duplicity( $order = 90,
# install client dependencies
ensure_resource('package', 'duplicity', {'ensure' => $ensure_duplicity_version})
- # 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!") } }
@@ -135,13 +132,13 @@ define backupninja::duplicity( $order = 90,
}
# the backupninja rule for this duplicity backup
- file { "${backupninja::client::defaults::configdir}/${order}_${name}.dup":
+ file { "${backupninja::configdir}/${order}_${name}.dup":
ensure => $ensure,
content => template('backupninja/dup.conf.erb'),
owner => root,
group => root,
mode => 0600,
- require => File["${backupninja::client::defaults::configdir}"]
+ require => File["${backupninja::configdir}"]
}
}
diff --git a/manifests/labelmount.pp b/manifests/labelmount.pp
index 6b1f772..8974cec 100644
--- a/manifests/labelmount.pp
+++ b/manifests/labelmount.pp
@@ -23,23 +23,22 @@ define backupninja::labelmount($order = 10,
$label,
$dest
) {
- include backupninja::client::defaults
- file { "${backupninja::client::defaults::configdir}/${order}_${name}.labelmount":
+ file { "${backupninja::configdir}/${order}_${name}.labelmount":
ensure => $ensure,
content => template('backupninja/labelmount.conf.erb'),
owner => root,
group => root,
mode => 0600,
- require => File["${backupninja::client::defaults::configdir}"]
+ require => File["${backupninja::configdir}"]
}
- file { "${backupninja::client::defaults::configdir}/99_${name}.umount":
+ file { "${backupninja::configdir}/99_${name}.umount":
ensure => $ensure,
content => template('backupninja/umount.conf.erb'),
owner => root,
group => root,
mode => 0600,
- require => File["${backupninja::client::defaults::configdir}"]
+ require => File["${backupninja::configdir}"]
}
# Copy over the handler scripts themselves, since they're not in the
diff --git a/manifests/maildir.pp b/manifests/maildir.pp
index c394a5c..a7bb1e5 100644
--- a/manifests/maildir.pp
+++ b/manifests/maildir.pp
@@ -32,12 +32,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::defaults::configdir}/${order}_${name}.maildir":
+ file { "${backupninja::configdir}/${order}_${name}.maildir":
ensure => $ensure,
content => template('backupninja/maildir.conf.erb'),
owner => root,
group => root,
mode => 0600,
- require => File["${backupninja::client::defaults::configdir}"]
+ require => File["${backupninja::configdir}"]
}
}
diff --git a/manifests/mysql.pp b/manifests/mysql.pp
index 8e33e8e..b8877c0 100644
--- a/manifests/mysql.pp
+++ b/manifests/mysql.pp
@@ -27,13 +27,12 @@ define backupninja::mysql(
default => $configfile,
}
- include backupninja::client::defaults
- file { "${backupninja::client::defaults::configdir}/${order}_${name}.mysql":
+ file { "${backupninja::configdir}/${order}_${name}.mysql":
ensure => $ensure,
content => template('backupninja/mysql.conf.erb'),
owner => root,
group => root,
mode => 0600,
- require => File["${backupninja::client::defaults::configdir}"]
+ require => File["${backupninja::configdir}"]
}
}
diff --git a/manifests/pgsql.pp b/manifests/pgsql.pp
index 07fab32..d4814be 100644
--- a/manifests/pgsql.pp
+++ b/manifests/pgsql.pp
@@ -16,14 +16,12 @@
define backupninja::pgsql(
$order = 10, $ensure = present, $databases = 'all', $backupdir = "/var/backups/postgres", $compress = true, $vsname = false)
{
-
- include backupninja::client::defaults
- file { "${backupninja::client::defaults::configdir}/${order}_${name}.pgsql":
+ file { "${backupninja::configdir}/${order}_${name}.pgsql":
ensure => $ensure,
content => template('backupninja/pgsql.conf.erb'),
owner => root,
group => root,
mode => 0600,
- require => File["${backupninja::client::defaults::configdir}"]
+ require => File["${backupninja::configdir}"]
}
}
diff --git a/manifests/rdiff.pp b/manifests/rdiff.pp
index bd88859..ce8da19 100644
--- a/manifests/rdiff.pp
+++ b/manifests/rdiff.pp
@@ -26,7 +26,8 @@ define backupninja::rdiff(
"/home", "/usr/local/*bin", "/var/lib/dpkg/status*" ],
$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, $backupkeytype = "rsa", $backupkeystore = false, $extras = false, $nagios2_description = 'backups')
+ $backuptag = false, $backupkeytype = $backupninja::keytype, $backupkeystore = $backupninja::keystore,
+ $extras = false, $nagios2_description = 'backups')
{
# install client dependencies
ensure_resource('package', 'rdiff-backup', {'ensure' => $ensure_rdiffbackup_version})
@@ -61,13 +62,13 @@ define backupninja::rdiff(
}
- file { "${backupninja::client::defaults::configdir}/${order}_${name}.rdiff":
+ file { "${backupninja::configdir}/${order}_${name}.rdiff":
ensure => $ensure,
content => template('backupninja/rdiff.conf.erb'),
owner => root,
group => root,
mode => 0600,
- require => File["${backupninja::client::defaults::configdir}"]
+ require => File["${backupninja::configdir}"]
}
}
diff --git a/manifests/rsync.pp b/manifests/rsync.pp
index 7398265..30dfdbb 100644
--- a/manifests/rsync.pp
+++ b/manifests/rsync.pp
@@ -6,7 +6,7 @@ define backupninja::rsync(
$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,
+ $home = false, $backupkeytype = $backupninja::keytype, $backupkeystore = $backupninja::keystore, $extras = false,
$nagios2_description = 'backups', $subfolder = 'rsync',
$log = false, $partition = false, $fscheck = false, $read_only = false,
@@ -78,12 +78,12 @@ define backupninja::rsync(
}
}
- file { "${backupninja::client::defaults::configdir}/${order}_${name}.rsync":
+ file { "${backupninja::configdir}/${order}_${name}.rsync":
ensure => $ensure,
content => template('backupninja/rsync.conf.erb'),
owner => root,
group => root,
mode => 0600,
- require => File["${backupninja::client::defaults::configdir}"]
+ require => File["${backupninja::configdir}"]
}
}
diff --git a/manifests/sh.pp b/manifests/sh.pp
index fa6aca5..4a60e5f 100644
--- a/manifests/sh.pp
+++ b/manifests/sh.pp
@@ -14,13 +14,12 @@ define backupninja::sh($order = 50,
$ensure = present,
$command_string
) {
- include backupninja::client::defaults
- file { "${backupninja::client::defaults::configdir}/${order}_${name}.sh":
+ file { "${backupninja::configdir}/${order}_${name}.sh":
ensure => $ensure,
content => template('backupninja/sh.conf.erb'),
owner => root,
group => root,
mode => 0600,
- require => File["${backupninja::client::defaults::configdir}"]
+ require => File["${backupninja::configdir}"]
}
}
diff --git a/manifests/svn.pp b/manifests/svn.pp
index 3ab59c9..1ab0597 100644
--- a/manifests/svn.pp
+++ b/manifests/svn.pp
@@ -17,13 +17,12 @@ define backupninja::svn($order = 20,
$tmp = '/var/backups/svn.tmp',
$vsname = false
) {
- include backupninja::client::defaults
- file { "${backupninja::client::defaults::configdir}/${order}_${name}.svn":
+ file { "${backupninja::configdir}/${order}_${name}.svn":
ensure => $ensure,
content => template('backupninja/svn.conf.erb'),
owner => root,
group => root,
mode => 0600,
- require => File["${backupninja::client::defaults::configdir}"]
+ require => File["${backupninja::configdir}"]
}
}
diff --git a/manifests/sys.pp b/manifests/sys.pp
index ceaab98..d2b4aa9 100644
--- a/manifests/sys.pp
+++ b/manifests/sys.pp
@@ -26,7 +26,6 @@ define backupninja::sys($order = 30,
$doluks = false,
$dolvm = false
) {
- include backupninja::client::defaults
# install client dependencies
case $operatingsystem {
@@ -37,12 +36,12 @@ define backupninja::sys($order = 30,
default: {}
}
- file { "${backupninja::client::defaults::configdir}/${order}_${name}.sys":
+ file { "${backupninja::configdir}/${order}_${name}.sys":
ensure => $ensure,
content => template('backupninja/sys.conf.erb'),
owner => root,
group => root,
mode => 0600,
- require => File["${backupninja::client::defaults::configdir}"]
+ require => File["${backupninja::configdir}"]
}
}