From f5a750c1beef8bfaf38f62d85e96c7d5abd6b089 Mon Sep 17 00:00:00 2001 From: Vojtech Polasek Date: Wed, 5 Jun 2024 11:52:47 +0200 Subject: [PATCH] honor the section of the systemd file also in tests and rules --- .../system/logging/journald/journald_compress/rule.yml | 1 + .../tests/correct_value_in_quotes.fail.sh | 2 +- .../logging/journald/journald_forward_to_syslog/rule.yml | 1 + .../system/logging/journald/journald_storage/rule.yml | 1 + .../journald_storage/tests/correct_value_in_quotes.fail.sh | 2 +- .../systemd_dropin_configuration/tests/correct_dir.pass.sh | 3 ++- .../tests/correct_master.pass.sh | 3 ++- .../tests/multiple_vals.fail.sh | 7 ++++--- .../systemd_dropin_configuration/tests/wrong_dir.fail.sh | 3 ++- .../tests/wrong_master.fail.sh | 4 ++-- 10 files changed, 17 insertions(+), 10 deletions(-) diff --git a/linux_os/guide/system/logging/journald/journald_compress/rule.yml b/linux_os/guide/system/logging/journald/journald_compress/rule.yml index d9b65cae8f2a..bbe326eab847 100644 --- a/linux_os/guide/system/logging/journald/journald_compress/rule.yml +++ b/linux_os/guide/system/logging/journald/journald_compress/rule.yml @@ -50,6 +50,7 @@ template: component: journald master_cfg_file: /etc/systemd/journald.conf dropin_dir: {{{ journald_conf_dir_path }}} + section: Journal param: Compress value: yes no_quotes: 'true' diff --git a/linux_os/guide/system/logging/journald/journald_compress/tests/correct_value_in_quotes.fail.sh b/linux_os/guide/system/logging/journald/journald_compress/tests/correct_value_in_quotes.fail.sh index ea7812664f52..64cb0cd5593d 100644 --- a/linux_os/guide/system/logging/journald/journald_compress/tests/correct_value_in_quotes.fail.sh +++ b/linux_os/guide/system/logging/journald/journald_compress/tests/correct_value_in_quotes.fail.sh @@ -2,4 +2,4 @@ # This scenario is a regression test for https://bugzilla.redhat.com/show_bug.cgi?id=2193169 -echo "Compress='yes'" > "/etc/systemd/journald.conf" +echo -e "[Journal]\nCompress='yes'" > "/etc/systemd/journald.conf" diff --git a/linux_os/guide/system/logging/journald/journald_forward_to_syslog/rule.yml b/linux_os/guide/system/logging/journald/journald_forward_to_syslog/rule.yml index 9f2d5611cc53..5c12bac81c9c 100644 --- a/linux_os/guide/system/logging/journald/journald_forward_to_syslog/rule.yml +++ b/linux_os/guide/system/logging/journald/journald_forward_to_syslog/rule.yml @@ -49,6 +49,7 @@ template: component: journald master_cfg_file: /etc/systemd/journald.conf dropin_dir: {{{ journald_conf_dir_path }}} + section: Journal param: ForwardToSyslog value: yes no_quotes: 'true' diff --git a/linux_os/guide/system/logging/journald/journald_storage/rule.yml b/linux_os/guide/system/logging/journald/journald_storage/rule.yml index 18461b389974..09d4cd9ee2dd 100644 --- a/linux_os/guide/system/logging/journald/journald_storage/rule.yml +++ b/linux_os/guide/system/logging/journald/journald_storage/rule.yml @@ -49,6 +49,7 @@ template: component: journald master_cfg_file: /etc/systemd/journald.conf dropin_dir: {{{ journald_conf_dir_path }}} + section: Journal param: Storage value: persistent no_quotes: 'true' diff --git a/linux_os/guide/system/logging/journald/journald_storage/tests/correct_value_in_quotes.fail.sh b/linux_os/guide/system/logging/journald/journald_storage/tests/correct_value_in_quotes.fail.sh index 8ec7eb863b66..482f58969a2d 100644 --- a/linux_os/guide/system/logging/journald/journald_storage/tests/correct_value_in_quotes.fail.sh +++ b/linux_os/guide/system/logging/journald/journald_storage/tests/correct_value_in_quotes.fail.sh @@ -2,4 +2,4 @@ # This scenario is a regression test for https://bugzilla.redhat.com/show_bug.cgi?id=2169857 -echo "Storage='persistent'" > "/etc/systemd/journald.conf" +echo -e "[Journal]\nStorage='persistent'" > "/etc/systemd/journald.conf" diff --git a/shared/templates/systemd_dropin_configuration/tests/correct_dir.pass.sh b/shared/templates/systemd_dropin_configuration/tests/correct_dir.pass.sh index 7b4d2ff0302a..e9c553ac6de7 100644 --- a/shared/templates/systemd_dropin_configuration/tests/correct_dir.pass.sh +++ b/shared/templates/systemd_dropin_configuration/tests/correct_dir.pass.sh @@ -1,6 +1,7 @@ #!/bin/bash +SECTION="{{{ SECTION }}}" PARAM="{{{ PARAM }}}" VALUE="{{{ VALUE }}}" DROPIN_DIR="{{{ DROPIN_DIR }}}" [ -d $DROPIN_DIR ] || mkdir -p $DROPIN_DIR -echo "$PARAM=$VALUE" >> "$DROPIN_DIR/ssg.conf" +echo -e "[$SECTION]\n$PARAM=$VALUE" >> "$DROPIN_DIR/ssg.conf" diff --git a/shared/templates/systemd_dropin_configuration/tests/correct_master.pass.sh b/shared/templates/systemd_dropin_configuration/tests/correct_master.pass.sh index 3c4db5f7cb6d..6110ad87bf1f 100644 --- a/shared/templates/systemd_dropin_configuration/tests/correct_master.pass.sh +++ b/shared/templates/systemd_dropin_configuration/tests/correct_master.pass.sh @@ -1,5 +1,6 @@ #!/bin/bash +SECTION="{{{ SECTION }}}" PARAM="{{{ PARAM }}}" VALUE="{{{ VALUE }}}" MASTER_CFG_FILE="{{{ MASTER_CFG_FILE }}}" -echo "$PARAM=$VALUE" >> "$MASTER_CFG_FILE" +echo -e "[$SECTION]\n$PARAM=$VALUE" >> "$MASTER_CFG_FILE" diff --git a/shared/templates/systemd_dropin_configuration/tests/multiple_vals.fail.sh b/shared/templates/systemd_dropin_configuration/tests/multiple_vals.fail.sh index d5043b1d3600..bd59bdb53481 100644 --- a/shared/templates/systemd_dropin_configuration/tests/multiple_vals.fail.sh +++ b/shared/templates/systemd_dropin_configuration/tests/multiple_vals.fail.sh @@ -1,9 +1,10 @@ #!/bin/bash +SECTION="{{{ SECTION }}}" PARAM="{{{ PARAM }}}" VALUE="{{{ VALUE }}}" DROPIN_DIR="{{{ DROPIN_DIR }}}" MASTER_CFG_FILE="{{{ MASTER_CFG_FILE }}}" [ -d $DROPIN_DIR ] || mkdir -p $DROPIN_DIR -echo "$PARAM=$VALUE" >> "$DROPIN_DIR/ssg.conf" -echo "$PARAM=badval" >> "$DROPIN_DIR/gss.conf" -echo "$PARAM=foobarzoo" >> "$MASTER_CFG_FILE" +echo -e "[$SECTION]\n$PARAM=$VALUE" >> "$DROPIN_DIR/ssg.conf" +echo -e "[$SECTION]\n$PARAM=badval" >> "$DROPIN_DIR/gss.conf" +echo -e "[$SECTION]\n$PARAM=foobarzoo" >> "$MASTER_CFG_FILE" diff --git a/shared/templates/systemd_dropin_configuration/tests/wrong_dir.fail.sh b/shared/templates/systemd_dropin_configuration/tests/wrong_dir.fail.sh index 2a4a89dce358..5fe378936696 100644 --- a/shared/templates/systemd_dropin_configuration/tests/wrong_dir.fail.sh +++ b/shared/templates/systemd_dropin_configuration/tests/wrong_dir.fail.sh @@ -1,5 +1,6 @@ #!/bin/bash +SECTION="{{{ SECTION }}}" PARAM="{{{ PARAM }}}" DROPIN_DIR="{{{ DROPIN_DIR }}}" [ -d $DROPIN_DIR ] || mkdir -p $DROPIN_DIR -echo "$PARAM=badval" >> "$DROPIN_DIR/ssg.conf" +echo -e "[$SECTION]\n$PARAM=badval" >> "$DROPIN_DIR/ssg.conf" diff --git a/shared/templates/systemd_dropin_configuration/tests/wrong_master.fail.sh b/shared/templates/systemd_dropin_configuration/tests/wrong_master.fail.sh index c4c6a28878bc..2ff990d105d3 100644 --- a/shared/templates/systemd_dropin_configuration/tests/wrong_master.fail.sh +++ b/shared/templates/systemd_dropin_configuration/tests/wrong_master.fail.sh @@ -1,5 +1,5 @@ #!/bin/bash +SECTION="{{{ SECTION }}}" PARAM="{{{ PARAM }}}" -VALUE="{{{ VALUE }}}" MASTER_CFG_FILE="{{{ MASTER_CFG_FILE }}}" -echo "$PARAM=badval" >> "$MASTER_CFG_FILE" +echo -e "[$SECTION]\n$PARAM=badval" >> "$MASTER_CFG_FILE"