Skip to content

Commit 30089e6

Browse files
committed
add support for journal upload to a remote server
1 parent 7e2e187 commit 30089e6

File tree

7 files changed

+149
-0
lines changed

7 files changed

+149
-0
lines changed

REFERENCE.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
* `systemd::coredump`: This class manages the systemd-coredump configuration.
1717
* `systemd::install`: Install any systemd sub packages
18+
* `systemd::journal_upload`: This class manages and configures journal-upload.
1819
* `systemd::journald`: This class manages and configures journald.
1920
* `systemd::logind`: This class manages systemd's login manager configuration.
2021
* `systemd::machine_info`: This class manages systemd's machine-info file (hostnamectl)
@@ -56,6 +57,7 @@
5657

5758
* [`Systemd::CoredumpSettings`](#Systemd--CoredumpSettings): Configurations for coredump.conf
5859
* [`Systemd::Dropin`](#Systemd--Dropin): custom datatype that validates filenames/paths for valid systemd dropin files
60+
* [`Systemd::JournalUploadSettings`](#Systemd--JournalUploadSettings): Matches Systemd journal upload config Struct
5961
* [`Systemd::JournaldSettings`](#Systemd--JournaldSettings): Matches Systemd journald config Struct
6062
* [`Systemd::JournaldSettings::Ensure`](#Systemd--JournaldSettings--Ensure): defines allowed ensure states for systemd-journald settings
6163
* [`Systemd::LogindSettings`](#Systemd--LogindSettings): Matches Systemd Login Manager Struct
@@ -126,6 +128,8 @@ The following parameters are available in the `systemd` class:
126128
* [`set_local_rtc`](#-systemd--set_local_rtc)
127129
* [`manage_journald`](#-systemd--manage_journald)
128130
* [`journald_settings`](#-systemd--journald_settings)
131+
* [`manage_journal_upload`](#-systemd--manage_journal_upload)
132+
* [`journal_upload_settings`](#-systemd--journal_upload_settings)
129133
* [`manage_udevd`](#-systemd--manage_udevd)
130134
* [`udev_log`](#-systemd--udev_log)
131135
* [`udev_children_max`](#-systemd--udev_children_max)
@@ -460,6 +464,22 @@ Config Hash that is used to configure settings in journald.conf
460464

461465
Default value: `{}`
462466

467+
##### <a name="-systemd--manage_journal_upload"></a>`manage_journal_upload`
468+
469+
Data type: `Boolean`
470+
471+
Manage the systemd journal upload to a remote server
472+
473+
Default value: `false`
474+
475+
##### <a name="-systemd--journal_upload_settings"></a>`journal_upload_settings`
476+
477+
Data type: `Systemd::JournalUploadSettings`
478+
479+
Config Hash that is used to configure settings in journal-upload.conf
480+
481+
Default value: `{}`
482+
463483
##### <a name="-systemd--manage_udevd"></a>`manage_udevd`
464484

465485
Data type: `Boolean`
@@ -2562,6 +2582,22 @@ custom datatype that validates filenames/paths for valid systemd dropin files
25622582

25632583
Alias of `Pattern['^[^/]+\.conf$']`
25642584

2585+
### <a name="Systemd--JournalUploadSettings"></a>`Systemd::JournalUploadSettings`
2586+
2587+
Matches Systemd journal upload config Struct
2588+
2589+
Alias of
2590+
2591+
```puppet
2592+
Struct[{
2593+
Optional['URL'] => Variant[Stdlib::HTTPUrl,Systemd::JournaldSettings::Ensure],
2594+
Optional['ServerKeyFile'] => Variant[Stdlib::Unixpath,Systemd::JournaldSettings::Ensure],
2595+
Optional['ServerCertificateFile'] => Variant[Stdlib::Unixpath,Systemd::JournaldSettings::Ensure],
2596+
Optional['TrustedCertificateFile'] => Variant[Stdlib::Unixpath,Systemd::JournaldSettings::Ensure],
2597+
Optional['NetworkTimeoutSec'] => Variant[Systemd::Unit::Timespan,Systemd::JournaldSettings::Ensure],
2598+
}]
2599+
```
2600+
25652601
### <a name="Systemd--JournaldSettings"></a>`Systemd::JournaldSettings`
25662602

25672603
Matches Systemd journald config Struct

data/Debian-family.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
---
22
systemd::nspawn_package: 'systemd-container'
3+
systemd::journal_upload::package_name: 'systemd-journal-remote'

data/RedHat-family.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
systemd::networkd_package: systemd-networkd
33
systemd::nspawn_package: 'systemd-container'
44
systemd::resolved_package: 'systemd-resolved'
5+
systemd::journal_upload::package_name: 'systemd-journal-remote'

manifests/init.pp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@
132132
# @param journald_settings
133133
# Config Hash that is used to configure settings in journald.conf
134134
#
135+
# @param manage_journal_upload
136+
# Manage the systemd journal upload to a remote server
137+
#
138+
# @param journal_upload_settings
139+
# Config Hash that is used to configure settings in journal-upload.conf
140+
#
135141
# @param manage_udevd
136142
# Manage the systemd udev daemon
137143
#
@@ -253,6 +259,8 @@
253259
Boolean $purge_dropin_dirs = true,
254260
Boolean $manage_journald = true,
255261
Systemd::JournaldSettings $journald_settings = {},
262+
Boolean $manage_journal_upload = false,
263+
Systemd::JournalUploadSettings $journal_upload_settings = {},
256264
Systemd::MachineInfoSettings $machine_info_settings = {},
257265
Boolean $manage_udevd = false,
258266
Optional[Variant[Integer,String]] $udev_log = undef,
@@ -355,6 +363,10 @@
355363
contain systemd::journald
356364
}
357365

366+
if $manage_journal_upload {
367+
contain systemd::journal_upload
368+
}
369+
358370
if $manage_logind {
359371
contain systemd::logind
360372
}

manifests/journal_upload.pp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# @api private
2+
# @summary This class manages and configures journal-upload.
3+
# @see https://www.freedesktop.org/software/systemd/man/journald.conf.html
4+
#
5+
# @param package_name
6+
# name of the package to install for the functionality
7+
#
8+
class systemd::journal_upload (
9+
Optional[String[1]] $package_name = undef,
10+
) {
11+
assert_private()
12+
13+
if $package_name {
14+
stdlib::ensure_packages($package_name)
15+
}
16+
17+
service { 'systemd-journal-upload':
18+
ensure => running,
19+
}
20+
$systemd::journal_upload_settings.each |$option, $value| {
21+
ini_setting { $option:
22+
path => '/etc/systemd/journal-upload.conf',
23+
section => 'Upload',
24+
setting => $option,
25+
notify => Service['systemd-journal-upload'],
26+
}
27+
if $value =~ Hash {
28+
Ini_setting[$option] {
29+
* => $value,
30+
}
31+
} else {
32+
Ini_setting[$option] {
33+
value => $value,
34+
}
35+
}
36+
}
37+
}

spec/classes/init_spec.rb

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,56 @@
587587
it { is_expected.not_to contain_service('systemd-journald') }
588588
end
589589

590+
context 'when journal-upload is enabled' do
591+
let(:params) do
592+
{
593+
manage_journal_upload: true,
594+
journal_upload_settings: {
595+
'URL' => 'https://central.server:19532',
596+
'ServerKeyFile' => '/tmp/key.pem',
597+
'ServerCertificateFile' => '/tmp/cert.pem',
598+
'TrustedCertificateFile' => {
599+
'ensure' => 'absent',
600+
},
601+
},
602+
}
603+
end
604+
605+
it { is_expected.to compile.with_all_deps }
606+
it { is_expected.to contain_service('systemd-journal-upload') }
607+
608+
it { is_expected.to have_ini_setting_resource_count(4) }
609+
610+
it {
611+
expect(subject).to contain_ini_setting('URL').with(
612+
path: '/etc/systemd/journal-upload.conf',
613+
section: 'Upload',
614+
notify: 'Service[systemd-journal-upload]',
615+
value: 'https://central.server:19532'
616+
)
617+
}
618+
619+
it {
620+
expect(subject).to contain_ini_setting('TrustedCertificateFile').with(
621+
path: '/etc/systemd/journal-upload.conf',
622+
section: 'Upload',
623+
notify: 'Service[systemd-journal-upload]',
624+
ensure: 'absent'
625+
)
626+
}
627+
end
628+
629+
context 'when journal-upload is not enabled' do
630+
let(:params) do
631+
{
632+
manage_journal_upload: false,
633+
}
634+
end
635+
636+
it { is_expected.to compile.with_all_deps }
637+
it { is_expected.not_to contain_service('systemd-journal-upload') }
638+
end
639+
590640
context 'when disabling udevd management' do
591641
let(:params) do
592642
{

types/journaluploadsettings.pp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Matches Systemd journal upload config Struct
2+
type Systemd::JournalUploadSettings = Struct[
3+
# lint:ignore:140chars
4+
{
5+
Optional['URL'] => Variant[Stdlib::HTTPUrl,Systemd::JournaldSettings::Ensure],
6+
Optional['ServerKeyFile'] => Variant[Stdlib::Unixpath,Systemd::JournaldSettings::Ensure],
7+
Optional['ServerCertificateFile'] => Variant[Stdlib::Unixpath,Systemd::JournaldSettings::Ensure],
8+
Optional['TrustedCertificateFile'] => Variant[Stdlib::Unixpath,Systemd::JournaldSettings::Ensure],
9+
Optional['NetworkTimeoutSec'] => Variant[Systemd::Unit::Timespan,Systemd::JournaldSettings::Ensure],
10+
}
11+
# lint:endignore
12+
]

0 commit comments

Comments
 (0)