Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 13 additions & 91 deletions manifests/entry.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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)

}
6 changes: 0 additions & 6 deletions manifests/entry/duplicity.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 0 additions & 6 deletions manifests/entry/ldap.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
56 changes: 20 additions & 36 deletions manifests/entry/mysql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}


Expand Down
10 changes: 5 additions & 5 deletions manifests/entry/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand Down
22 changes: 3 additions & 19 deletions manifests/entry/pgsql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,19 @@
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',
) {

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' ]
Expand Down
6 changes: 0 additions & 6 deletions manifests/entry/sh.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion templates/entry/duplicity.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MANAGED BY PUPPET!

<%- @_when_real.each do |time| -%>
<%- @when.each do |time| -%>
when = <%= time %>
<%- end -%>

Expand Down
2 changes: 1 addition & 1 deletion templates/entry/ldap.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MANAGED BY PUPPET!

<%- @_when_real.each do |time| -%>
<%- @when.each do |time| -%>
when = <%= time %>
<%- end -%>

Expand Down
2 changes: 1 addition & 1 deletion templates/entry/mysql.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MANAGED BY PUPPET!

<%- @_when_real.each do |time| -%>
<%- @when.each do |time| -%>
when = <%= time %>
<%- end -%>

Expand Down
2 changes: 1 addition & 1 deletion templates/entry/pgsql.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MANAGED BY PUPPET!

<%- @_when_real.each do |time| -%>
<%- @when.each do |time| -%>
when = <%= time %>
<%- end -%>

Expand Down
2 changes: 1 addition & 1 deletion templates/entry/sh.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MANAGED BY PUPPET!

<%- @_when_real.each do |time| -%>
<%- @when.each do |time| -%>
when = <%= time %>
<%- end -%>

Expand Down