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

Add ansible remediaton for rsyslog_cron_logging rule #12326

Merged
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,27 @@
# platform = multi_platform_all
# reboot = false
# strategy = configure
# complexity = low
# disruption = low

- name: "{{{ rule_title }}} - Search if cron configuration exists"
ansible.builtin.command: 'grep -s "^\s*cron\.\*\s*/var/log/cron$" /etc/rsyslog.conf /etc/rsyslog.d/*.conf'
register: cron_log_config_exists
failed_when: false

- name: "{{{ rule_title }}} - Ensure the /etc/rsyslog.d directory exists"
ansible.builtin.file:
path: /etc/rsyslog.d
state: directory

- name: "{{{ rule_title }}} - Add cron log configuration line"
ansible.builtin.lineinfile:
path: /etc/rsyslog.d/cron.conf
line: "cron.* /var/log/cron"
create: true
when: cron_log_config_exists.stdout_lines | length == 0

- name: "{{{ rule_title }}} - Restart the rsyslog service now"
ansible.builtin.service:
name: rsyslog
state: restarted
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
test_ref="test_cron_logging_rsyslog_dir" />
<criterion comment="cron is configured in /etc/rsyslog.d using RainerScript"
test_ref="test_cron_logging_rsyslog_dir_rainer" />
{{% if product == "ol8" %}}
{{% if "ol" in product %}}
<criterion comment="rsyslog is configured in /etc/rsyslog.conf to log to all facilities"
test_ref="test_cron_logging_rsyslog_logging_all_facilities" />
<criterion comment="rsyslog is configured in /etc/rsyslog.d to log to all facilities"
Expand Down Expand Up @@ -70,7 +70,7 @@
<ind:instance datatype="int">1</ind:instance>
</ind:textfilecontent54_object>

{{% if product == "ol8" %}}
{{% if "ol" in product %}}
<ind:textfilecontent54_test check="all" check_existence="all_exist"
comment="rsyslog is configured in /etc/rsyslog.conf to log to all facilities"
id="test_cron_logging_rsyslog_logging_all_facilities" version="1">
Expand Down
Loading