diff --git a/linux_os/guide/system/permissions/restrictions/coredumps/coredump_disable_backtraces/tests/etc_systemd_coredump_conf_dne.fail.sh b/linux_os/guide/system/permissions/restrictions/coredumps/coredump_disable_backtraces/tests/etc_systemd_coredump_conf_dne.fail.sh new file mode 100644 index 00000000000..970ec8b506a --- /dev/null +++ b/linux_os/guide/system/permissions/restrictions/coredumps/coredump_disable_backtraces/tests/etc_systemd_coredump_conf_dne.fail.sh @@ -0,0 +1,6 @@ +#!/bin/bash +FILE="/etc/systemd/coredump.conf" +if [ -f $FILE ]; then + rm $FILE +fi + diff --git a/linux_os/guide/system/permissions/restrictions/coredumps/coredump_disable_storage/tests/etc_systemd_coredump_conf_dne.fail.sh b/linux_os/guide/system/permissions/restrictions/coredumps/coredump_disable_storage/tests/etc_systemd_coredump_conf_dne.fail.sh new file mode 100644 index 00000000000..970ec8b506a --- /dev/null +++ b/linux_os/guide/system/permissions/restrictions/coredumps/coredump_disable_storage/tests/etc_systemd_coredump_conf_dne.fail.sh @@ -0,0 +1,6 @@ +#!/bin/bash +FILE="/etc/systemd/coredump.conf" +if [ -f $FILE ]; then + rm $FILE +fi + diff --git a/shared/macros/10-ansible.jinja b/shared/macros/10-ansible.jinja index 84f23f4863b..2dbabe5896d 100644 --- a/shared/macros/10-ansible.jinja +++ b/shared/macros/10-ansible.jinja @@ -293,17 +293,11 @@ value: :code:`Setting={{ varname1 }}` #}} {{%- macro ansible_coredump_config_set(msg='', parameter='', value='') %}} {{% if 'sle' in product %}} - -- name: "{{{ rule_title }}}: Make sure Coredump section exist in remediation file" - ansible.builtin.lineinfile: - path: '/etc/systemd/coredump.conf.d/oscap-autoremedy.conf' - line: '[Coredump]' - create: true - -{{{ ansible_set_config_file(msg, "/etc/systemd/coredump.conf.d/oscap-autoremedy.conf", parameter=parameter, value=value, create="yes", separator="=", separator_regex="\s*=\s*", insert_after="[Coredump]") }}} +{{% set file = '/etc/systemd/coredump.conf.d/oscap-autoremedy.conf' %}} {{% else %}} -{{{ ansible_set_config_file(msg, "/etc/systemd/coredump.conf", parameter=parameter, value=value, create="no", separator="=", separator_regex="\s*=\s*") }}} +{{% set file = '/etc/systemd/coredump.conf' %}} {{% endif %}} +{{{ ansible_ini_file_set(file, "Coredump", parameter, value) }}} {{%- endmacro %}} diff --git a/shared/macros/10-bash.jinja b/shared/macros/10-bash.jinja index 7ca65806466..960c90ab96c 100644 --- a/shared/macros/10-bash.jinja +++ b/shared/macros/10-bash.jinja @@ -299,18 +299,7 @@ fi {{% else %}} {{%- set target_path="/etc/systemd/coredump.conf" -%}} {{% endif %}} -{{{ set_config_file( - path=target_path, - parameter=parameter, - value=value, - create=true, - insert_after="", - insert_before="", - insensitive=true, - separator="=", - separator_regex="\s*=\s*", - prefix_regex="^\s*") - }}} +{{{ bash_ensure_ini_config(target_path, section="Coredump", key=parameter, value=value) }}} {{%- endmacro -%}}