mirror of
https://github.com/ansible-lockdown/RHEL9-CIS.git
synced 2025-12-24 22:23:06 +00:00
Initial
Signed-off-by: Mark Bolwell <mark.bollyuk@gmail.com>
This commit is contained in:
commit
a54b5216eb
87 changed files with 7693 additions and 0 deletions
103
tasks/section_4/cis_4.1.1.x.yml
Normal file
103
tasks/section_4/cis_4.1.1.x.yml
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
---
|
||||
|
||||
- name: "4.1.1.1 | L2 | PATCH | Ensure auditd is installed"
|
||||
block:
|
||||
- name: "4.1.1.1 | L2 | PATCH | Ensure auditd is installed | Install auditd packages"
|
||||
package:
|
||||
name: audit
|
||||
state: present
|
||||
when: '"auditd" not in ansible_facts.packages'
|
||||
|
||||
- name: "4.1.1.1 | L2 | PATCH | Ensure auditd is installed | Install auditd-lib packages"
|
||||
package:
|
||||
name: audit-libs
|
||||
state: present
|
||||
when: '"auditd-lib" not in ansible_facts.packages'
|
||||
when:
|
||||
- rhel9cis_rule_4_1_1_1
|
||||
tags:
|
||||
- level2-server
|
||||
- level2-workstation
|
||||
- patch
|
||||
- rule_4.1.1.1
|
||||
|
||||
- name: "4.1.1.2 | L2 | PATCH | Ensure auditd service is enabled"
|
||||
service:
|
||||
name: auditd
|
||||
state: started
|
||||
enabled: yes
|
||||
when:
|
||||
- not rhel9cis_skip_for_travis
|
||||
- rhel9cis_rule_4_1_1_2
|
||||
- ansible_connection != 'docker'
|
||||
tags:
|
||||
- level2-server
|
||||
- level2-workstation
|
||||
- auditd
|
||||
- patch
|
||||
- rule_4.1.1.2
|
||||
|
||||
- name: "4.1.1.3 | L2 | PATCH | Ensure auditing for processes that start prior to auditd is enabled"
|
||||
block:
|
||||
- name: "4.1.1.3 | L2 | AUDIT | Ensure auditing for processes that start prior to auditd is enabled | Get GRUB_CMDLINE_LINUX"
|
||||
shell: grep 'GRUB_CMDLINE_LINUX=' /etc/default/grub | sed 's/.$//'
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
check_mode: no
|
||||
register: rhel9cis_4_1_1_3_grub_cmdline_linux
|
||||
|
||||
- name: "4.1.1.3 | L2 | PATCH | Ensure auditing for processes that start prior to auditd is enabled | Replace existing setting"
|
||||
replace:
|
||||
dest: /etc/default/grub
|
||||
regexp: 'audit=.'
|
||||
replace: 'audit=1'
|
||||
notify: grub2cfg
|
||||
when: "'audit=' in rhel9cis_4_1_1_3_grub_cmdline_linux.stdout"
|
||||
|
||||
- name: "4.1.1.3 | L2 | PATCH | Ensure auditing for processes that start prior to auditd is enabled | Add audit setting if missing"
|
||||
lineinfile:
|
||||
path: /etc/default/grub
|
||||
regexp: '^GRUB_CMDLINE_LINUX='
|
||||
line: '{{ rhel9cis_4_1_1_3_grub_cmdline_linux.stdout }} audit=1"'
|
||||
notify: grub2cfg
|
||||
when: "'audit=' not in rhel9cis_4_1_1_3_grub_cmdline_linux.stdout"
|
||||
when:
|
||||
- rhel9cis_rule_4_1_1_3
|
||||
tags:
|
||||
- level2-server
|
||||
- level2-workstation
|
||||
- auditd
|
||||
- patch
|
||||
- rule_4.1.1.3
|
||||
|
||||
- name: "4.1.1.4 | L2 | PATCH | Ensure audit_backlog_limit is sufficient"
|
||||
block:
|
||||
- name: "4.1.1.4 | L2 | AUDIT | Ensure audit_backlog_limit is sufficient | Get GRUB_CMDLINE_LINUX"
|
||||
shell: grep 'GRUB_CMDLINE_LINUX=' /etc/default/grub | sed 's/.$//'
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
check_mode: no
|
||||
register: rhel9cis_4_1_1_4_grub_cmdline_linux
|
||||
|
||||
- name: "4.1.1.4 | L2 | PATCH | Ensure audit_backlog_limit is sufficient | Replace existing setting"
|
||||
replace:
|
||||
dest: /etc/default/grub
|
||||
regexp: 'audit_backlog_limit=\d+'
|
||||
replace: 'audit_backlog_limit={{ rhel9cis_audit_back_log_limit }}'
|
||||
notify: grub2cfg
|
||||
when: "'audit_backlog_limit=' in rhel9cis_4_1_1_4_grub_cmdline_linux.stdout"
|
||||
|
||||
- name: "4.1.1.4 | L2 | PATCH | Ensure audit_backlog_limit is sufficient | Add audit_backlog_limit setting if missing"
|
||||
lineinfile:
|
||||
path: /etc/default/grub
|
||||
regexp: '^GRUB_CMDLINE_LINUX='
|
||||
line: '{{ rhel9cis_4_1_1_4_grub_cmdline_linux.stdout }} audit_backlog_limit={{ rhel9cis_audit_back_log_limit }}"'
|
||||
notify: grub2cfg
|
||||
when: "'audit_backlog_limit=' not in rhel9cis_4_1_1_4_grub_cmdline_linux.stdout"
|
||||
when:
|
||||
- rhel9cis_rule_4_1_1_4
|
||||
tags:
|
||||
- level2-server
|
||||
- level2-workstation
|
||||
- patch
|
||||
- rule_4.1.1.4
|
||||
53
tasks/section_4/cis_4.1.2.x.yml
Normal file
53
tasks/section_4/cis_4.1.2.x.yml
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
---
|
||||
|
||||
- name: "4.1.2.1 | L2 | PATCH | Ensure audit log storage size is configured"
|
||||
lineinfile:
|
||||
dest: /etc/audit/auditd.conf
|
||||
regexp: "^max_log_file( |=)"
|
||||
line: "max_log_file = {{ rhel9cis_max_log_file_size }}"
|
||||
state: present
|
||||
notify: restart auditd
|
||||
when:
|
||||
- rhel9cis_rule_4_1_2_1
|
||||
tags:
|
||||
- level2-server
|
||||
- level2-workstation
|
||||
- auditd
|
||||
- patch
|
||||
- rule_4.1.2.1
|
||||
|
||||
- name: "4.1.2.2 | L2 | PATCH | Ensure audit logs are not automatically deleted"
|
||||
lineinfile:
|
||||
dest: /etc/audit/auditd.conf
|
||||
regexp: "^max_log_file_action"
|
||||
line: "max_log_file_action = {{ rhel9cis_auditd['max_log_file_action'] }}"
|
||||
state: present
|
||||
notify: restart auditd
|
||||
when:
|
||||
- rhel9cis_rule_4_1_2_2
|
||||
tags:
|
||||
- level2-server
|
||||
- level2-workstation
|
||||
- auditd
|
||||
- patch
|
||||
- rule_4.1.2.2
|
||||
|
||||
- name: "4.1.2.3 | L2 | PATCH | Ensure system is disabled when audit logs are full"
|
||||
lineinfile:
|
||||
dest: /etc/audit/auditd.conf
|
||||
regexp: "{{ item.regexp }}"
|
||||
line: "{{ item.line }}"
|
||||
state: present
|
||||
notify: restart auditd
|
||||
with_items:
|
||||
- { regexp: '^admin_space_left_action', line: 'admin_space_left_action = {{ rhel9cis_auditd.admin_space_left_action }}' }
|
||||
- { regexp: '^action_mail_acct', line: 'action_mail_acct = {{ rhel9cis_auditd.action_mail_acct }}' }
|
||||
- { regexp: '^space_left_action', line: 'space_left_action = {{ rhel9cis_auditd.space_left_action }}' }
|
||||
when:
|
||||
- rhel9cis_rule_4_1_2_3
|
||||
tags:
|
||||
- level2-server
|
||||
- level2-workstation
|
||||
- auditd
|
||||
- patch
|
||||
- rule_4.1.2.3
|
||||
205
tasks/section_4/cis_4.1.x.yml
Normal file
205
tasks/section_4/cis_4.1.x.yml
Normal file
|
|
@ -0,0 +1,205 @@
|
|||
---
|
||||
|
||||
- name: "4.1.3 | L2 | PATCH | Ensure changes to system administration scope (sudoers) is collected"
|
||||
debug:
|
||||
msg: "Control being set via Handler 'update auditd' which writes to /etc/audit.d/99_auditd.rules"
|
||||
notify: update auditd
|
||||
when:
|
||||
- rhel9cis_rule_4_1_3
|
||||
tags:
|
||||
- level2-server
|
||||
- level2-workstation
|
||||
- auditd
|
||||
- patch
|
||||
- rule_4.1.3
|
||||
|
||||
- name: "4.1.4 | L2 | PATCH | Ensure login and logout events are collected"
|
||||
debug:
|
||||
msg: "Control being set via Handler 'update auditd' which writes to /etc/audit.d/99_auditd.rules"
|
||||
notify: update auditd
|
||||
when:
|
||||
- rhel9cis_rule_4_1_4
|
||||
tags:
|
||||
- level2-server
|
||||
- level2-workstation
|
||||
- auditd
|
||||
- patch
|
||||
- rule_4.1.4
|
||||
|
||||
- name: "4.1.5 | L2 | PATCH | Ensure session initiation information is collected"
|
||||
debug:
|
||||
msg: "Control being set via Handler 'update auditd' which writes to /etc/audit.d/99_auditd.rules"
|
||||
notify: update auditd
|
||||
when:
|
||||
- rhel9cis_rule_4_1_5
|
||||
tags:
|
||||
- level2-server
|
||||
- level2-workstation
|
||||
- auditd
|
||||
- patch
|
||||
- rule_4.1.5
|
||||
|
||||
- name: "4.1.6 | L2 | PATCH | Ensure events that modify date and time information are collected"
|
||||
debug:
|
||||
msg: "Control being set via Handler 'update auditd' which writes to /etc/audit.d/99_auditd.rules"
|
||||
notify: update auditd
|
||||
when:
|
||||
- rhel9cis_rule_4_1_6
|
||||
tags:
|
||||
- level2-server
|
||||
- level2-workstation
|
||||
- auditd
|
||||
- patch
|
||||
- rule_4.1.6
|
||||
|
||||
- name: "4.1.7 | L2 | PATCH | Ensure events that modify the system's Mandatory Access Controls are collected"
|
||||
debug:
|
||||
msg: "Control being set via Handler 'update auditd' which writes to /etc/audit.d/99_auditd.rules"
|
||||
notify: update auditd
|
||||
when:
|
||||
- rhel9cis_rule_4_1_7
|
||||
tags:
|
||||
- level2-server
|
||||
- level2-workstation
|
||||
- auditd
|
||||
- patch
|
||||
- rule_4.1.7
|
||||
|
||||
- name: "4.1.8 | L2 | PATCH | Ensure events that modify the system's network environment are collected"
|
||||
debug:
|
||||
msg: "Control being set via Handler 'update auditd' which writes to /etc/audit.d/99_auditd.rules"
|
||||
notify: update auditd
|
||||
when:
|
||||
- rhel9cis_rule_4_1_8
|
||||
tags:
|
||||
- level2-server
|
||||
- level2-workstation
|
||||
- auditd
|
||||
- patch
|
||||
- rule_4.1.8
|
||||
|
||||
- name: "4.1.9 | L2 | PATCH | Ensure discretionary access control permission modification events are collected"
|
||||
debug:
|
||||
msg: "Control being set via Handler 'update auditd' which writes to /etc/audit.d/99_auditd.rules"
|
||||
notify: update auditd
|
||||
when:
|
||||
- rhel9cis_rule_4_1_9
|
||||
tags:
|
||||
- level2-server
|
||||
- level2-workstation
|
||||
- auditd
|
||||
- patch
|
||||
- rule_4.1.9
|
||||
|
||||
- name: "4.1.10 | L2 | PATCH | Ensure unsuccessful unauthorized file access attempts are collected"
|
||||
debug:
|
||||
msg: "Control being set via Handler 'update auditd' which writes to /etc/audit.d/99_auditd.rules"
|
||||
notify: update auditd
|
||||
when:
|
||||
- rhel9cis_rule_4_1_10
|
||||
tags:
|
||||
- level2-server
|
||||
- level2-workstation
|
||||
- auditd
|
||||
- patch
|
||||
- rule_4.1.10
|
||||
|
||||
- name: "4.1.11 | L2 | PATCH | Ensure events that modify user/group information are collected"
|
||||
debug:
|
||||
msg: "Control being set via Handler 'update auditd' which writes to /etc/audit.d/99_auditd.rules"
|
||||
notify: update auditd
|
||||
when:
|
||||
- rhel9cis_rule_4_1_11
|
||||
tags:
|
||||
- level2-server
|
||||
- level2-workstation
|
||||
- auditd
|
||||
- patch
|
||||
- rule_4.1.11
|
||||
|
||||
- name: "4.1.12 | L2 | PATCH | Ensure successful file system mounts are collected"
|
||||
block:
|
||||
- name: "4.1.12 | L2 | AUDIT | Ensure successful file system mounts are collected"
|
||||
shell: for i in $(df | grep '^/dev' | awk '{ print $NF }'); do find $i -xdev -type f -perm -4000 -o -type f -perm -2000 2>/dev/null; done
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
check_mode: no
|
||||
register: priv_procs
|
||||
|
||||
- name: "4.1.12 | L2 | PATCH | Ensure successful file system mounts are collected"
|
||||
debug:
|
||||
msg: "Control being set via Handler 'update auditd' which writes to /etc/audit.d/99_auditd.rules"
|
||||
notify: update auditd
|
||||
when:
|
||||
- rhel9cis_rule_4_1_12
|
||||
tags:
|
||||
- level2-server
|
||||
- level2-workstation
|
||||
- auditd
|
||||
- patch
|
||||
- rule_4.1.12
|
||||
|
||||
- name: "4.1.13 | L2 | PATCH | Ensure use of privileged commands is collected"
|
||||
debug:
|
||||
msg: "Control being set via Handler 'update auditd' which writes to /etc/audit.d/99_auditd.rules"
|
||||
notify: update auditd
|
||||
when:
|
||||
- rhel9cis_rule_4_1_13
|
||||
tags:
|
||||
- level2-server
|
||||
- level2-workstation
|
||||
- auditd
|
||||
- patch
|
||||
- rule_4.1.13
|
||||
|
||||
- name: "4.1.14 | L2 | PATCH | Ensure file deletion events by users are collected"
|
||||
debug:
|
||||
msg: "Control being set via Handler 'update auditd' which writes to /etc/audit.d/99_auditd.rules"
|
||||
notify: update auditd
|
||||
when:
|
||||
- rhel9cis_rule_4_1_14
|
||||
tags:
|
||||
- level2-server
|
||||
- level2-workstation
|
||||
- auditd
|
||||
- patch
|
||||
- rule_4.1.14
|
||||
|
||||
- name: "4.1.15 | L2 | PATCH | Ensure kernel module loading and unloading is collected"
|
||||
debug:
|
||||
msg: "Control being set via Handler 'update auditd' which writes to /etc/audit.d/99_auditd.rules"
|
||||
notify: update auditd
|
||||
when:
|
||||
- rhel9cis_rule_4_1_15
|
||||
tags:
|
||||
- level2-server
|
||||
- level2-workstation
|
||||
- auditd
|
||||
- patch
|
||||
- rule_4.1.15
|
||||
|
||||
- name: "4.1.16 | L2 | PATCH | Ensure system administrator actions (sudolog) are collected"
|
||||
debug:
|
||||
msg: "Control being set via Handler 'update auditd' which writes to /etc/audit.d/99_auditd.rules"
|
||||
notify: update auditd
|
||||
when:
|
||||
- rhel9cis_rule_4_1_16
|
||||
tags:
|
||||
- level2-server
|
||||
- level2-workstation
|
||||
- auditd
|
||||
- patch
|
||||
- rule_4.1.16
|
||||
|
||||
- name: "4.1.17 | L2 | PATCH | Ensure the audit configuration is immutable"
|
||||
debug:
|
||||
msg: "Control being set via Handler 'update auditd' which writes to /etc/audit.d/99_auditd.rules"
|
||||
notify: update auditd
|
||||
when:
|
||||
- rhel9cis_rule_4_1_17
|
||||
tags:
|
||||
- level2-server
|
||||
- level2-workstation
|
||||
- auditd
|
||||
- patch
|
||||
- rule_4.1.17
|
||||
177
tasks/section_4/cis_4.2.1.x.yml
Normal file
177
tasks/section_4/cis_4.2.1.x.yml
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
---
|
||||
|
||||
- name: "4.2.1.1 | L1 | PATCH | Ensure rsyslog installed"
|
||||
package:
|
||||
name: rsyslog
|
||||
state: present
|
||||
when:
|
||||
- "'rsyslog' not in ansible_facts.packages"
|
||||
- rhel9cis_rule_4_2_1_1
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- patch
|
||||
- rule_4.2.1.1
|
||||
|
||||
- name: "4.2.1.2 | L1 | PATCH | Ensure rsyslog Service is enabled"
|
||||
service:
|
||||
name: rsyslog
|
||||
enabled: yes
|
||||
when:
|
||||
- rhel9cis_rule_4_2_1_2
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- patch
|
||||
- rsyslog
|
||||
- rule_4.2.1.2
|
||||
|
||||
- name: "4.2.1.3 | L1 | PATCH | Ensure rsyslog default file permissions configured"
|
||||
lineinfile:
|
||||
dest: /etc/rsyslog.conf
|
||||
regexp: '^\$FileCreateMode'
|
||||
line: '$FileCreateMode 0640'
|
||||
notify: restart rsyslog
|
||||
when:
|
||||
- rhel9cis_rule_4_2_1_3
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- patch
|
||||
- rule_4.2.1.3
|
||||
|
||||
- name: "4.2.1.4 | L1 | PATCH | Ensure logging is configured"
|
||||
block:
|
||||
- name: "4.2.1.4 | L1 | AUDIT | Ensure logging is configured | rsyslog current config message out"
|
||||
command: cat /etc/rsyslog.conf
|
||||
become: yes
|
||||
changed_when: false
|
||||
failed_when: no
|
||||
check_mode: no
|
||||
register: rhel_09_4_2_1_4_audit
|
||||
|
||||
- name: "4.2.1.4 | L1 | AUDIT | Ensure logging is configured | rsyslog current config message out"
|
||||
debug:
|
||||
msg:
|
||||
- "These are the current logging configurations for rsyslog, please review:"
|
||||
- "{{ rhel_09_4_2_1_4_audit.stdout_lines }}"
|
||||
|
||||
- name: "4.2.1.4 | L1 | PATCH | Ensure logging is configured | mail.* log setting"
|
||||
blockinfile:
|
||||
path: /etc/rsyslog.conf
|
||||
state: present
|
||||
marker: "# {mark} MAIL LOG SETTINGS (ANSIBLE MANAGED)"
|
||||
block: |
|
||||
# mail logging additions to meet CIS standards
|
||||
mail.* -/var/log/mail
|
||||
mail.info -/var/log/mail.info
|
||||
mail.warning -/var/log/mail.warning
|
||||
mail.err /var/log/mail.err
|
||||
insertafter: '# Log all the mail messages in one place.'
|
||||
notify: restart rsyslog
|
||||
when: rhel9cis_rsyslog_ansiblemanaged
|
||||
|
||||
- name: "4.2.1.4 | L1 | PATCH | Ensure logging is configured | news.crit log setting"
|
||||
blockinfile:
|
||||
path: /etc/rsyslog.conf
|
||||
state: present
|
||||
marker: "# {mark} NEWS LOG SETTINGS (ANSIBLE MANAGED)"
|
||||
block: |
|
||||
# news logging additions to meet CIS standards
|
||||
news.crit -/var/log/news/news.crit
|
||||
news.notice -/var/log/news/news.crit
|
||||
insertafter: '# Save news errors of level crit and higher in a special file.'
|
||||
notify: restart rsyslog
|
||||
when: rhel9cis_rsyslog_ansiblemanaged
|
||||
|
||||
- name: "4.2.1.4 | L1 | PATCH | Ensure logging is configured | Misc. log setting"
|
||||
blockinfile:
|
||||
path: /etc/rsyslog.conf
|
||||
state: present
|
||||
marker: "# {mark} MISC. LOG SETTINGS (ANSIBLE MANAGED)"
|
||||
block: |
|
||||
# misc. logging additions to meet CIS standards
|
||||
*.=warning;*.=err -/var/log/warn
|
||||
*.crit /var/log/warn
|
||||
*.*;mail.none;news.none /var/log/messages
|
||||
insertafter: '#### RULES ####'
|
||||
notify: restart rsyslog
|
||||
when: rhel9cis_rsyslog_ansiblemanaged
|
||||
|
||||
- name: "4.2.1.4 | L1 | PATCH | Ensure logging is configured | Local log settings"
|
||||
blockinfile:
|
||||
path: /etc/rsyslog.conf
|
||||
state: present
|
||||
marker: "#{mark} LOCAL LOG SETTINGS (ANSIBLE MANAGED)"
|
||||
block: |
|
||||
# local log settings
|
||||
local0,local1.* -/var/log/localmessages
|
||||
local2,local3.* -/var/log/localmessages
|
||||
local4,local5.* -/var/log/localmessages
|
||||
local6,local7.* -/var/log/localmessages
|
||||
*.emrg :omusrmsg:*
|
||||
insertafter: '#### RULES ####'
|
||||
notify: restart rsyslog
|
||||
when:
|
||||
- rhel9cis_rule_4_2_1_4
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- patch
|
||||
- rsyslog
|
||||
- rule_4.2.1.4
|
||||
|
||||
- name: "4.2.1.5 | L1 | PATCH | Ensure rsyslog is configured to send logs to a remote log host"
|
||||
blockinfile:
|
||||
path: /etc/rsyslog.conf
|
||||
state: present
|
||||
block: |
|
||||
# remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional
|
||||
*.* @@{{ rhel9cis_remote_log_server }}
|
||||
insertafter: EOF
|
||||
register: result
|
||||
failed_when:
|
||||
- result is failed
|
||||
- result.rc != 257
|
||||
notify: restart rsyslog
|
||||
when:
|
||||
- rhel9cis_rule_4_2_1_5
|
||||
- rhel9cis_remote_log_server is defined
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- patch
|
||||
- rule_4.2.1.5
|
||||
- rsyslog
|
||||
|
||||
- name: "4.2.1.6 | L1 | PATCH | Ensure remote rsyslog messages are only accepted on designated log hosts."
|
||||
block:
|
||||
- name: "4.2.1.6 | L1 | PATCH | Ensure remote rsyslog messages are only accepted on designated log hosts. | When not log host"
|
||||
replace:
|
||||
path: /etc/rsyslog.conf
|
||||
regexp: '({{ item }})'
|
||||
replace: '#\1'
|
||||
notify: restart rsyslog
|
||||
with_items:
|
||||
- '^(\$ModLoad imtcp)'
|
||||
- '^(\$InputTCPServerRun)'
|
||||
when: not rhel9cis_system_is_log_server
|
||||
|
||||
- name: "4.2.1.6 | L1 | PATCH | Ensure remote rsyslog messages are only accepted on designated log hosts. | When log host"
|
||||
replace:
|
||||
path: /etc/rsyslog.conf
|
||||
regexp: '^#(.*{{ item }}.*)'
|
||||
replace: '\1'
|
||||
notify: restart rsyslog
|
||||
with_items:
|
||||
- 'ModLoad imtcp'
|
||||
- 'InputTCPServerRun'
|
||||
when: rhel9cis_system_is_log_server
|
||||
when:
|
||||
- rhel9cis_rule_4_2_1_6
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- patch
|
||||
- rule_4.2.1.6
|
||||
- rsyslog
|
||||
43
tasks/section_4/cis_4.2.2.x.yml
Normal file
43
tasks/section_4/cis_4.2.2.x.yml
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
---
|
||||
|
||||
- name: "4.2.2.1 | L1 | PATCH | Ensure journald is configured to send logs to rsyslog"
|
||||
lineinfile:
|
||||
dest: /etc/systemd/journald.conf
|
||||
regexp: "^#ForwardToSyslog=|^ForwardToSyslog="
|
||||
line: ForwardToSyslog=yes
|
||||
state: present
|
||||
when:
|
||||
- rhel9cis_rule_4_2_2_1
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- patch
|
||||
- rule_4.2.2.1
|
||||
|
||||
- name: "4.2.2.2 | L1 | PATCH | Ensure journald is configured to compress large log files"
|
||||
lineinfile:
|
||||
dest: /etc/systemd/journald.conf
|
||||
regexp: "^#Compress=|^Compress="
|
||||
line: Compress=yes
|
||||
state: present
|
||||
when:
|
||||
- rhel9cis_rule_4_2_2_2
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- patch
|
||||
- rule_4.2.2.2
|
||||
|
||||
- name: "4.2.2.3 | L1 | PATCH | Ensure journald is configured to write logfiles to persistent disk"
|
||||
lineinfile:
|
||||
dest: /etc/systemd/journald.conf
|
||||
regexp: "^#Storage=|^Storage="
|
||||
line: Storage=persistent
|
||||
state: present
|
||||
when:
|
||||
- rhel9cis_rule_4_2_2_3
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- patch
|
||||
- rule_4.2.2.3
|
||||
13
tasks/section_4/cis_4.2.3.yml
Normal file
13
tasks/section_4/cis_4.2.3.yml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
|
||||
- name: "4.2.3 | L1 | PATCH | Ensure permissions on all logfiles are configured"
|
||||
command: find /var/log -type f -exec chmod g-wx,o-rwx "{}" +
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
when:
|
||||
- rhel9cis_rule_4_2_3
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- patch
|
||||
- rule_4.2.3
|
||||
24
tasks/section_4/cis_4.3.yml
Normal file
24
tasks/section_4/cis_4.3.yml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
|
||||
- name: "4.3 | L1 | PATCH | Ensure logrotate is configured"
|
||||
block:
|
||||
- name: "4.3 | L1 | AUDIT | Ensure logrotate is configured | Get logrotate settings"
|
||||
find:
|
||||
paths: /etc/logrotate.d/
|
||||
register: log_rotates
|
||||
|
||||
- name: "4.3 | L1 | PATCH | Ensure logrotate is configured"
|
||||
replace:
|
||||
path: "{{ item.path }}"
|
||||
regexp: '^(\s*)(daily|weekly|monthly|yearly)$'
|
||||
replace: "\\1{{ rhel9cis_logrotate }}"
|
||||
with_items:
|
||||
- "{{ log_rotates.files }}"
|
||||
- { path: "/etc/logrotate.conf" }
|
||||
when:
|
||||
- rhel9cis_rule_4_3
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
- patch
|
||||
- rule_4.3
|
||||
23
tasks/section_4/main.yml
Normal file
23
tasks/section_4/main.yml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
|
||||
- name: "SECTION | 4.1| Configure System Accounting (auditd)"
|
||||
include: cis_4.1.1.x.yml
|
||||
|
||||
- name: "SECTION | 4.1.2.x| Configure Data Retention"
|
||||
include: cis_4.1.2.x.yml
|
||||
|
||||
- name: "SECTION | 4.1.x| Auditd rules"
|
||||
include: cis_4.1.x.yml
|
||||
|
||||
- name: "SECTION | 4.2.x| Configure Logging"
|
||||
include: cis_4.2.1.x.yml
|
||||
when: rhel9cis_syslog == 'rsyslog'
|
||||
|
||||
- name: "SECTION | 4.2.2.x| Configure journald"
|
||||
include: cis_4.2.2.x.yml
|
||||
|
||||
- name: "SECTION | 4.2.3 | Configure logile perms"
|
||||
include: cis_4.2.3.yml
|
||||
|
||||
- name: "SECTION | 4.3 | Configure logrotate"
|
||||
include: cis_4.3.yml
|
||||
Loading…
Add table
Add a link
Reference in a new issue