bacula: Changed storage daemon to run as bacula user instead of root and converted tape alerts to use custom script.

This commit is contained in:
Timo Mkinen 2013-05-21 08:38:15 +03:00
parent f3ad618caa
commit 9c3f13701a
3 changed files with 60 additions and 6 deletions

23
bacula/files/tapealert Executable file
View file

@ -0,0 +1,23 @@
#!/bin/sh
if [ $# -ne 1 ]; then
echo "Usage: `basename $0` <device>" 1>&2
exit 1
fi
PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
DEVICE=$1
GENERIC=`readlink /sys/class/scsi_tape/\`basename ${DEVICE}\`/device/generic`
if [ $? -ne 0 ]; then
echo "ERR: Cannot find tape drive ${DEVICE}" 1>&2
exit 1
fi
GENERIC=/dev/`basename ${GENERIC}`
tapeinfo -f ${GENERIC} | fgrep TapeAlert
if [ $? -eq 1 ]; then
exit 0
fi
smartctl -H -l error ${GENERIC}

View file

@ -358,6 +358,23 @@ class bacula::storage($password = undef) {
before => Class["bacula::certificates"],
}
file { "/etc/sysconfig/bacula-sd":
ensure => present,
content => "SD_USER=bacula\nSD_GROUP=bacula\n",
mode => "0644",
owner => "root",
group => "root",
require => Package["bacula-storage"],
notify => Service["bacula-sd"],
}
exec { "usermod-bacula":
path => "/bin:/usr/bin:/sbin:/usr/sbin",
command => "usermod -a -G tape bacula",
unless => "id -n -G bacula | grep '\\btape\\b'",
require => Package["bacula-storage"],
before => Service["bacula-sd"],
}
file { "/etc/bacula/bacula-sd.conf":
ensure => present,
content => template("bacula/bacula-sd.conf.erb"),
@ -408,10 +425,7 @@ class bacula::storage($password = undef) {
define bacula::device($device, $media) {
include bacula::storage
require smart
package { "mtx":
ensure => installed,
}
require bacula::device::common
file { "/etc/bacula/bacula-sd.d/${name}.conf":
ensure => present,
@ -435,6 +449,24 @@ define bacula::device($device, $media) {
}
class bacula::device::common {
require smart
package { "mtx":
ensure => installed,
}
file { "/usr/local/sbin/tapealert":
ensure => present,
source => "puppet:///modules/bacula/tapealert",
mode => "0755",
owner => "root",
group => "root",
}
}
# Install Bacula web interface
#
# === Parameters

View file

@ -8,6 +8,5 @@ Device {
RemovableMedia = yes;
RandomAccess = no;
Maximum Network Buffer Size = 65536
Alert Command = "sh -c 'tapeinfo -f <%= @device %> | grep TapeAlert | cat'"
Alert Command = "sh -c 'smartctl -H -l error <%= @device %> | cat'"
Alert Command = "sh -c '/usr/local/sbin/tapealert %a'"
}