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
4 changes: 3 additions & 1 deletion manifests/client/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
$ensure = file,
$backup_enable = 'yes',
$client_schedule = 'WeeklyCycle',
$jobdefs = undef,
$db_backend = undef,
$director_password = '',
$director_server = undef,
Expand All @@ -122,6 +123,7 @@
$tls_ca_cert_dir = undef,
$tls_require = 'yes',
$use_tls = false,
$bootstrap = "/var/lib/bacula/${name}.bsr",
) {
include ::bacula::params

Expand Down Expand Up @@ -193,7 +195,7 @@
}

if $run_scripts {
case type($run_scripts) {
case type3x($run_scripts) {
'array' : {
# TODO figure out how to validate each item in the array is a hash.
$run_scripts_real = $run_scripts
Expand Down
32 changes: 32 additions & 0 deletions manifests/client/job.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
define bacula::client::job (
$client = $name,
$type = Backup,
$backup_enable = 'yes',
$restore_enable = 'yes',
$storage_server_real = undef,
$client_schedule = undef,
$director_password = '',
$director_server_real = undef,
$fileset = 'Basic:noHome',
$run_scripts_real = undef,
$storage_server = undef,
$pool = 'default',
$rerun_failed_levels = undef,
$restore_where = '/var/tmp/bacula-restores',
$volume_autoprune = 'Yes',
$volume_retention = '1 Year',
$restore_where = undef,
$bootstrap = undef,
) {

file { "/etc/bacula/bacula-dir.d/jobs-${name}.conf":
ensure => file,
owner => 'bacula',
group => 'bacula',
mode => '0640',
content => template('bacula/job.erb'),
notify => Exec['bacula-dir reload'],
}

}

20 changes: 19 additions & 1 deletion manifests/director.pp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
$use_tls = false,
$use_vol_purge_script = false,
$use_vol_purge_mvdir = undef,
$volume_recycle = 'No',
$volume_autoprune = 'Yes',
$volume_autoprune_diff = 'Yes',
$volume_autoprune_full = 'Yes',
Expand All @@ -73,6 +74,9 @@
) inherits ::bacula::params {


$scripts_dir = $::bacula::params::scripts_dir
$catalog_dir = $::bacula::params::catalog_dir

$director_server_real = $director_server ? {
undef => $::bacula::params::director_server_default,
default => $director_server,
Expand Down Expand Up @@ -258,10 +262,15 @@
require => $service_require,
}

$bconsole_cmd = $::osfamily ? {
'Debian' => '/usr/bin/bconsole',
default => '/usr/sbin/bconsole',
}

# Instead of restarting the <code>bacula-dir</code> service which could interrupt running jobs tell the director to reload its
# configuration.
exec { 'bacula-dir reload':
command => '/bin/echo reload | /usr/sbin/bconsole',
command => "/bin/echo reload | ${bconsole_cmd}",
logoutput => on_failure,
refreshonly => true,
timeout => 10,
Expand All @@ -270,4 +279,13 @@
Service['bacula-dir'],
],
}


concat { "/etc/bacula/bacula-dir.d/pools.conf":
owner => 'bacula',
group => 'tape',
mode => '0644',
}


}
5 changes: 3 additions & 2 deletions manifests/director/custom_config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
$ensure = 'file',
$director_server = undef,
$content = undef,
$source = undef
$source = undef,
$subdir = 'bacula-dir.d',
) {
if !($ensure in ['file', 'absent']) {
fail('The only valid values for the ensure parameter are file or absent')
Expand All @@ -40,7 +41,7 @@
fail('You must supply either the content or source parameter')
}

file { "/etc/bacula/bacula-dir.d/custom-${name}.conf":
file { "/etc/bacula/${subdir}/custom-${name}.conf":
ensure => file,
owner => 'bacula',
group => 'bacula',
Expand Down
51 changes: 33 additions & 18 deletions manifests/director/mysql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
$db_port = '3306',
$db_user = '',
$db_user_host = undef,
$manage_db = false,
) {
$manage_db = false
){
include ::bacula::params

if $manage_db {
Expand All @@ -47,34 +47,49 @@
$db_require = Class['::mysql::server']
}
} else {
$db_require = undef
if defined(Class['percona']) {
$db_require = Class['percona']
$is_percona = true
} else {
$db_require = undef
}
}

$db_user_host_real = $db_user_host ? {
undef => $::fqdn,
default => $db_user_host,
}

#FIXME Due to a bug in v1.0.0 of the puppetlabs-mysql module I can't use a notify here on the define.
mysql::db { $db_database:
user => $db_user,
password => $db_password,
host => $db_user_host,
grant => ['all'],
require => $db_require,
# notify => Exec['make_db_tables'],
before => Exec['make_db_tables'],
if $is_percona {
percona::database { $db_database:
ensure => present,
notify => Exec['make_db_tables'],
}

percona::rights { "${db_user}@${db_user_host}/${db_database}":
database => $db_database,
priv => [ 'all' ],
host => $db_user_host,
password => $db_password,
}
} else {
mysql::db { $db_database:
user => $db_user,
password => $db_password,
host => $db_user_host,
grant => ['all'],
require => $db_require,
notify => Exec['make_db_tables'],
}
}
#FIXME Work around a bug in v1.0.0 of the puppetlabs-mysql module that causes the <code>mysql_grant</code> type to notify on
# every run by having the <code>mysql_database</code> resource created in the <code>mysql::db</code> define notify
# <code>Exec['make_db_tables']</code> instead of using the more flexible notify from the entire define.
Mysql_database[$db_database] ~> Exec['make_db_tables']
}

$make_db_tables_command = $::operatingsystem ? {
/(Ubuntu|Debian)/ => '/usr/lib/bacula/make_bacula_tables',
default => '/usr/libexec/bacula/make_mysql_tables',
'Debian' => '/usr/lib/bacula/make_bacula_tables',
'Ubuntu' => '/usr/share/bacula-director/make_mysql_tables',
default => '/usr/libexec/bacula/make_mysql_tables',
}

$db_parameters = "--host=${db_host} --user=${db_user} --password=${db_password} --port=${db_port} --database=${db_database}"

exec { 'make_db_tables':
Expand Down
40 changes: 40 additions & 0 deletions manifests/director/pool.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# == Define: bacula::director::pool
#
# Include a pool configuration file in <tt>/etc/bacula/bacula-dir.d/pools.conf</tt>.
#
# === Parameters
#
# === Examples
#
# Provide some examples on how to use this type:
#
# bacula::director::pool { 'namevar' :
# label_ext => full,
# }
#
define bacula::director::pool (
$pool_type = 'Backup',
$label_format = '${Client}.${Year}${Month:p/2/0/r}${Day:p/2/0/r}.${Hour:p/2/0/r}${Minute:p/2/0/r}',
$label_ext = undef,
$recycle = 'Yes',
$auto_prune = 'Yes',
$volume_retention = '1 Week',
$max_volume_bytes = '100G',
$max_volume_jobs = 20,
$subdir = 'bacula-dir.d',
) {
if $label_ext == '' {
$fin_label_format = "${label_format}"
} else {
$fin_label_format = "${label_format}.${label_ext}"
}

concat::fragment { "${name}":
ensure => present,
target => "/etc/bacula/${subdir}/pools.conf",
content => template('bacula/pool.erb'),
}



}
5 changes: 4 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
$manage_db_tables = true,
$manage_logwatch = undef,
$operator_command = $::bacula::params::operator_command,
$plugin_dir = undef,
$plugin_dir = $::bacula::params::plugin_dir,
$storage_default_mount = '/mnt/bacula',
$storage_server = undef,
$storage_template = undef,
Expand All @@ -240,6 +240,7 @@
$use_tls = false,
$use_vol_purge_script = false,
$use_vol_purge_mvdir = undef,
$volume_recycle = 'No',
$volume_autoprune = 'Yes',
$volume_autoprune_diff = 'Yes',
$volume_autoprune_full = 'Yes',
Expand Down Expand Up @@ -309,6 +310,7 @@
use_tls => $use_tls,
use_vol_purge_script => $use_vol_purge_script,
use_vol_purge_mvdir => $use_vol_purge_mvdir,
volume_recycle => $volume_recycle,
volume_autoprune => $volume_autoprune,
volume_autoprune_diff => $volume_autoprune_diff,
volume_autoprune_full => $volume_autoprune_full,
Expand Down Expand Up @@ -370,6 +372,7 @@
use_tls => $use_tls,
use_vol_purge_script => $use_vol_purge_script,
use_vol_purge_mvdir => $use_vol_purge_mvdir,
volume_recycle => $volume_recycle,
volume_autoprune => $volume_autoprune,
volume_autoprune_diff => $volume_autoprune_diff,
volume_autoprune_full => $volume_autoprune_full,
Expand Down
14 changes: 13 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
x86_64 => 'lib64',
default => 'lib',
}
$libdir = $::operatingsystem ? {
$libdir = $facts['os']['family'] ? {
/(Debian|Ubuntu)/ => '/usr/lib',
default => "/usr/${lib}",
}
Expand All @@ -74,4 +74,16 @@
/(Debian|Ubuntu)/ => 'bacula-sd-sqlite',
default => 'bacula-storage-sqlite',
}

case $::operatingsystem {
/(Ubuntu)/: {
$scripts_dir = '/etc/bacula/scripts'
$catalog_dir = '/var/lib/bacula'
}
default: {
$scripts_dir = '/usr/libexec/bacula'
$catalog_dir = '/var/spool/bacula'
}
}

}
13 changes: 7 additions & 6 deletions manifests/params/validate.pp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
$use_tls = '',
$use_vol_purge_script = false,
$use_vol_purge_mvdir = undef,
$volume_recycle = '',
$volume_autoprune = '',
$volume_autoprune_diff = '',
$volume_autoprune_full = '',
Expand Down Expand Up @@ -95,18 +96,18 @@
validate_re($volume_autoprune_incr, '^(Yes|yes|No|no)$')

# Validate mail_to variables are email address
if $mail_to != undef {
if $mail_to != '' {
validate_re($mail_to, '^[\w-]+@([\w-]+\.)+[\w-]+$')
} elsif $mail_to == undef and $mail_to_on_error == undef {
} elsif $mail_to == '' and $mail_to_on_error == '' {
validate_re($::bacula::params::mail_to_default, '^[\w-]+@([\w-]+\.)+[\w-]+$')
}
if $mail_to_daemon != undef {
if $mail_to_daemon != '' {
validate_re($mail_to_daemon, '^[\w-]+@([\w-]+\.)+[\w-]+$')
}
if $mail_to_on_error != undef {
if $mail_to_on_error != '' {
validate_re($mail_to_on_error, '^[\w-]+@([\w-]+\.)+[\w-]+$')
}
if $mail_to_operator != undef {
if $mail_to_operator != '' {
validate_re($mail_to_operator, '^[\w-]+@([\w-]+\.)+[\w-]+$')
}
validate_bool($use_vol_purge_script)
Expand Down Expand Up @@ -179,7 +180,7 @@

validate_absolute_path($storage_default_mount)

if $plugin_dir != undef {
if $plugin_dir != '' {
validate_absolute_path($plugin_dir)
}

Expand Down
2 changes: 1 addition & 1 deletion manifests/storage.pp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
ensure => directory,
owner => 'bacula',
group => 'bacula',
mode => '0755',
mode => '0770',
require => Package[$db_package],
}

Expand Down
Loading