Skip to content

Commit

Permalink
Manage journald service and configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
treydock committed Oct 17, 2018
1 parent 1a8d586 commit 085b016
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
2 changes: 2 additions & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ systemd::ntp_server: ~
systemd::fallback_ntp_server: ~
systemd::manage_accounting: false
systemd::accounting: {}
systemd::manage_journald: false
systemd::journald_config: {}
13 changes: 13 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@
# A space-separated list of NTP server host names or IP addresses to be used
# as the fallback NTP servers. Any per-interface NTP servers obtained from
# systemd-networkd take precedence over this setting. requires puppetlabs-inifile
#
# @param manage_journald
# Managed the systemd journald daemon and config
#
# @param journald_config
# Config Hash that is used to configure settings in journald.conf
#
class systemd (
Hash[String,Hash[String, Any]] $service_limits,
Boolean $manage_resolved,
Expand All @@ -90,6 +97,8 @@
Optional[Variant[Array,String]] $fallback_ntp_server,
Boolean $manage_accounting,
Hash[String,String] $accounting,
Boolean $manage_journald,
Hash[String, String] $journald_config,
){

contain systemd::systemctl::daemon_reload
Expand All @@ -111,4 +120,8 @@
if $manage_accounting {
contain systemd::system
}

if $manage_journald {
contain systemd::journald
}
}
23 changes: 23 additions & 0 deletions manifests/journald.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# **NOTE: THIS IS A [PRIVATE](https://github.com/puppetlabs/puppetlabs-stdlib#assert_private) CLASS**
#
# This class provides a solution to managed journald
#
class systemd::journald {

assert_private()

$systemd::journald_config.each |$option, $value| {
ini_setting{ $option:
ensure => 'present',
path => '/etc/systemd/journald.conf',
section => 'Journal',
setting => $option,
value => $value,
notify => Service['systemd-journald'],
}
}

service { 'systemd-journald':
ensure => 'running',
}
}
40 changes: 40 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
it { is_expected.to_not create_service('systemd-resolved') }
it { is_expected.to_not create_service('systemd-networkd') }
it { is_expected.to_not create_service('systemd-timesyncd') }
it { is_expected.to_not create_service('systemd-journald') }

context 'when enabling resolved and networkd' do
let(:params) {{
Expand Down Expand Up @@ -158,6 +159,45 @@
end
it { is_expected.to compile.with_all_deps }
end

context 'when managing journald' do
let :params do
{
manage_journald: true,
}
end

it { is_expected.to contain_class('systemd::journald') }
it { is_expected.to contain_service('systemd-journald').with_ensure('running') }
it { is_expected.to have_ini_setting_resource_count(0) }

context 'with journald_config defined' do
let :params do
{
manage_journald: true,
journald_config: { 'RateLimitInterval' => '30s', 'RateLimitBurst' => '1000' }
}
end

it { is_expected.to contain_ini_setting('RateLimitInterval').with(
ensure: 'present',
path: '/etc/systemd/journald.conf',
section: 'Journal',
setting: 'RateLimitInterval',
value: '30s',
notify: 'Service[systemd-journald]'
)}

it { is_expected.to contain_ini_setting('RateLimitBurst').with(
ensure: 'present',
path: '/etc/systemd/journald.conf',
section: 'Journal',
setting: 'RateLimitBurst',
value: '1000',
notify: 'Service[systemd-journald]'
)}
end
end
end
end
end
Expand Down

0 comments on commit 085b016

Please sign in to comment.