From e09b1d7607ce74df99e1324e405c2877d09bee79 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Tue, 24 Sep 2019 15:31:03 +0200 Subject: [PATCH] Move filestore device and media type name to the storage, part I 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 | 2 ++ modules/bacula/manifests/client.pp | 6 ++++- modules/bacula/manifests/storage.pp | 8 ++++-- modules/bacula/manifests/storage/client.pp | 26 +++++++++++++++++++ modules/bacula/manifests/storage_per_node.pp | 26 ------------------- .../sd-per-client.conf.erb} | 4 +-- 6 files changed, 41 insertions(+), 31 deletions(-) create mode 100644 modules/bacula/manifests/storage/client.pp delete mode 100644 modules/bacula/manifests/storage_per_node.pp rename modules/bacula/templates/{storage-per-client.conf.erb => storage/sd-per-client.conf.erb} (69%) diff --git a/data/common.yaml b/data/common.yaml index ff5efc0fe..4cd0c195d 100644 --- a/data/common.yaml +++ b/data/common.yaml @@ -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 ##################### diff --git a/modules/bacula/manifests/client.pp b/modules/bacula/manifests/client.pp index bc9a9253a..200f4b01b 100644 --- a/modules/bacula/manifests/client.pp +++ b/modules/bacula/manifests/client.pp @@ -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, diff --git a/modules/bacula/manifests/storage.pp b/modules/bacula/manifests/storage.pp index 34bd6491b..c2b6886d9 100644 --- a/modules/bacula/manifests/storage.pp +++ b/modules/bacula/manifests/storage.pp @@ -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 index 000000000..3b03a7598 --- /dev/null +++ b/modules/bacula/manifests/storage/client.pp @@ -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 index e6f842582..000000000 --- a/modules/bacula/manifests/storage_per_node.pp +++ /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/sd-per-client.conf.erb similarity index 69% rename from modules/bacula/templates/storage-per-client.conf.erb rename to modules/bacula/templates/storage/sd-per-client.conf.erb index bd7a6781d..5d6c769f9 100644 --- a/modules/bacula/templates/storage-per-client.conf.erb +++ b/modules/bacula/templates/storage/sd-per-client.conf.erb @@ -4,8 +4,8 @@ ## Device { - Name = "<%= @bacula_filestor_device %>-<%= @client %>" - Media Type = "<%= @bacula_filestor_name %>-<%= @client %>" + 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; -- 2.20.1