Move filestore device and media type name to the storage, part I
authorPeter Palfrader <peter@palfrader.org>
Tue, 24 Sep 2019 13:31:03 +0000 (15:31 +0200)
committerPeter Palfrader <peter@palfrader.org>
Tue, 24 Sep 2019 13:34:09 +0000 (15:34 +0200)
For now for config on the storage node.  Not yet for config
pushed from the client to the director.

Also rename bacula::storage_per_node to bacula::storage::client.

data/common.yaml
modules/bacula/manifests/client.pp
modules/bacula/manifests/storage.pp
modules/bacula/manifests/storage/client.pp [new file with mode: 0644]
modules/bacula/manifests/storage_per_node.pp [deleted file]
modules/bacula/templates/storage-per-client.conf.erb [deleted file]
modules/bacula/templates/storage/sd-per-client.conf.erb [new file with mode: 0644]

index ff5efc0..4cd0c19 100644 (file)
@@ -36,6 +36,8 @@ bacula::director::db_address: 'postgresql-manda-01.debian.org'
 bacula::director::db_port:    5432
 bacula::director::db_sslca:   '/etc/ssl/debian/certs/ca.crt'
 
+bacula::client::storage_server: storace.debian.org
+
 
 # == other variables
 #####################
index bc9a925..200f4b0 100644 (file)
@@ -3,9 +3,11 @@
 # this mostly configures the file daemon, but also firewall rules and
 # fragments to sent to the other servers.
 #
+# @param storage_server The storage server to use for this client
 # @param port_fd Port that bacula-fd listens on
 # @param ensure  present or absent
 class bacula::client(
+  String $storage_server,
   Integer $port_fd = 9102,
   Enum['present', 'absent'] $ensure = defined(Class['bacula::not_a_client']) ? { true => 'absent', default => 'present' },
 ) inherits bacula {
@@ -15,7 +17,9 @@ class bacula::client(
   $reverse_ensure = $ensure ? { 'present' => 'absent', 'absent' => 'present' }
 
   if $ensure == 'present' {
-    @@bacula::storage_per_node { $::fqdn: }
+    @@bacula::storage::client { $::fqdn:
+      tag => "bacula::to-storage::${storage_server}"
+    }
 
     @@bacula::node { $::fqdn:
       port_fd => $port_fd,
index 34bd649..c2b6886 100644 (file)
@@ -1,8 +1,12 @@
 # the bacula storage node
 #
 # @param backup_path the directory where backups should be stored
+# @param filestor_device Storage device name prefix
+# @param filestor_name Storage device media type name prefix
 class bacula::storage (
-  String $backup_path = '/srv/bacula',
+  String $backup_path     = '/srv/bacula',
+  String $filestor_device = 'FileStorage',
+  String $filestor_name   = 'File',
 ) inherits bacula {
   package { 'bacula-sd':
     ensure => installed
@@ -77,5 +81,5 @@ class bacula::storage (
       | EOF
   }
 
-  Bacula::Storage_per_node<<| |>>
+  Bacula::Storage::Client<<| tag == "bacula::to-storage::${::fqdn}" |>>
 }
diff --git a/modules/bacula/manifests/storage/client.pp b/modules/bacula/manifests/storage/client.pp
new file mode 100644 (file)
index 0000000..3b03a75
--- /dev/null
@@ -0,0 +1,26 @@
+# Bacula storage configuration for a client.
+#
+# This is stored config by a client and then collected on the storage
+#
+# @param client The name of the client (relevant for device names, media type names, etc.)
+define bacula::storage::client(
+  String $client = $name
+) {
+  include bacula::storage
+
+  file {
+    "/etc/bacula/storage-conf.d/${client}.conf":
+      content => template('bacula/storage/sd-per-client.conf.erb'),
+      mode    => '0440',
+      group   => bacula,
+      notify  => Exec['bacula-sd restart-when-idle'],
+      ;
+    "${bacula::storage::backup_path}/${client}":
+      ensure => directory,
+      mode   => '0755',
+      owner  => bacula,
+      group  => bacula,
+      ;
+  }
+}
+
diff --git a/modules/bacula/manifests/storage_per_node.pp b/modules/bacula/manifests/storage_per_node.pp
deleted file mode 100644 (file)
index e6f8425..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-# bacula storage for node.  This is stored config by a client, collected on the storage
-define bacula::storage_per_node() {
-  include bacula::storage
-
-  $bacula_filestor_device = $bacula::bacula_filestor_device
-  $bacula_filestor_name   = $bacula::bacula_filestor_name
-
-  $bacula_client_name   = "${name}-fd"
-  $client               = $name
-
-  file {
-    "/etc/bacula/storage-conf.d/${name}.conf":
-      content => template('bacula/storage-per-client.conf.erb'),
-      mode    => '0440',
-      group   => bacula,
-      notify  => Exec['bacula-sd restart-when-idle'],
-      ;
-    "${bacula::storage::backup_path}/${name}":
-      ensure => directory,
-      mode   => '0755',
-      owner  => bacula,
-      group  => bacula,
-      ;
-  }
-}
-
diff --git a/modules/bacula/templates/storage-per-client.conf.erb b/modules/bacula/templates/storage-per-client.conf.erb
deleted file mode 100644 (file)
index bd7a678..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-##
-## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE.
-## USE: git clone git+ssh://$USER@puppet.debian.org/srv/puppet.debian.org/git/dsa-puppet.git
-##
-
-Device {
-  Name = "<%= @bacula_filestor_device %>-<%= @client %>"
-  Media Type = "<%= @bacula_filestor_name %>-<%= @client %>"
-  Archive Device = "<%= scope['bacula::storage::backup_path'] %>/<%= @client %>"
-  LabelMedia = yes;
-  Random Access = Yes;
-  AutomaticMount = yes;
-  RemovableMedia = no;
-  AlwaysOpen = no;
-}
diff --git a/modules/bacula/templates/storage/sd-per-client.conf.erb b/modules/bacula/templates/storage/sd-per-client.conf.erb
new file mode 100644 (file)
index 0000000..5d6c769
--- /dev/null
@@ -0,0 +1,15 @@
+##
+## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE.
+## USE: git clone git+ssh://$USER@puppet.debian.org/srv/puppet.debian.org/git/dsa-puppet.git
+##
+
+Device {
+  Name = "<%= scope['bacula::storage::filestor_device'] %>-<%= @client %>"
+  Media Type = "<%= scope['bacula::storage::filestor_name'] %>-<%= @client %>"
+  Archive Device = "<%= scope['bacula::storage::backup_path'] %>/<%= @client %>"
+  LabelMedia = yes;
+  Random Access = Yes;
+  AutomaticMount = yes;
+  RemovableMedia = no;
+  AlwaysOpen = no;
+}