From 79eaa5fac5e56512b759061c7c2ff3ae285ae530 Mon Sep 17 00:00:00 2001 From: Michael Reichel Date: Mon, 30 Sep 2024 15:48:14 +0200 Subject: [PATCH 1/4] feat: add message parameter for client config --- REFERENCE.md | 16 ++++++++++++++++ manifests/client.pp | 18 ++++++++++++------ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index cea8beaf..f5e24823 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -262,6 +262,7 @@ class { 'bacula::client': director_name => 'mydirector.example.com' } The following parameters are available in the `bacula::client` class: +* [`messages`](#-bacula--client--messages) * [`packages`](#-bacula--client--packages) * [`services`](#-bacula--client--services) * [`default_pool`](#-bacula--client--default_pool) @@ -272,6 +273,7 @@ The following parameters are available in the `bacula::client` class: * [`listen_address`](#-bacula--client--listen_address) * [`password`](#-bacula--client--password) * [`max_concurrent_jobs`](#-bacula--client--max_concurrent_jobs) +* [`manage_defaults`](#-bacula--client--manage_defaults) * [`director_name`](#-bacula--client--director_name) * [`autoprune`](#-bacula--client--autoprune) * [`file_retention`](#-bacula--client--file_retention) @@ -284,6 +286,12 @@ The following parameters are available in the `bacula::client` class: * [`pki_master_key`](#-bacula--client--pki_master_key) * [`plugin_dir`](#-bacula--client--plugin_dir) +##### `messages` + +Data type: `Hash[String, Bacula::Message]` + +Logging configuration; loaded from hiera + ##### `packages` Data type: `Array[String]` @@ -375,6 +383,14 @@ Bacula FD option for 'Maximum Concurrent Jobs' Default value: `2` +##### `manage_defaults` + +Data type: `Boolean` + +Setup default message type + +Default value: `true` + ##### `director_name` Data type: `String` diff --git a/manifests/client.pp b/manifests/client.pp index dcaf1cbe..cd4ea8d7 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -2,6 +2,7 @@ # # This class installs and configures the File Daemon to backup a client system. # +# @param messages Logging configuration; loaded from hiera # @param packages A list of packages to install; loaded from hiera # @param services A list of services to operate; loaded from hiera # @param default_pool The name of the Pool for this FD to use by default @@ -35,6 +36,7 @@ # Bacula being unable to bind twice to the IPv4 address and fail to start. # @param password A password to use for communication with this File Daemon # @param max_concurrent_jobs Bacula FD option for 'Maximum Concurrent Jobs' +# @param manage_defaults Setup default message type # @param director_name The hostname of the director for this FD # @param autoprune Bacula FD option for 'AutoPrune' # @param file_retention Bacula FD option for 'File Retention' @@ -51,6 +53,7 @@ # class { 'bacula::client': director_name => 'mydirector.example.com' } # class bacula::client ( + Hash[String, Bacula::Message] $messages, Array[String] $packages, String $services, String $default_pool, @@ -67,12 +70,20 @@ Bacula::Time $job_retention = '6 months', String $client = $trusted['certname'], String $address = $facts['networking']['fqdn'], + Boolean $manage_defaults = true, Optional[Bacula::Yesno] $pki_signatures = undef, Optional[Bacula::Yesno] $pki_encryption = undef, Optional[String] $pki_keypair = undef, Optional[String] $pki_master_key = undef, Optional[String] $plugin_dir = undef, ) inherits bacula { + if $manage_defaults { + bacula::messages { 'Standard-fd': + daemon => 'fd', + director => "${director_name}-dir = all, !skipped, !restored", + append => '"/var/log/bacula/bacula-fd.log" = all, !skipped', + } + } $group = $bacula::bacula_group $conf_dir = $bacula::conf_dir $config_file = "${conf_dir}/bacula-fd.conf" @@ -103,12 +114,7 @@ content => epp('bacula/bacula-fd-header.epp'), } - bacula::messages { 'Standard-fd': - daemon => 'fd', - director => "${director_name}-dir = all, !skipped, !restored", - append => '"/var/log/bacula/bacula-fd.log" = all, !skipped', - } - + create_resources(bacula::messages, $messages) # Tell the director about this client config @@bacula::director::client { $client: address => $address, From 4531492807cbf362e0fa1210b53af298e666bfa9 Mon Sep 17 00:00:00 2001 From: Michael Reichel Date: Mon, 30 Sep 2024 15:49:18 +0200 Subject: [PATCH 2/4] fix: correcting indentation --- types/message.pp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/types/message.pp b/types/message.pp index 942eb7e1..b908816e 100644 --- a/types/message.pp +++ b/types/message.pp @@ -1,18 +1,18 @@ # A Bacula message specification type Bacula::Message = Struct[{ - mname => String, - append => Optional[String], - catalog => Optional[String], - console => Optional[String], - daemon => Optional[String], - director => Optional[String], - mail => Optional[String], - mailcmd => Optional[String], - mailonsuccess => Optional[String], - mailonsuccesscmd => Optional[String], - mailonerror => Optional[String], - mailonerrorcmd => Optional[String], - operator => Optional[String], - operatorcmd => Optional[String], - syslog => Optional[String], + mname => String, + append => Optional[String], + catalog => Optional[String], + console => Optional[String], + daemon => Optional[String], + director => Optional[String], + mail => Optional[String], + mailcmd => Optional[String], + mailonsuccess => Optional[String], + mailonsuccesscmd => Optional[String], + mailonerror => Optional[String], + mailonerrorcmd => Optional[String], + operator => Optional[String], + operatorcmd => Optional[String], + syslog => Optional[String], }] From 2f8fc7e8011f677cad620b401be51cf002d4cb3b Mon Sep 17 00:00:00 2001 From: Michael Reichel Date: Tue, 1 Oct 2024 10:31:00 +0200 Subject: [PATCH 3/4] enhancement: add bacula:client:messages type --- REFERENCE.md | 34 ++++++++++++++---------------- data/common.yaml | 6 ++++++ manifests/client.pp | 50 +++++++++++++++++++-------------------------- 3 files changed, 42 insertions(+), 48 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index f5e24823..8168b890 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -385,12 +385,8 @@ Default value: `2` ##### `manage_defaults` -Data type: `Boolean` - Setup default message type -Default value: `true` - ##### `director_name` Data type: `String` @@ -2194,21 +2190,21 @@ Alias of ```puppet Struct[{ - mname => String, - append => Optional[String], - catalog => Optional[String], - console => Optional[String], - daemon => Optional[String], - director => Optional[String], - mail => Optional[String], - mailcmd => Optional[String], - mailonsuccess => Optional[String], - mailonsuccesscmd => Optional[String], - mailonerror => Optional[String], - mailonerrorcmd => Optional[String], - operator => Optional[String], - operatorcmd => Optional[String], - syslog => Optional[String], + mname => String, + append => Optional[String], + catalog => Optional[String], + console => Optional[String], + daemon => Optional[String], + director => Optional[String], + mail => Optional[String], + mailcmd => Optional[String], + mailonsuccess => Optional[String], + mailonsuccesscmd => Optional[String], + mailonerror => Optional[String], + mailonerrorcmd => Optional[String], + operator => Optional[String], + operatorcmd => Optional[String], + syslog => Optional[String], }] ``` diff --git a/data/common.yaml b/data/common.yaml index d33583c5..ed027ac7 100644 --- a/data/common.yaml +++ b/data/common.yaml @@ -9,6 +9,12 @@ bacula::director::messages: console: 'all, !skipped, !saved' append: '"/var/log/bacula/bacula-dir.log" = all, !skipped' catalog: 'all' +bacula::client::messages: + Standard-fd: + daemon: 'fd' + mname: 'Standard' + director: "${director_name}-dir = all, !skipped, !restored" + append: '"/var/log/bacula/bacula-fd.log" = all, !skipped' bacula::director::packages: [] bacula::storage::services: 'bacula-sd' diff --git a/manifests/client.pp b/manifests/client.pp index cd4ea8d7..fe287fc3 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -54,36 +54,28 @@ # class bacula::client ( Hash[String, Bacula::Message] $messages, - Array[String] $packages, - String $services, - String $default_pool, - Optional[String] $default_pool_full, - Optional[String] $default_pool_inc, - Optional[String] $default_pool_diff, - Integer $port = 9102, - Array[String[1]] $listen_address = [], - String $password = 'secret', - Integer $max_concurrent_jobs = 2, - String $director_name = $bacula::director_name, - Bacula::Yesno $autoprune = true, - Bacula::Time $file_retention = '45 days', - Bacula::Time $job_retention = '6 months', - String $client = $trusted['certname'], - String $address = $facts['networking']['fqdn'], - Boolean $manage_defaults = true, - Optional[Bacula::Yesno] $pki_signatures = undef, - Optional[Bacula::Yesno] $pki_encryption = undef, - Optional[String] $pki_keypair = undef, - Optional[String] $pki_master_key = undef, - Optional[String] $plugin_dir = undef, + Array[String] $packages, + String $services, + String $default_pool, + Optional[String] $default_pool_full, + Optional[String] $default_pool_inc, + Optional[String] $default_pool_diff, + Integer $port = 9102, + Array[String[1]] $listen_address = [], + String $password = 'secret', + Integer $max_concurrent_jobs = 2, + String $director_name = $bacula::director_name, + Bacula::Yesno $autoprune = true, + Bacula::Time $file_retention = '45 days', + Bacula::Time $job_retention = '6 months', + String $client = $trusted['certname'], + String $address = $facts['networking']['fqdn'], + Optional[Bacula::Yesno] $pki_signatures = undef, + Optional[Bacula::Yesno] $pki_encryption = undef, + Optional[String] $pki_keypair = undef, + Optional[String] $pki_master_key = undef, + Optional[String] $plugin_dir = undef, ) inherits bacula { - if $manage_defaults { - bacula::messages { 'Standard-fd': - daemon => 'fd', - director => "${director_name}-dir = all, !skipped, !restored", - append => '"/var/log/bacula/bacula-fd.log" = all, !skipped', - } - } $group = $bacula::bacula_group $conf_dir = $bacula::conf_dir $config_file = "${conf_dir}/bacula-fd.conf" From 5467ee234232c8b8d117091526d787c0611df6cb Mon Sep 17 00:00:00 2001 From: Michael Reichel Date: Wed, 2 Oct 2024 13:34:27 +0200 Subject: [PATCH 4/4] fix: director name assignment with hiera lookup and add documentation --- .github/CONTRIBUTING.md | 5 +++++ README.md | 15 +++++++++++++++ REFERENCE.md | 5 ----- data/common.yaml | 2 +- manifests/client.pp | 1 - 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 8b466cfb..651e6793 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -181,6 +181,11 @@ against it. You can run those locally ahead of time with: bundle exec rake rubocop ``` +Or if you want to run them all together at once: +```sh +bundle exec rake strings:generate:reference && bundle exec rake lint && bundle exec rake validate && bundle exec rake rubocop +``` + ### Running the unit tests The unit test suite covers most of the code, as mentioned above please diff --git a/README.md b/README.md index 5e8c8774..e37212c8 100644 --- a/README.md +++ b/README.md @@ -180,6 +180,21 @@ class { 'bacula::client': } ``` +To exclude Info messages from the logfile. + +```puppet +class { 'bacula::client': + messages => { + 'Standard-fd' => { + daemon => 'fd', + mname => 'Standard', + director => "${director}-dir = all, !skipped, !restored", + append => '"/var/log/bacula/bacula-fd.log" = all, !info, !skipped', + }, + }, +} +``` + #### Data Encryption (PKI Setup) Refer to the [PKI diff --git a/REFERENCE.md b/REFERENCE.md index 8168b890..bd7db928 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -273,7 +273,6 @@ The following parameters are available in the `bacula::client` class: * [`listen_address`](#-bacula--client--listen_address) * [`password`](#-bacula--client--password) * [`max_concurrent_jobs`](#-bacula--client--max_concurrent_jobs) -* [`manage_defaults`](#-bacula--client--manage_defaults) * [`director_name`](#-bacula--client--director_name) * [`autoprune`](#-bacula--client--autoprune) * [`file_retention`](#-bacula--client--file_retention) @@ -383,10 +382,6 @@ Bacula FD option for 'Maximum Concurrent Jobs' Default value: `2` -##### `manage_defaults` - -Setup default message type - ##### `director_name` Data type: `String` diff --git a/data/common.yaml b/data/common.yaml index ed027ac7..96f8842a 100644 --- a/data/common.yaml +++ b/data/common.yaml @@ -13,7 +13,7 @@ bacula::client::messages: Standard-fd: daemon: 'fd' mname: 'Standard' - director: "${director_name}-dir = all, !skipped, !restored" + director: "%{trusted.certname}-dir = all, !skipped, !restored" append: '"/var/log/bacula/bacula-fd.log" = all, !skipped' bacula::director::packages: [] diff --git a/manifests/client.pp b/manifests/client.pp index fe287fc3..5418a74e 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -36,7 +36,6 @@ # Bacula being unable to bind twice to the IPv4 address and fail to start. # @param password A password to use for communication with this File Daemon # @param max_concurrent_jobs Bacula FD option for 'Maximum Concurrent Jobs' -# @param manage_defaults Setup default message type # @param director_name The hostname of the director for this FD # @param autoprune Bacula FD option for 'AutoPrune' # @param file_retention Bacula FD option for 'File Retention'