Skip to content

Commit 1fc5d99

Browse files
authored
Merge pull request #482 from cirrax/dev_journal
add support for journal upload and remote server
2 parents 291b9e1 + 895a42e commit 1fc5d99

9 files changed

+311
-0
lines changed

REFERENCE.md

+76
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
* `systemd::coredump`: This class manages the systemd-coredump configuration.
1717
* `systemd::install`: Install any systemd sub packages
18+
* `systemd::journal_remote`: This class manages and configures journal-remote.
19+
* `systemd::journal_upload`: This class manages and configures journal-upload.
1820
* `systemd::journald`: This class manages and configures journald.
1921
* `systemd::logind`: This class manages systemd's login manager configuration.
2022
* `systemd::machine_info`: This class manages systemd's machine-info file (hostnamectl)
@@ -60,6 +62,8 @@
6062
* [`Systemd::Capabilities`](#Systemd--Capabilities): Defines allowed capabilities
6163
* [`Systemd::CoredumpSettings`](#Systemd--CoredumpSettings): Configurations for coredump.conf
6264
* [`Systemd::Dropin`](#Systemd--Dropin): custom datatype that validates filenames/paths for valid systemd dropin files
65+
* [`Systemd::JournalRemoteSettings`](#Systemd--JournalRemoteSettings): matches Systemd journal remote config Struct
66+
* [`Systemd::JournalUploadSettings`](#Systemd--JournalUploadSettings): matches Systemd journal upload config Struct
6367
* [`Systemd::JournaldSettings`](#Systemd--JournaldSettings): Matches Systemd journald config Struct
6468
* [`Systemd::JournaldSettings::Ensure`](#Systemd--JournaldSettings--Ensure): defines allowed ensure states for systemd-journald settings
6569
* [`Systemd::LogLevel`](#Systemd--LogLevel): Defines allowed log levels
@@ -136,6 +140,10 @@ The following parameters are available in the `systemd` class:
136140
* [`set_local_rtc`](#-systemd--set_local_rtc)
137141
* [`manage_journald`](#-systemd--manage_journald)
138142
* [`journald_settings`](#-systemd--journald_settings)
143+
* [`manage_journal_upload`](#-systemd--manage_journal_upload)
144+
* [`journal_upload_settings`](#-systemd--journal_upload_settings)
145+
* [`manage_journal_remote`](#-systemd--manage_journal_remote)
146+
* [`journal_remote_settings`](#-systemd--journal_remote_settings)
139147
* [`manage_udevd`](#-systemd--manage_udevd)
140148
* [`udev_log`](#-systemd--udev_log)
141149
* [`udev_children_max`](#-systemd--udev_children_max)
@@ -475,6 +483,38 @@ Config Hash that is used to configure settings in journald.conf
475483

476484
Default value: `{}`
477485

486+
##### <a name="-systemd--manage_journal_upload"></a>`manage_journal_upload`
487+
488+
Data type: `Boolean`
489+
490+
Manage the systemd journal upload to a remote server
491+
492+
Default value: `false`
493+
494+
##### <a name="-systemd--journal_upload_settings"></a>`journal_upload_settings`
495+
496+
Data type: `Systemd::JournalUploadSettings`
497+
498+
Config Hash that is used to configure settings in journal-upload.conf
499+
500+
Default value: `{}`
501+
502+
##### <a name="-systemd--manage_journal_remote"></a>`manage_journal_remote`
503+
504+
Data type: `Boolean`
505+
506+
Manage the systemd journal remote server used to upload journals
507+
508+
Default value: `false`
509+
510+
##### <a name="-systemd--journal_remote_settings"></a>`journal_remote_settings`
511+
512+
Data type: `Systemd::JournalRemoteSettings`
513+
514+
Config Hash that is used to configure settings in journal-remote.conf
515+
516+
Default value: `{}`
517+
478518
##### <a name="-systemd--manage_udevd"></a>`manage_udevd`
479519

480520
Data type: `Boolean`
@@ -2690,6 +2730,42 @@ custom datatype that validates filenames/paths for valid systemd dropin files
26902730

26912731
Alias of `Pattern['^[^/]+\.conf$']`
26922732

2733+
### <a name="Systemd--JournalRemoteSettings"></a>`Systemd::JournalRemoteSettings`
2734+
2735+
matches Systemd journal remote config Struct
2736+
2737+
Alias of
2738+
2739+
```puppet
2740+
Struct[{
2741+
Optional['Seal'] => Variant[Enum['yes','no'],Systemd::JournaldSettings::Ensure],
2742+
Optional['SplitMode'] => Variant[Enum['host','none'],Systemd::JournaldSettings::Ensure],
2743+
Optional['ServerKeyFile'] => Variant[Stdlib::Unixpath,Systemd::JournaldSettings::Ensure],
2744+
Optional['ServerCertificateFile'] => Variant[Stdlib::Unixpath,Systemd::JournaldSettings::Ensure],
2745+
Optional['TrustedCertificateFile'] => Variant[Stdlib::Unixpath,Systemd::JournaldSettings::Ensure],
2746+
Optional['MaxUse'] => Variant[Systemd::Unit::Amount,Systemd::JournaldSettings::Ensure],
2747+
Optional['KeepFree'] => Variant[Systemd::Unit::Amount,Systemd::JournaldSettings::Ensure],
2748+
Optional['MaxFileSize'] => Variant[Systemd::Unit::Amount,Systemd::JournaldSettings::Ensure],
2749+
Optional['MaxFiles'] => Variant[Integer,Systemd::JournaldSettings::Ensure],
2750+
}]
2751+
```
2752+
2753+
### <a name="Systemd--JournalUploadSettings"></a>`Systemd::JournalUploadSettings`
2754+
2755+
matches Systemd journal upload config Struct
2756+
2757+
Alias of
2758+
2759+
```puppet
2760+
Struct[{
2761+
Optional['URL'] => Variant[Stdlib::HTTPUrl,Systemd::JournaldSettings::Ensure],
2762+
Optional['ServerKeyFile'] => Variant[Stdlib::Unixpath,Systemd::JournaldSettings::Ensure],
2763+
Optional['ServerCertificateFile'] => Variant[Stdlib::Unixpath,Systemd::JournaldSettings::Ensure],
2764+
Optional['TrustedCertificateFile'] => Variant[Stdlib::Unixpath,Systemd::JournaldSettings::Ensure],
2765+
Optional['NetworkTimeoutSec'] => Variant[Systemd::Unit::Timespan,Systemd::JournaldSettings::Ensure],
2766+
}]
2767+
```
2768+
26932769
### <a name="Systemd--JournaldSettings"></a>`Systemd::JournaldSettings`
26942770

26952771
Matches Systemd journald config Struct

data/Debian-family.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
---
22
systemd::nspawn_package: 'systemd-container'
3+
systemd::journal_upload::package_name: 'systemd-journal-remote'
4+
systemd::journal_remote::package_name: 'systemd-journal-remote'

data/RedHat-family.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
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'
6+
systemd::journal_remote::package_name: 'systemd-journal-remote'

manifests/init.pp

+24
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,18 @@
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+
#
141+
# @param manage_journal_remote
142+
# Manage the systemd journal remote server used to upload journals
143+
#
144+
# @param journal_remote_settings
145+
# Config Hash that is used to configure settings in journal-remote.conf
146+
#
135147
# @param manage_udevd
136148
# Manage the systemd udev daemon
137149
#
@@ -275,6 +287,10 @@
275287
Boolean $purge_dropin_dirs = true,
276288
Boolean $manage_journald = true,
277289
Systemd::JournaldSettings $journald_settings = {},
290+
Boolean $manage_journal_upload = false,
291+
Systemd::JournalUploadSettings $journal_upload_settings = {},
292+
Boolean $manage_journal_remote = false,
293+
Systemd::JournalRemoteSettings $journal_remote_settings = {},
278294
Systemd::MachineInfoSettings $machine_info_settings = {},
279295
Boolean $manage_udevd = false,
280296
Optional[Variant[Integer,String]] $udev_log = undef,
@@ -383,6 +399,14 @@
383399
contain systemd::journald
384400
}
385401

402+
if $manage_journal_upload {
403+
contain systemd::journal_upload
404+
}
405+
406+
if $manage_journal_remote {
407+
contain systemd::journal_remote
408+
}
409+
386410
if $manage_logind {
387411
contain systemd::logind
388412
}

manifests/journal_remote.pp

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# @api private
2+
# @summary This class manages and configures journal-remote.
3+
# @see https://www.freedesktop.org/software/systemd/man/journal-remote.conf.html
4+
#
5+
# @param package_name
6+
# name of the package to install for the functionality
7+
#
8+
class systemd::journal_remote (
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-remote':
18+
ensure => running,
19+
enable => true,
20+
}
21+
$systemd::journal_remote_settings.each |$option, $value| {
22+
ini_setting { "journal-remote_${option}":
23+
path => '/etc/systemd/journal-remote.conf',
24+
section => 'Remote',
25+
setting => $option,
26+
notify => Service['systemd-journal-remote'],
27+
}
28+
if $value =~ Systemd::JournaldSettings::Ensure {
29+
Ini_setting["journal-remote_${option}"] {
30+
* => $value,
31+
}
32+
} else {
33+
Ini_setting["journal-remote_${option}"] {
34+
value => $value,
35+
}
36+
}
37+
}
38+
}

manifests/journal_upload.pp

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
# @param service_ensure
9+
# what we ensure for the service
10+
#
11+
# @param service_enable
12+
# to enable the service
13+
#
14+
class systemd::journal_upload (
15+
Optional[String[1]] $package_name = undef,
16+
Enum['running','stopped'] $service_ensure = 'running',
17+
Boolean $service_enable = true,
18+
) {
19+
assert_private()
20+
21+
if $package_name {
22+
stdlib::ensure_packages($package_name)
23+
}
24+
25+
service { 'systemd-journal-upload':
26+
ensure => $service_ensure,
27+
enable => $service_enable,
28+
}
29+
$systemd::journal_upload_settings.each |$option, $value| {
30+
ini_setting { "journal-upload_${option}":
31+
path => '/etc/systemd/journal-upload.conf',
32+
section => 'Upload',
33+
setting => $option,
34+
notify => Service['systemd-journal-upload'],
35+
}
36+
if $value =~ Systemd::JournaldSettings::Ensure {
37+
Ini_setting["journal-upload_${option}"] {
38+
* => $value,
39+
}
40+
} else {
41+
Ini_setting["journal-upload_${option}"] {
42+
value => $value,
43+
}
44+
}
45+
}
46+
}

spec/classes/init_spec.rb

+95
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,101 @@
675675
it { is_expected.not_to contain_service('systemd-journald') }
676676
end
677677

678+
context 'when journal-upload and journal-remote is enabled' do
679+
let(:params) do
680+
{
681+
manage_journal_upload: true,
682+
journal_upload_settings: {
683+
'URL' => 'https://central.server:19532',
684+
'ServerKeyFile' => '/tmp/key-upload.pem',
685+
'ServerCertificateFile' => {
686+
'ensure' => 'absent',
687+
},
688+
'TrustedCertificateFile' => '/tmp/cert-upload.pem',
689+
},
690+
manage_journal_remote: true,
691+
journal_remote_settings: {
692+
'SplitMode' => 'host',
693+
'ServerKeyFile' => '/tmp/key-remote.pem',
694+
'ServerCertificateFile' => '/tmp/cert-remote.pem',
695+
'TrustedCertificateFile' => {
696+
'ensure' => 'absent',
697+
},
698+
},
699+
}
700+
end
701+
702+
it { is_expected.to compile.with_all_deps }
703+
704+
it {
705+
is_expected.to contain_service('systemd-journal-upload').with(
706+
ensure: 'running',
707+
enable: true
708+
)
709+
}
710+
711+
it {
712+
is_expected.to contain_service('systemd-journal-remote').with(
713+
ensure: 'running'
714+
)
715+
}
716+
717+
it { is_expected.to have_ini_setting_resource_count(8) }
718+
719+
it {
720+
expect(subject).to contain_ini_setting('journal-upload_TrustedCertificateFile').with(
721+
path: '/etc/systemd/journal-upload.conf',
722+
section: 'Upload',
723+
setting: 'TrustedCertificateFile',
724+
notify: 'Service[systemd-journal-upload]',
725+
value: '/tmp/cert-upload.pem'
726+
)
727+
}
728+
729+
it {
730+
expect(subject).to contain_ini_setting('journal-remote_TrustedCertificateFile').with(
731+
path: '/etc/systemd/journal-remote.conf',
732+
section: 'Remote',
733+
setting: 'TrustedCertificateFile',
734+
notify: 'Service[systemd-journal-remote]',
735+
ensure: 'absent'
736+
)
737+
}
738+
739+
it {
740+
expect(subject).to contain_ini_setting('journal-upload_ServerCertificateFile').with(
741+
path: '/etc/systemd/journal-upload.conf',
742+
section: 'Upload',
743+
setting: 'ServerCertificateFile',
744+
notify: 'Service[systemd-journal-upload]',
745+
ensure: 'absent'
746+
)
747+
}
748+
749+
it {
750+
expect(subject).to contain_ini_setting('journal-remote_ServerCertificateFile').with(
751+
path: '/etc/systemd/journal-remote.conf',
752+
section: 'Remote',
753+
setting: 'ServerCertificateFile',
754+
notify: 'Service[systemd-journal-remote]',
755+
value: '/tmp/cert-remote.pem'
756+
)
757+
}
758+
end
759+
760+
context 'when journal-upload/journal-remote is not enabled' do
761+
let(:params) do
762+
{
763+
manage_journal_upload: false,
764+
manage_journal_remote: false,
765+
}
766+
end
767+
768+
it { is_expected.to compile.with_all_deps }
769+
it { is_expected.not_to contain_service('systemd-journal-upload') }
770+
it { is_expected.not_to contain_service('systemd-journal-remote') }
771+
end
772+
678773
context 'when disabling udevd management' do
679774
let(:params) do
680775
{

types/journalremotesettings.pp

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# @summary matches Systemd journal remote config Struct
2+
type Systemd::JournalRemoteSettings = Struct[
3+
# lint:ignore:140chars
4+
{
5+
Optional['Seal'] => Variant[Enum['yes','no'],Systemd::JournaldSettings::Ensure],
6+
Optional['SplitMode'] => Variant[Enum['host','none'],Systemd::JournaldSettings::Ensure],
7+
Optional['ServerKeyFile'] => Variant[Stdlib::Unixpath,Systemd::JournaldSettings::Ensure],
8+
Optional['ServerCertificateFile'] => Variant[Stdlib::Unixpath,Systemd::JournaldSettings::Ensure],
9+
Optional['TrustedCertificateFile'] => Variant[Stdlib::Unixpath,Systemd::JournaldSettings::Ensure],
10+
Optional['MaxUse'] => Variant[Systemd::Unit::Amount,Systemd::JournaldSettings::Ensure],
11+
Optional['KeepFree'] => Variant[Systemd::Unit::Amount,Systemd::JournaldSettings::Ensure],
12+
Optional['MaxFileSize'] => Variant[Systemd::Unit::Amount,Systemd::JournaldSettings::Ensure],
13+
Optional['MaxFiles'] => Variant[Integer,Systemd::JournaldSettings::Ensure],
14+
}
15+
# lint:endignore
16+
]

types/journaluploadsettings.pp

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# @summary 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)