Skip to content

Commit 2f72b3f

Browse files
authored
Merge pull request #60 from netmanagers/add_journald
Add journald
2 parents d633daf + 32d2e70 commit 2f72b3f

File tree

9 files changed

+210
-0
lines changed

9 files changed

+210
-0
lines changed

docs/README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Formula to set up and configure systemd including
1919
* networkd
2020
* timesyncd
2121
* resolved
22+
* journald
2223

2324
.. contents:: **Table of Contents**
2425

@@ -67,6 +68,10 @@ Available states
6768

6869
Installs the systemd packages and libraries.
6970

71+
``systemd.journald``
72+
^^^^^^^^^^^^^^^^^^^^^
73+
This state manages systemd-journald configuration
74+
7075
``systemd.timesyncd``
7176
^^^^^^^^^^^^^^^^^^^^^
7277
This state installs systemd-timesyncd and configures both NTP and timezone

kitchen.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ suites:
160160
- systemd
161161
- systemd.networkd
162162
- systemd.networkd.profiles
163+
- systemd.journald
163164
- rsync_test_package
164165
- systemd.units
165166
pillars:

pillar.example

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,31 @@ systemd:
146146
- Path: 'pci-0000:00:1a.0-*'
147147
- Link:
148148
- Name: internet0
149+
150+
## journald
151+
journald:
152+
config_source: pillar
153+
config:
154+
SplitMode: uid
155+
SyncIntervalSec: 5m
156+
RateLimitIntervalSec: 30s
157+
RateLimitBurst: 10000
158+
SystemMaxUse: 2g
159+
SystemKeepFree: 3g
160+
SystemMaxFileSize: 4g
161+
SystemMaxFiles: 100
162+
RuntimeMaxFiles: 100
163+
MaxFileSec: 1month
164+
ForwardToSyslog: 'yes'
165+
ForwardToKMsg: 'no'
166+
ForwardToConsole: 'no'
167+
ForwardToWall: 'yes'
168+
TTYPath: /dev/console
169+
MaxLevelStore: debug
170+
MaxLevelSyslog: debug
171+
MaxLevelKMsg: notice
172+
MaxLevelConsole: info
173+
MaxLevelWall: emerg
174+
LineMax: 48K
175+
ReadKMsg: 'yes'
176+
Audit: 'no'

systemd/defaults.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,10 @@ systemd:
4040
Cache: 'yes'
4141
DNSStubListener: 'yes'
4242
ReadEtcHosts: 'yes'
43+
44+
journald:
45+
config_source: file
46+
config:
47+
Storage: auto
48+
Compress: 'yes'
49+
Seal: 'yes'

systemd/journald/config.sls

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{%- from "systemd/map.jinja" import systemd with context %}
2+
{%- from "systemd/libtofs.jinja" import files_switch with context -%}
3+
4+
{%- set journald = systemd.get('journald', {}) %}
5+
{%- set config = journald.get('config', {}) %}
6+
7+
journald:
8+
{%- if journald.config_source == 'file' %}
9+
file.managed:
10+
- name: /etc/systemd/journald.conf
11+
- user: root
12+
- group: root
13+
- mode: 644
14+
- template: jinja
15+
- source: {{ files_switch(['journald.conf'],
16+
lookup='journald',
17+
use_subpath=True
18+
)
19+
}}
20+
{%- elif journald.config_source == 'pillar' %}
21+
ini.options_present:
22+
- name: /etc/systemd/journald.conf
23+
- separator: '='
24+
- strict: True
25+
- sections:
26+
Journal:
27+
{%- for k, v in config.items() %}
28+
{%- if k in [
29+
'Audit',
30+
'Compress',
31+
'ForwardToConsole',
32+
'ForwardToKMsg',
33+
'ForwardToSyslog',
34+
'ForwardToWall',
35+
'LineMax',
36+
'MaxFileSec',
37+
'MaxLevelConsole',
38+
'MaxLevelKMsg',
39+
'MaxLevelStore',
40+
'MaxLevelSyslog',
41+
'MaxLevelWall',
42+
'MaxRetentionSec',
43+
'RateLimitBurst',
44+
'RateLimitIntervalSec',
45+
'ReadKMsg',
46+
'RuntimeKeepFree',
47+
'RuntimeMaxFileSize',
48+
'RuntimeMaxFiles',
49+
'RuntimeMaxUse',
50+
'Seal',
51+
'SplitMode',
52+
'Storage',
53+
'SyncIntervalSec',
54+
'SystemKeepFree',
55+
'SystemMaxFileSize',
56+
'SystemMaxFiles',
57+
'SystemMaxUse',
58+
'TTYPath',
59+
]
60+
%}
61+
{{ k }}: {{ v | yaml }}
62+
{%- endif %}
63+
{%- endfor %}
64+
65+
{%- endif %}
66+
- listen_in:
67+
- service: journald
68+
service.running:
69+
- name: systemd-journald
70+
- enable: True
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# This file managed by Salt, do not edit by hand!!
2+
#
3+
# This file is part of systemd.
4+
#
5+
# systemd is free software; you can redistribute it and/or modify it
6+
# under the terms of the GNU Lesser General Public License as published by
7+
# the Free Software Foundation; either version 2.1 of the License, or
8+
# (at your option) any later version.
9+
#
10+
# Entries in this file show the compile time defaults.
11+
# You can change settings by editing this file.
12+
# Defaults can be restored by simply deleting this file.
13+
#
14+
# See journald.conf(5) for details.
15+
16+
[Journal]
17+
#Storage=auto
18+
#Compress=yes
19+
#Seal=yes
20+
#SplitMode=uid
21+
#SyncIntervalSec=5m
22+
#RateLimitIntervalSec=30s
23+
#RateLimitBurst=10000
24+
#SystemMaxUse=
25+
#SystemKeepFree=
26+
#SystemMaxFileSize=
27+
#SystemMaxFiles=100
28+
#RuntimeMaxUse=
29+
#RuntimeKeepFree=
30+
#RuntimeMaxFileSize=
31+
#RuntimeMaxFiles=100
32+
#MaxRetentionSec=
33+
#MaxFileSec=1month
34+
#ForwardToSyslog=yes
35+
#ForwardToKMsg=no
36+
#ForwardToConsole=no
37+
#ForwardToWall=yes
38+
#TTYPath=/dev/console
39+
#MaxLevelStore=debug
40+
#MaxLevelSyslog=debug
41+
#MaxLevelKMsg=notice
42+
#MaxLevelConsole=info
43+
#MaxLevelWall=emerg
44+
#LineMax=48K
45+
#ReadKMsg=yes
46+
#Audit=no

systemd/journald/init.sls

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include:
2+
- .config

systemd/resolved/files/default/resolved.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# This file managed by Salt, do not edit by hand!!
2+
#
13
# This file is part of systemd.
24
#
35
# systemd is free software; you can redistribute it and/or modify it
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# frozen_string_literal: true
2+
3+
control 'Systemd Journald' do
4+
title 'should match desired lines'
5+
6+
describe file('/etc/systemd/journald.conf') do
7+
its('type') { should eq :file }
8+
its('mode') { should cmp '0644' }
9+
its('owner') { should eq 'root' }
10+
its('group') { should eq 'root' }
11+
12+
its('content') { should include '[Journal]' }
13+
its('content') { should include 'Storage = auto' }
14+
its('content') { should include 'Compress = yes' }
15+
its('content') { should include 'Seal = yes' }
16+
its('content') { should include 'SplitMode = uid' }
17+
its('content') { should include 'SyncIntervalSec = 5m' }
18+
its('content') { should include 'RateLimitIntervalSec = 30s' }
19+
its('content') { should include 'RateLimitBurst = 10000' }
20+
its('content') { should include 'SystemMaxUse = 2g' }
21+
its('content') { should include 'SystemKeepFree = 3g' }
22+
its('content') { should include 'SystemMaxFileSize = 4g' }
23+
its('content') { should include 'SystemMaxFiles = 100' }
24+
its('content') { should include '#RuntimeMaxUse=' }
25+
its('content') { should include '#RuntimeKeepFree=' }
26+
its('content') { should include '#RuntimeMaxFileSize=' }
27+
its('content') { should include 'RuntimeMaxFiles = 100' }
28+
its('content') { should include '#MaxRetentionSec=' }
29+
its('content') { should include 'MaxFileSec = 1month' }
30+
its('content') { should include 'ForwardToSyslog = yes' }
31+
its('content') { should include 'ForwardToKMsg = no' }
32+
its('content') { should include 'ForwardToConsole = no' }
33+
its('content') { should include 'ForwardToWall = yes' }
34+
its('content') { should include 'TTYPath = /dev/console' }
35+
its('content') { should include 'MaxLevelStore = debug' }
36+
its('content') { should include 'MaxLevelSyslog = debug' }
37+
its('content') { should include 'MaxLevelKMsg = notice' }
38+
its('content') { should include 'MaxLevelConsole = info' }
39+
its('content') { should include 'MaxLevelWall = emerg' }
40+
its('content') { should include 'LineMax = 48K' }
41+
its('content') { should include 'ReadKMsg = yes' }
42+
its('content') { should include 'Audit = no' }
43+
end
44+
45+
describe service('systemd-journald.service') do
46+
it { should be_enabled }
47+
it { should be_running }
48+
end
49+
end

0 commit comments

Comments
 (0)