nixos/rsyslogd & nixos/syslog-ng: fix broken module (#47306)

* journald: forward message to syslog by default if a syslog implementation is installed

* added a test to ensure rsyslog is receiving messages when expected

* added rsyslogd tests to release.nix
This commit is contained in:
aanderse 2018-10-27 13:01:30 -04:00 committed by Renaud
parent d6a15b09c7
commit 1381019e49
3 changed files with 50 additions and 0 deletions

View File

@ -587,6 +587,15 @@ in
'';
};
services.journald.forwardToSyslog = mkOption {
default = config.services.rsyslogd.enable || config.services.syslog-ng.enable;
defaultText = "config.services.rsyslogd.enable || config.services.syslog-ng.enable";
type = types.bool;
description = ''
Whether to forward log messages to syslog.
'';
};
services.logind.extraConfig = mkOption {
default = "";
type = types.lines;
@ -754,6 +763,9 @@ in
ForwardToConsole=yes
TTYPath=${config.services.journald.console}
''}
${optionalString (config.services.journald.forwardToSyslog) ''
ForwardToSyslog=yes
''}
${config.services.journald.extraConfig}
'';

View File

@ -399,6 +399,7 @@ in rec {
tests.radicale = callTest tests/radicale.nix {};
tests.redmine = callTest tests/redmine.nix {};
tests.rspamd = callSubTests tests/rspamd.nix {};
tests.rsyslogd = callSubTests tests/rsyslogd.nix {};
tests.runInMachine = callTest tests/run-in-machine.nix {};
tests.rxe = callTest tests/rxe.nix {};
tests.samba = callTest tests/samba.nix {};

37
nixos/tests/rsyslogd.nix Normal file
View File

@ -0,0 +1,37 @@
{ system ? builtins.currentSystem }:
with import ../lib/testing.nix { inherit system; };
{
test1 = makeTest {
name = "rsyslogd-test1";
meta.maintainers = [ lib.maintainers.aanderse ];
machine =
{ config, pkgs, ... }:
{ services.rsyslogd.enable = true;
services.journald.forwardToSyslog = false;
};
# ensure rsyslogd isn't receiving messages from journald if explicitly disabled
testScript = ''
$machine->waitForUnit("default.target");
$machine->fail("test -f /var/log/messages");
'';
};
test2 = makeTest {
name = "rsyslogd-test2";
meta.maintainers = [ lib.maintainers.aanderse ];
machine =
{ config, pkgs, ... }:
{ services.rsyslogd.enable = true;
};
# ensure rsyslogd is receiving messages from journald
testScript = ''
$machine->waitForUnit("default.target");
$machine->succeed("test -f /var/log/messages");
'';
};
}