diff --git a/manifests/entry.pp b/manifests/entry.pp index 58781e5..d7dc8e4 100644 --- a/manifests/entry.pp +++ b/manifests/entry.pp @@ -19,97 +19,19 @@ default => $when } - case $type { - 'duplicity': { - backupninja::entry::duplicity { $name: - ensure => $ensure, - weight => $weight, - when => $real_when, - # Duplicity - options => $options[options], - nicelevel => $options[nicelevel], - testconnect => $options[testconnect], - sign => $options[sign], - encryptkey => $options[encryptkey], - signkey => $options[signkey], - password => $options[password], - include => $options[include], - exclude => $options[exclude], - incremental => $options[incremental], - increments => $options[increments], - keep => $options[keep], - desturl => $options[desturl], - awsaccesskeyid => $options[awsaccesskeyid], - awssecretaccesskey => $options[awssecretaccesskey], - ftp_password => $options[ftp_password], - bandwidthlimit => $options[bandwidthlimit], - sshoptions => $options[sshoptions], - destdir => $options[destdir], - desthost => $options[desthost], - destuser => $options[destuser], - } - } - 'ldap': { - backupninja::entry::ldap { $name: - ensure => $ensure, - weight => $weight, - when => $real_when, - # Ldap - backupdir => $options[backupdir], - suffixes => $options[suffixes], - compress => $options[compress], - ldif => $options[ldif], - restart => $options[restart], - } - } - 'mysql': { - backupninja::entry::mysql { $name: - ensure => $ensure, - weight => $weight, - when => $real_when, - # MySQL - hotcopy => $options[hotcopy], - sqldump => $options[sqldump], - sqldumpoptions => $options[sqldumpoptions], - compress => $options[compress], - dbhost => $options[dbhost], - backupdir => $options[backupdir], - databases => $options[databases], - user => $options[user], - dbusername => $options[dbusername], - dbpassword => $options[dbpassword], - configfile => $options[configfile], - nodata => $options[nodata], - nodata_any => $options[nodata_any], - vsname => $options[vsname], - handler => $options[handler], - } - } - 'pgsql': { - backupninja::entry::pgsql { $name: - ensure => $ensure, - weight => $weight, - when => $real_when, - # pgsql - compress => $options[compress], - backupdir => $options[backupdir], - databases => $options[databases], - format => $options[format], - handler => $options[handler], - } - } - 'sh': { - backupninja::entry::sh { $name: - ensure => $ensure, - weight => $weight, - when => $real_when, - #sh - commands => $options[commands], - } - } - default: { - fail "Uknown type ${type} for backupninja::entry" - } + if $real_when =~ Array[String] { + $_when_real = $real_when + } else { + $_when_real = [] << $real_when } + $defaults = { + 'ensure' => $ensure, + 'weight' => $weight, + 'when' => $_when_real, + } + + $params = merge($defaults, $options) + ensure_resource("backupninja::entry::${type}", $name, $params) + } diff --git a/manifests/entry/duplicity.pp b/manifests/entry/duplicity.pp index 2aa83d3..9d89a06 100644 --- a/manifests/entry/duplicity.pp +++ b/manifests/entry/duplicity.pp @@ -49,12 +49,6 @@ require backupninja::entry::params - if $when =~ Array[String] { - $_when_real = $when - } else { - $_when_real = [] << $when - } - if ! defined(Package[$backupninja::entry::params::duplicity_package_name]) { package { $backupninja::entry::params::duplicity_package_name: ensure => $backupninja::ensure, diff --git a/manifests/entry/ldap.pp b/manifests/entry/ldap.pp index 4e468ed..211eda7 100644 --- a/manifests/entry/ldap.pp +++ b/manifests/entry/ldap.pp @@ -17,12 +17,6 @@ require backupninja::params require backupninja::entry::params - if $when =~ Array[String] { - $_when_real = $when - } else { - $_when_real = [] << $when - } - file { "${backupninja::params::config_dir}/${weight}_${name}.${handler}" : ensure => $ensure, owner => 'root', diff --git a/manifests/entry/mysql.pp b/manifests/entry/mysql.pp index 8299e93..6447f22 100644 --- a/manifests/entry/mysql.pp +++ b/manifests/entry/mysql.pp @@ -3,50 +3,34 @@ # This defined type handles the mysql backupninja task entries # define backupninja::entry::mysql ( - Enum['present', 'absent'] $ensure = $backupninja::ensure, - Optional[Integer] $weight = 20, - Variant[Array[String], String] $when = '', - Boolean $hotcopy = false, - Boolean $sqldump = true, - String $sqldumpoptions = '--lock-tables --complete-insert --add-drop-table --quick --quote-names', - Boolean $compress = false, - String $dbhost = '', - Stdlib::Absolutepath $backupdir = "${backupninja::params::backupdir}/mysql", - Variant[Array[String], String] $databases = 'all', - String $user = '', - String $dbusername = '', - String $dbpassword = '', - Stdlib::Absolutepath $configfile = $backupninja::params::mysql_configfile, - String $nodata = '', - Array[String] $nodata_any = [], - String $vsname = '', - String $handler = 'mysql', + Enum['present', 'absent'] $ensure = $backupninja::ensure, + Optional[Integer] $weight = 20, + Variant[Array[String], String] $when = '', + Boolean $hotcopy = false, + Boolean $sqldump = true, + String $sqldumpoptions = '--lock-tables --complete-insert --add-drop-table --quick --quote-names', + Boolean $compress = false, + String $dbhost = '', + Stdlib::Absolutepath $backupdir = "${backupninja::params::backupdir}/mysql", + Array[String] $databases = ['all'], + String $user = '', + String $dbusername = '', + String $dbpassword = '', + Stdlib::Absolutepath $configfile = $backupninja::params::mysql_configfile, + String $nodata = '', + Array[String] $nodata_any = [], + String $vsname = '', + String $handler = 'mysql', ) { require backupninja::params require backupninja::entry::params - if $when =~ Array[String] { - $_when_real = $when - } else { - $_when_real = [] << $when - } - - if empty($databases) { - $db_list = ['all'] - } - elsif is_string($databases) { - $db_list = split($databases, ' ') - } - else { - $db_list = $databases - } - - if $db_list.size > 1 and 'all' in $db_list { + if $databases.size > 1 and 'all' in $databases { $db_list_real = ['all'] } else { - $db_list_real = $db_list.unique + $db_list_real = $databases.unique } diff --git a/manifests/entry/params.pp b/manifests/entry/params.pp index 5bc30a8..d6a842c 100644 --- a/manifests/entry/params.pp +++ b/manifests/entry/params.pp @@ -6,11 +6,11 @@ require backupninja::params - if $backupninja::params::when =~ Array[String] { - $_when_real = $backupninja::params::when - } else { - $_when_real = [] << $backupninja::params::when - } +# if $backupninja::params::when =~ Array[String] { +# $_when_real = $backupninja::params::when +# } else { +# $_when_real = [] << $backupninja::params::when +# } case $::osfamily { 'Debian': { diff --git a/manifests/entry/pgsql.pp b/manifests/entry/pgsql.pp index 043327b..e94557c 100644 --- a/manifests/entry/pgsql.pp +++ b/manifests/entry/pgsql.pp @@ -8,7 +8,7 @@ Variant[Array[String], String] $when = '', Boolean $compress = false, Stdlib::Absolutepath $backupdir = "${backupninja::params::backupdir}/postgres", - String $databases = 'all', + Array[String] $databases = ['all'], String $format = 'custom', String $handler = 'pgsql', ) { @@ -16,27 +16,11 @@ require backupninja::params require backupninja::entry::params - if $when =~ Array[String] { - $_when_real = $when - } else { - $_when_real = [] << $when - } - - if empty($databases) { - $db_list = ['all'] - } - elsif is_string($databases) { - $db_list = split($databases, ' ') - } - else { - $db_list = $databases - } - - if $db_list.size > 1 and 'all' in $db_list { + if $databases.size > 1 and 'all' in $databases { $db_list_real = ['all'] } else { - $db_list_real = $db_list.unique + $db_list_real = $databases.unique } $formats = [ 'plain', 'tar', 'custom' ] diff --git a/manifests/entry/sh.pp b/manifests/entry/sh.pp index 94ff4b5..27a8831 100644 --- a/manifests/entry/sh.pp +++ b/manifests/entry/sh.pp @@ -11,12 +11,6 @@ require backupninja::params - if $when =~ Array[String] { - $_when_real = $when - } else { - $_when_real = [] << $when - } - file { "${backupninja::params::config_dir}/${weight}_${name}.sh" : ensure => $ensure, owner => 'root', diff --git a/templates/entry/duplicity.erb b/templates/entry/duplicity.erb index 54f2195..fc40d87 100644 --- a/templates/entry/duplicity.erb +++ b/templates/entry/duplicity.erb @@ -1,6 +1,6 @@ # MANAGED BY PUPPET! -<%- @_when_real.each do |time| -%> +<%- @when.each do |time| -%> when = <%= time %> <%- end -%> diff --git a/templates/entry/ldap.erb b/templates/entry/ldap.erb index 69c0898..e9a7e51 100644 --- a/templates/entry/ldap.erb +++ b/templates/entry/ldap.erb @@ -1,6 +1,6 @@ # MANAGED BY PUPPET! -<%- @_when_real.each do |time| -%> +<%- @when.each do |time| -%> when = <%= time %> <%- end -%> diff --git a/templates/entry/mysql.erb b/templates/entry/mysql.erb index a341036..e54391c 100644 --- a/templates/entry/mysql.erb +++ b/templates/entry/mysql.erb @@ -1,6 +1,6 @@ # MANAGED BY PUPPET! -<%- @_when_real.each do |time| -%> +<%- @when.each do |time| -%> when = <%= time %> <%- end -%> diff --git a/templates/entry/pgsql.erb b/templates/entry/pgsql.erb index 92445aa..b76be90 100644 --- a/templates/entry/pgsql.erb +++ b/templates/entry/pgsql.erb @@ -1,6 +1,6 @@ # MANAGED BY PUPPET! -<%- @_when_real.each do |time| -%> +<%- @when.each do |time| -%> when = <%= time %> <%- end -%> diff --git a/templates/entry/sh.erb b/templates/entry/sh.erb index afad5a0..eea0bf5 100644 --- a/templates/entry/sh.erb +++ b/templates/entry/sh.erb @@ -1,6 +1,6 @@ # MANAGED BY PUPPET! -<%- @_when_real.each do |time| -%> +<%- @when.each do |time| -%> when = <%= time %> <%- end -%>