-
Notifications
You must be signed in to change notification settings - Fork 709
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12326 from mrkanon/ansible_rsyslog_cron_logging
Add ansible remediaton for rsyslog_cron_logging rule
- Loading branch information
Showing
2 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...tem/logging/ensure_rsyslog_log_file_configuration/rsyslog_cron_logging/ansible/shared.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters