Split up mail roles
authorPeter Palfrader <peter@palfrader.org>
Wed, 25 Sep 2019 16:21:30 +0000 (18:21 +0200)
committerPeter Palfrader <peter@palfrader.org>
Wed, 25 Sep 2019 16:37:00 +0000 (18:37 +0200)
data/common.yaml
modules/bacula/manifests/init.pp
modules/bacula/templates/bacula-dir.conf.erb

index 970397a..06f0d03 100644 (file)
@@ -32,7 +32,7 @@ roles::dns_primary::allow_access:
   - '2a01:3f0:0:28::25'
 # bacula
 #
-bacula::operator_email: 'bacula-reports@admin.debian.org'
+bacula::email_all: 'bacula-reports@admin.debian.org'
 bacula::ssl_ca_path:     '/etc/ssl/debian/certs/ca.crt'
 bacula::ssl_client_cert: '/etc/ssl/debian/certs/thishost.crt'
 bacula::ssl_client_key:  '/etc/ssl/private/thishost.key'
index dfbc9ce..90e42af 100644 (file)
@@ -5,7 +5,10 @@
 # @param ssl_client_key   path to TLS client certificate key
 # @param ssl_server_cert  path to TLS server certificate
 # @param ssl_server_key   path to TLS server certificate key
-# @param operator_email   email address for reports
+# @param email_all        email address for all reports
+# @param email_error      email address for errors
+# @param email_operator   email address for the operator (to mount tapes etc)
+# @param email_daemon     email address for messages from the daemon
 # @param public_addresses this host's public IP addresses.  The ones it connects out from and is reachable from outsite.
 # @param has_ipv4         daemons should listen on ipv4
 # @param has_ipv6         daemons should listen on ipv6
@@ -16,7 +19,10 @@ class bacula (
   String $ssl_server_cert,
   String $ssl_server_key,
 
-  String $operator_email                       = 'root@localhost',
+  Optional[String] $email_all = undef,
+  String $email_error                          = $email_all ? { true => $email_all, default => 'root@localhost' },
+  String $email_operator                       = $email_error,
+  String $email_daemon                         = $email_error,
   Array[Stdlib::IP::Address] $public_addresses = $base::public_addresses,
   Boolean $has_ipv4                            = $bacula::public_addresses.any |$addr| { $addr =~ Stdlib::IP::Address::V4 },
   Boolean $has_ipv6                            = $bacula::public_addresses.any |$addr| { $addr =~ Stdlib::IP::Address::V6 },
index f714ea2..b2a2093 100644 (file)
@@ -105,8 +105,13 @@ Messages {
   Name = <%= @messages_name %>
   mailcommand = "/usr/lib/bacula/bsmtp -h localhost -f \"\(Bacula\) %r\" -s \"Bacula: %t %e of %c %l\" %r"
   operatorcommand = "/usr/lib/bacula/bsmtp -h localhost -f \"\(Bacula\) %r\" -s \"Bacula: Intervention needed for %j\" %r"
-  mail = <%= @operator_email %> = all
-  operator = <%= @operator_email %> = mount
+<% if @email_all %>
+  mail = <%= @email_all %> = all
+<% end %>
+<% if @email_error != @email_all %>
+  mail on error = <%= @email_error %> = all
+<% end %>
+  operator = <%= @email_operator %> = mount
   console = all, !skipped, !saved
   syslog = all
   append = "/var/lib/bacula/log" = all
@@ -117,7 +122,7 @@ Messages {
 Messages {
   Name = Daemon
   mailcommand = "/usr/lib/bacula/bsmtp -h localhost -f \"\(Bacula\) %r\" -s \"Bacula daemon message\" %r"
-  mail = <%= @operator_email %> = all
+  mail = <%= @email_daemon %> = all
   console = all, !skipped, !saved
   syslog = all
   append = "/var/lib/bacula/log" = all