2024-07-24 14:05:46 +01:00
|
|
|
---
|
|
|
|
|
|
|
|
|
|
- name: "6.2.1.1 | PATCH | Ensure journald service is enabled and active"
|
2024-12-04 11:45:13 +00:00
|
|
|
when: rhel9cis_rule_6_2_1_1
|
2024-07-24 14:05:46 +01:00
|
|
|
tags:
|
|
|
|
|
- level1-server
|
|
|
|
|
- level1-workstation
|
|
|
|
|
- audit
|
|
|
|
|
- journald
|
|
|
|
|
- rule_6.2.1.1
|
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
|
name: systemd-journald.service
|
|
|
|
|
masked: false
|
|
|
|
|
state: started
|
|
|
|
|
|
|
|
|
|
- name: "6.2.1.2 | PATCH | Ensure journald log file access is configured"
|
2024-12-04 11:45:13 +00:00
|
|
|
when: rhel9cis_rule_6_2_1_2
|
2024-07-24 14:05:46 +01:00
|
|
|
tags:
|
|
|
|
|
- level1-server
|
|
|
|
|
- level1-workstation
|
|
|
|
|
- audit
|
|
|
|
|
- journald
|
|
|
|
|
- rule_6.2.1.2
|
|
|
|
|
block:
|
|
|
|
|
- name: "6.2.1.2 | PATCH | Ensure journald log file access is configured | Default file permissions"
|
|
|
|
|
ansible.builtin.file:
|
|
|
|
|
path: /usr/lib/tmpfiles.d/systemd.conf
|
2024-12-04 11:45:13 +00:00
|
|
|
mode: 'g-wx,o-rwx'
|
2024-07-24 14:05:46 +01:00
|
|
|
|
|
|
|
|
- name: "6.2.1.2 | AUDIT | Ensure journald log file access is configured | Check for override file"
|
|
|
|
|
ansible.builtin.stat:
|
|
|
|
|
path: /etc/tmpfiles.d/systemd.conf
|
2024-11-04 18:39:01 +00:00
|
|
|
register: discovered_tmpfile_override
|
2024-07-24 14:05:46 +01:00
|
|
|
|
|
|
|
|
- name: "6.2.1.2 | AUDIT | Ensure journald log file access is configured | If override file check for journal"
|
2024-11-04 18:39:01 +00:00
|
|
|
when: discovered_tmpfile_override.stat.exists
|
2024-07-24 14:05:46 +01:00
|
|
|
ansible.builtin.shell: grep -E 'z /var/log/journal/%m/system.journal \d*' /usr/lib/tmpfiles.d/systemd.conf
|
2024-11-04 18:39:01 +00:00
|
|
|
register: discovered_journald_fileperms_override
|
2024-07-24 14:05:46 +01:00
|
|
|
changed_when: false
|
2024-11-04 18:39:01 +00:00
|
|
|
failed_when: discovered_journald_fileperms_override.rc not in [ 0, 1 ]
|
2024-07-24 14:05:46 +01:00
|
|
|
|
|
|
|
|
- name: "6.2.1.2 | AUDIT | Ensure journald log file access is configured | Warning if override found"
|
|
|
|
|
when:
|
2024-11-04 18:39:01 +00:00
|
|
|
- discovered_tmpfile_override.stat.exists
|
|
|
|
|
- discovered_journald_fileperms_override.stdout | length > 0
|
2024-07-24 14:05:46 +01:00
|
|
|
ansible.builtin.debug:
|
|
|
|
|
msg: "Warning!! - tmpfiles override found /usr/lib/tmpfiles.d/systemd.conf affecting journald files please confirm matches site policy"
|
|
|
|
|
|
|
|
|
|
- name: "6.2.1.2 | AUDIT | Ensure journald log file access is configured | Warning if override found"
|
|
|
|
|
when:
|
2024-11-04 18:39:01 +00:00
|
|
|
- discovered_tmpfile_override.stat.exists
|
|
|
|
|
- discovered_journald_fileperms_override.stdout | length > 0
|
2024-07-24 14:05:46 +01:00
|
|
|
ansible.builtin.import_tasks:
|
|
|
|
|
file: warning_facts.yml
|
|
|
|
|
vars:
|
|
|
|
|
warn_control_id: '6.2.1.2'
|
|
|
|
|
|
|
|
|
|
- name: "6.2.1.3 | PATCH | Ensure journald log file rotation is configured"
|
2024-12-04 11:45:13 +00:00
|
|
|
when: rhel9cis_rule_6_2_1_3
|
2024-07-24 14:05:46 +01:00
|
|
|
tags:
|
|
|
|
|
- level1-server
|
|
|
|
|
- level1-workstation
|
|
|
|
|
- patch
|
|
|
|
|
- journald
|
|
|
|
|
- rule_6.2.1.3
|
|
|
|
|
notify: Restart journald
|
|
|
|
|
block:
|
|
|
|
|
- name: "6.2.1.3 | PATCH | Ensure journald log file rotation is configured | Add file"
|
|
|
|
|
ansible.builtin.template:
|
|
|
|
|
src: etc/systemd/journald.conf.d/rotation.conf.j2
|
|
|
|
|
dest: /etc/systemd/journald.conf.d/rotation.conf
|
|
|
|
|
owner: root
|
|
|
|
|
group: root
|
2024-12-04 11:45:13 +00:00
|
|
|
mode: 'g-wx,o-rwx'
|
2024-07-24 14:05:46 +01:00
|
|
|
|
|
|
|
|
- name: "6.2.1.3 | PATCH | Ensure journald log file rotation is configured | comment out current entries"
|
|
|
|
|
ansible.builtin.replace:
|
|
|
|
|
path: /etc/systemd/journald.conf
|
|
|
|
|
regexp: "{{ item }}"
|
|
|
|
|
replace: '#\1'
|
|
|
|
|
loop:
|
|
|
|
|
- '^(\s*SystemMaxUse\s*=.*)'
|
|
|
|
|
- '^(\s*SystemKeepFree\s*=.*)'
|
|
|
|
|
- '^(\s*RuntimeMaxUse\s*=)'
|
|
|
|
|
- '^(\s*RuntimeKeepFree\s*=.*)'
|
|
|
|
|
- '^(\s*MaxFileSec\s*=.*)'
|
|
|
|
|
|
|
|
|
|
- name: "6.2.1.4 | PATCH | Ensure only one logging system is in use"
|
2024-12-04 11:45:13 +00:00
|
|
|
when: rhel9cis_rule_6_2_1_4
|
2024-07-24 14:05:46 +01:00
|
|
|
tags:
|
|
|
|
|
- level1-server
|
|
|
|
|
- level1-workstation
|
|
|
|
|
- patch
|
|
|
|
|
- journald
|
|
|
|
|
- syslog
|
|
|
|
|
- rule_6.2.1.4
|
|
|
|
|
block:
|
|
|
|
|
- name: "6.2.1.4 | PATCH | Ensure only one logging system is in use | when rsyslog"
|
|
|
|
|
when: rhel9cis_syslog == "rsyslog"
|
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
|
name: systemd-journald
|
|
|
|
|
state: stopped
|
|
|
|
|
enabled: false
|
|
|
|
|
|
|
|
|
|
- name: "6.2.1.4 | PATCH | Ensure only one logging system is in use | when journald"
|
|
|
|
|
when: rhel9cis_syslog == "journald"
|
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
|
name: rsyslog
|
|
|
|
|
state: stopped
|
|
|
|
|
enabled: false
|