Skip to content

Commit

Permalink
Merge pull request #219 from babiel/mir_bacula-fd_messages_contrib
Browse files Browse the repository at this point in the history
Adding an option for the bacula file daemon to support custom message types
  • Loading branch information
smortex authored Jan 7, 2025
2 parents bdbf875 + 5467ee2 commit 662d553
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 57 deletions.
5 changes: 5 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,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
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 22 additions & 15 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -284,6 +285,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)

##### <a name="-bacula--client--messages"></a>`messages`

Data type: `Hash[String, Bacula::Message]`

Logging configuration; loaded from hiera

##### <a name="-bacula--client--packages"></a>`packages`

Data type: `Array[String]`
Expand Down Expand Up @@ -2178,21 +2185,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],
}]
```

Expand Down
6 changes: 6 additions & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: "%{trusted.certname}-dir = all, !skipped, !restored"
append: '"/var/log/bacula/bacula-fd.log" = all, !skipped'
bacula::director::packages: []

bacula::storage::services: 'bacula-sd'
Expand Down
51 changes: 24 additions & 27 deletions manifests/client.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -51,27 +52,28 @@
# class { 'bacula::client': director_name => 'mydirector.example.com' }
#
class bacula::client (
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,
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'],
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 {
$group = $bacula::bacula_group
$conf_dir = $bacula::conf_dir
Expand Down Expand Up @@ -103,12 +105,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,
Expand Down
30 changes: 15 additions & 15 deletions types/message.pp
Original file line number Diff line number Diff line change
@@ -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],
}]

0 comments on commit 662d553

Please sign in to comment.