From: Peter Palfrader Date: Tue, 24 Sep 2019 13:31:03 +0000 (+0200) Subject: Move filestore device and media type name to the storage, part I X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=e09b1d7607ce74df99e1324e405c2877d09bee79;p=mirror%2Fdsa-puppet.git 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. --- 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-per-client.conf.erb deleted file mode 100644 index bd7a6781d..000000000 --- a/modules/bacula/templates/storage-per-client.conf.erb +++ /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 index 000000000..5d6c769f9 --- /dev/null +++ b/modules/bacula/templates/storage/sd-per-client.conf.erb @@ -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; +}