Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create file if it doesn't exist for coredump rules #12181

Merged
merged 5 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
FILE="/etc/systemd/coredump.conf"
if [ -f $FILE ]; then
rm $FILE
fi

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
FILE="/etc/systemd/coredump.conf"
if [ -f $FILE ]; then
rm $FILE
fi

12 changes: 3 additions & 9 deletions shared/macros/10-ansible.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}}


Expand Down
13 changes: 1 addition & 12 deletions shared/macros/10-bash.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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 -%}}


Expand Down
Loading