4
0
Fork 0

Merge pull request #37 from ansible-lockdown/auditd_improvements

Auditd improvements, workflow updates Oracle Support
This commit is contained in:
uk-bolly 2023-03-10 16:19:17 +00:00 committed by GitHub
commit cd66d451db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 150 additions and 108 deletions

View file

@ -1,9 +1,12 @@
---
parseable: true parseable: true
quiet: true quiet: true
skip_list: skip_list:
- 'schema' - 'schema'
- 'no-changed-when' - 'no-changed-when'
- 'var-spacing' - 'var-spacing'
- 'fqcn-builtins'
- 'experimental' - 'experimental'
- 'name[play]' - 'name[play]'
- 'name[casing]' - 'name[casing]'

View file

@ -87,13 +87,6 @@ jobs:
run: sleep 60s run: sleep 60s
shell: bash shell: bash
# Set up requirements for random root password CIS 5.6.6
- name: add urandom passwd to root account
shell: bash
working-directory: .github/workflows
run: |
ANSIBLE_HOST_KEY_CHECKING=False && ansible all -i hosts.yml -m shell -a "cat /dev/urandom | tr -dc [:print:] | head -c50 | passwd --stdin root" -b --private-key .ssh/github_actions.pem
# Run the ansible playbook # Run the ansible playbook
- name: Run_Ansible_Playbook - name: Run_Ansible_Playbook
uses: arillso/action.playbook@master uses: arillso/action.playbook@master

View file

@ -77,8 +77,8 @@ resource "local_file" "inventory" {
setup_audit: true setup_audit: true
run_audit: true run_audit: true
system_is_ec2: true system_is_ec2: true
audit_git_version: devel
skip_reboot: false skip_reboot: false
rhel9cis_rule_5_6_6: false # skip root passwd check and keys only
EOF EOF
} }

View file

@ -1,29 +1,31 @@
--- ---
ignore: |
tests/
molecule/
.github/
.gitlab-ci.yml
*molecule.yml
extends: default extends: default
ignore: |
tests/
molecule/
.github/
.gitlab-ci.yml
*molecule.yml
rules: rules:
braces: indentation:
max-spaces-inside: 1 # Requiring 4 space indentation
level: error spaces: 4
brackets: # Requiring consistent indentation within a file, either indented or not
max-spaces-inside: 1 indent-sequences: consistent
level: error braces:
indentation: max-spaces-inside: 1
indent-sequences: consistent level: error
level: error brackets:
line-length: disable max-spaces-inside: 1
key-duplicates: enable level: error
new-line-at-end-of-file: enable line-length: disable
new-lines: key-duplicates: enable
type: unix new-line-at-end-of-file: enable
trailing-spaces: enable new-lines:
truthy: type: unix
allowed-values: ['true', 'false'] trailing-spaces: enable
check-keys: true truthy:
allowed-values: ['true', 'false']
check-keys: false

View file

@ -1,5 +1,15 @@
# Changes to rhel9CIS # Changes to rhel9CIS
## 1.0.3
Update to auditd components improve idempotency and tidy up
Added a warning to check diff if any changes to template file (if template file exists) else its new.
workflow update to remove the urandom update
skip 5.6.6 root password check
variable naming
OracleLinux support added
#38 journald restart amendment thanks to @bdwyertech
## 1.0.2 ## 1.0.2
thanks to @smatterchew thanks to @smatterchew
@ -7,6 +17,7 @@ thanks to @smatterchew
thanks to @I-am-MoS thanks to @I-am-MoS
#34 create user.cfg if not present #34 create user.cfg if not present
Aligned benchmark audit version with remediate release Aligned benchmark audit version with remediate release
## 1.0.1 ## 1.0.1

View file

@ -36,6 +36,7 @@ To use release version please point to main branch
RHEL 9 RHEL 9
Almalinux 9 Almalinux 9
Rocky 9 Rocky 9
OracleLinux 9
ansible 2.10 ansible 2.10
jmespath jmespath

View file

@ -464,9 +464,9 @@ rhel9cis_ftp_client: false
## Section3 vars ## Section3 vars
## Sysctl ## Sysctl
sysctl_update: false rhel9cis_sysctl_update: false
flush_ipv4_route: false rhel9cis_flush_ipv4_route: false
flush_ipv6_route: false rhel9cis_flush_ipv6_route: false
### Firewall Service - either firewalld, iptables, or nftables ### Firewall Service - either firewalld, iptables, or nftables
#### Some control allow for services to be removed or masked #### Some control allow for services to be removed or masked
@ -512,7 +512,7 @@ rhel9cis_max_log_file_size: 10
update_audit_template: false update_audit_template: false
## Advanced option found in auditd post ## Advanced option found in auditd post
allow_auditd_uid_user_exclusions: false rhel9cis_allow_auditd_uid_user_exclusions: false
# This can be used to configure other keys in auditd.conf # This can be used to configure other keys in auditd.conf

View file

@ -13,7 +13,7 @@
sysctl_set: true sysctl_set: true
ignore_errors: true # noqa ignore-errors ignore_errors: true # noqa ignore-errors
when: when:
- flush_ipv4_route - rhel9cis_flush_ipv4_route
- not system_is_container - not system_is_container
- name: Sysctl flush ipv6 route table - name: Sysctl flush ipv6 route table
@ -22,13 +22,13 @@
value: '1' value: '1'
sysctl_set: true sysctl_set: true
when: when:
- flush_ipv6_route - rhel9cis_flush_ipv6_route
- not system_is_container - not system_is_container
- name: Systemd restart tmp.mount - name: Systemd restart tmp.mount
ansible.builtin.systemd: ansible.builtin.systemd:
name: tmp.mount name: tmp.mount
daemon_Reload: true daemon_reload: true
enabled: true enabled: true
masked: false masked: false
state: Reloaded state: Reloaded

View file

@ -1,8 +1,9 @@
--- ---
- name: POST | AUDITD | Apply auditd template will for section 4.1.3 - only required rules will be added | stat file - name: POST | AUDITD | Apply auditd template will for section 4.1.3 - only required rules will be added | stat file
ansible.builtin.stat: ansible.builtin.stat:
path: /etc/audit/rules.d/99_auditd.rules path: /etc/audit/rules.d/99_auditd.rules
register: auditd_file register: rhel9cis_auditd_file
- name: POST | AUDITD | Apply auditd template will for section 4.1.3 - only required rules will be added | setup file - name: POST | AUDITD | Apply auditd template will for section 4.1.3 - only required rules will be added | setup file
ansible.builtin.template: ansible.builtin.template:
@ -11,17 +12,25 @@
owner: root owner: root
group: root group: root
mode: 0640 mode: 0640
diff: "{{ auditd_file.stat.exists }}" # Only run diff if not a new file diff: "{{ rhel9cis_auditd_file.stat.exists }}" # Only run diff if not a new file
register: audit_rules_updated register: rhel9cis_auditd_template_updated
notify: notify:
- Auditd immutable check - Auditd immutable check
- Audit immutable fact - Audit immutable fact
- Restart auditd - Restart auditd
- name: POST | AUDITD | Add Warning count for changes to template file | Warn Count # noqa: no-handler
ansible.builtin.import_tasks: warning_facts.yml
vars:
warn_control_id: 'Auditd template updated, see diff output for details'
when:
- rhel9cis_auditd_template_updated.changed
- rhel9cis_auditd_file.stat.exists
- name: POST | AUDITD | Apply auditd template will for section 4.1.3 - only required rules will be added | stat file - name: POST | AUDITD | Apply auditd template will for section 4.1.3 - only required rules will be added | stat file
ansible.builtin.stat: ansible.builtin.stat:
path: /etc/audit/rules.d/98_auditd_exceptions.rules path: /etc/audit/rules.d/98_auditd_exceptions.rules
register: auditd_exception_file register: rhel9cis_auditd_exception_file
- name: POST | Set up auditd user logging exceptions | setup file - name: POST | Set up auditd user logging exceptions | setup file
ansible.builtin.template: ansible.builtin.template:
@ -30,8 +39,8 @@
owner: root owner: root
group: root group: root
mode: 0640 mode: 0640
diff: "{{ auditd_exception_file.stat.exists }}" diff: "{{ rhel9cis_auditd_exception_file.stat.exists }}"
notify: Restart auditd notify: Restart auditd
when: when:
- allow_auditd_uid_user_exclusions - rhel9cis_allow_auditd_uid_user_exclusions
- rhel9cis_auditd_uid_exclude | length > 0 - rhel9cis_auditd_uid_exclude | length > 0

View file

@ -1,13 +1,13 @@
--- ---
# Post tasks # Post tasks
- name: Gather the package facts after remediation - name: POST | Gather the package facts after remediation
ansible.builtin.package_facts: ansible.builtin.package_facts:
manager: auto manager: auto
tags: tags:
- always - always
- name: Update sysctl - name: POST | Update sysctl
ansible.builtin.template: ansible.builtin.template:
src: "etc/sysctl.d/{{ item }}.j2" src: "etc/sysctl.d/{{ item }}.j2"
dest: "/etc/sysctl.d/{{ item }}" dest: "/etc/sysctl.d/{{ item }}"
@ -22,7 +22,7 @@
- 60-netipv4_sysctl.conf - 60-netipv4_sysctl.conf
- 60-netipv6_sysctl.conf - 60-netipv6_sysctl.conf
when: when:
- sysctl_update - rhel9cis_sysctl_update
- not system_is_container - not system_is_container
- "'procps-ng' in ansible_facts.packages" - "'procps-ng' in ansible_facts.packages"

View file

@ -120,11 +120,12 @@
- name: "PRELIM | Update to latest gpg keys" - name: "PRELIM | Update to latest gpg keys"
ansible.builtin.package: ansible.builtin.package:
name: "{{ ansible_distribution | lower }}-gpg-keys" name: "{{ gpg_key_package }}"
state: latest state: latest
when: when:
- rhel9cis_rule_1_2_4 - rhel9cis_rule_1_2_4
- ansible_distribution != 'RedHat' - ansible_distribution != 'RedHat'
- ansible_distribution != 'OracleLinux'
- name: "PRELIM | Section 4.1 | Configure System Accounting (auditd)" - name: "PRELIM | Section 4.1 | Configure System Accounting (auditd)"
ansible.builtin.package: ansible.builtin.package:

View file

@ -112,6 +112,7 @@
when: when:
- rhel9cis_rule_1_2_4 - rhel9cis_rule_1_2_4
- not rhel9cis_rhel_default_repo or ansible_distribution != 'RedHat' - not rhel9cis_rhel_default_repo or ansible_distribution != 'RedHat'
- ansible_distribution != 'OracleLinux'
tags: tags:
- level1-server - level1-server
- level1-workstation - level1-workstation

View file

@ -57,7 +57,7 @@
- name: "1.3.3 | Ensure cryptographic mechanisms are used to protect the integrity of audit tools" - name: "1.3.3 | Ensure cryptographic mechanisms are used to protect the integrity of audit tools"
ansible.builtin.blockinfile: ansible.builtin.blockinfile:
path: /etc/aide.conf path: /etc/aide.conf
marker: "# {mark} Audit tools (CIS - Ansible)" marker: "# {mark} Audit tools - CIS benchmark - Ansible-lockdown"
block: | block: |
/sbin/auditctl p+i+n+u+g+s+b+acl+xattrs+sha512 /sbin/auditctl p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/auditd p+i+n+u+g+s+b+acl+xattrs+sha512 /sbin/auditd p+i+n+u+g+s+b+acl+xattrs+sha512

View file

@ -28,7 +28,7 @@
mode: "{{ item.mode }}" mode: "{{ item.mode }}"
state: touch state: touch
modification_time: preserve modification_time: preserve
acess_time: preserve access_time: preserve
loop: loop:
- { path: 'grub.cfg', mode: '0700' } - { path: 'grub.cfg', mode: '0700' }
- { path: 'grubenv', mode: '0600' } - { path: 'grubenv', mode: '0600' }

View file

@ -33,7 +33,7 @@
block: block:
- name: "1.5.3 | PATCH | Ensure address space layout randomization (ASLR) is enabled" - name: "1.5.3 | PATCH | Ensure address space layout randomization (ASLR) is enabled"
ansible.builtin.set_fact: ansible.builtin.set_fact:
sysctl_update: true rhel9cis_sysctl_update: true
- name: "1.5.3 | PATCH | Ensure address space layout randomization (ASLR) is enabled" - name: "1.5.3 | PATCH | Ensure address space layout randomization (ASLR) is enabled"
ansible.builtin.debug: ansible.builtin.debug:

View file

@ -6,8 +6,8 @@
block: block:
- name: "3.1.1 | PATCH | Ensure IPv6 status is identified | refresh" - name: "3.1.1 | PATCH | Ensure IPv6 status is identified | refresh"
ansible.builtin.set_fact: ansible.builtin.set_fact:
sysctl_update: true rhel9cis_sysctl_update: true
flush_ipv6_route: true rhel9cis_flush_ipv6_route: true
- name: "3.1.1 | PATCH | Ensure IPv6 status is identified | disable" - name: "3.1.1 | PATCH | Ensure IPv6 status is identified | disable"
ansible.builtin.debug: ansible.builtin.debug:

View file

@ -4,8 +4,8 @@
block: block:
- name: "3.2.1 | PATCH | Ensure IP forwarding is disabled | Disable IPv4 forwarding | Set Fact" - name: "3.2.1 | PATCH | Ensure IP forwarding is disabled | Disable IPv4 forwarding | Set Fact"
ansible.builtin.set_fact: ansible.builtin.set_fact:
sysctl_update: true rhel9cis_sysctl_update: true
flush_ipv4_route: true rhel9cis_flush_ipv4_route: true
- name: "3.2.1 | PATCH | Ensure IP forwarding is disabled | Disable IPv4 forwarding" - name: "3.2.1 | PATCH | Ensure IP forwarding is disabled | Disable IPv4 forwarding"
ansible.builtin.debug: ansible.builtin.debug:
@ -15,7 +15,7 @@
block: block:
- name: "3.2.1 | PATCH | Ensure IP forwarding is disabled | Disable IPv6 forwarding | Set Fact" - name: "3.2.1 | PATCH | Ensure IP forwarding is disabled | Disable IPv6 forwarding | Set Fact"
ansible.builtin.set_fact: ansible.builtin.set_fact:
flush_ipv6_route: true rhel9cis_flush_ipv6_route: true
- name: "3.2.1 | PATCH | Ensure IP forwarding is disabled | Disable IPv6 forwarding" - name: "3.2.1 | PATCH | Ensure IP forwarding is disabled | Disable IPv6 forwarding"
ansible.builtin.debug: ansible.builtin.debug:
@ -36,8 +36,8 @@
block: block:
- name: "3.2.2 | PATCH | Ensure packet redirect sending is disabled | Set Fact" - name: "3.2.2 | PATCH | Ensure packet redirect sending is disabled | Set Fact"
ansible.builtin.set_fact: ansible.builtin.set_fact:
sysctl_update: true rhel9cis_sysctl_update: true
flush_ipv4_route: true rhel9cis_flush_ipv4_route: true
- name: "3.2.2 | PATCH | Ensure packet redirect sending is disabled" - name: "3.2.2 | PATCH | Ensure packet redirect sending is disabled"
ansible.builtin.debug: ansible.builtin.debug:
msg: "Control being set via Handler 'update sysctl' which writes to /etc/sysctl.d/60-netipv4_sysctl.conf" msg: "Control being set via Handler 'update sysctl' which writes to /etc/sysctl.d/60-netipv4_sysctl.conf"

View file

@ -4,8 +4,8 @@
block: block:
- name: "3.3.1 | PATCH | Ensure source routed packets are not accepted | IPv4 | Set Fact" - name: "3.3.1 | PATCH | Ensure source routed packets are not accepted | IPv4 | Set Fact"
ansible.builtin.set_fact: ansible.builtin.set_fact:
sysctl_update: true rhel9cis_sysctl_update: true
flush_ipv4_route: true rhel9cis_flush_ipv4_route: true
- name: "3.3.1 | PATCH | Ensure source routed packets are not accepted | IPv4" - name: "3.3.1 | PATCH | Ensure source routed packets are not accepted | IPv4"
ansible.builtin.debug: ansible.builtin.debug:
msg: "Control being set via Handler 'update sysctl' which writes to /etc/sysctl.d/60-netipv4_sysctl.conf" msg: "Control being set via Handler 'update sysctl' which writes to /etc/sysctl.d/60-netipv4_sysctl.conf"
@ -14,7 +14,7 @@
block: block:
- name: "3.3.1 | PATCH | Ensure source routed packets are not accepted | IPv6 | Set Fact" - name: "3.3.1 | PATCH | Ensure source routed packets are not accepted | IPv6 | Set Fact"
ansible.builtin.set_fact: ansible.builtin.set_fact:
flush_ipv6_route: true rhel9cis_flush_ipv6_route: true
- name: "3.3.1 | PATCH | Ensure source routed packets are not accepted | IPv6" - name: "3.3.1 | PATCH | Ensure source routed packets are not accepted | IPv6"
ansible.builtin.debug: ansible.builtin.debug:
@ -33,8 +33,8 @@
block: block:
- name: "3.3.2 | PATCH | Ensure ICMP redirects are not accepted | IPv4 | Set Fact" - name: "3.3.2 | PATCH | Ensure ICMP redirects are not accepted | IPv4 | Set Fact"
ansible.builtin.set_fact: ansible.builtin.set_fact:
sysctl_update: true rhel9cis_sysctl_update: true
flush_ipv4_route: true rhel9cis_flush_ipv4_route: true
- name: "3.3.2 | PATCH | Ensure ICMP redirects are not accepted | IPv4" - name: "3.3.2 | PATCH | Ensure ICMP redirects are not accepted | IPv4"
ansible.builtin.debug: ansible.builtin.debug:
@ -44,7 +44,7 @@
block: block:
- name: "3.3.2 | PATCH | Ensure ICMP redirects are not accepted | IPv6 | Set Fact" - name: "3.3.2 | PATCH | Ensure ICMP redirects are not accepted | IPv6 | Set Fact"
ansible.builtin.set_fact: ansible.builtin.set_fact:
flush_ipv6_route: true rhel9cis_flush_ipv6_route: true
- name: "3.3.2 | PATCH | Ensure ICMP redirects are not accepted | IPv6" - name: "3.3.2 | PATCH | Ensure ICMP redirects are not accepted | IPv6"
ansible.builtin.debug: ansible.builtin.debug:
@ -63,8 +63,8 @@
block: block:
- name: "3.3.3 | PATCH | Ensure secure ICMP redirects are not accepted | Set Fact" - name: "3.3.3 | PATCH | Ensure secure ICMP redirects are not accepted | Set Fact"
ansible.builtin.set_fact: ansible.builtin.set_fact:
sysctl_update: true rhel9cis_sysctl_update: true
flush_ipv4_route: true rhel9cis_flush_ipv4_route: true
- name: "3.3.3 | PATCH | Ensure secure ICMP redirects are not accepted" - name: "3.3.3 | PATCH | Ensure secure ICMP redirects are not accepted"
ansible.builtin.debug: ansible.builtin.debug:
@ -82,8 +82,8 @@
block: block:
- name: "3.3.4 | PATCH | Ensure suspicious packets are logged | Set Fact" - name: "3.3.4 | PATCH | Ensure suspicious packets are logged | Set Fact"
ansible.builtin.set_fact: ansible.builtin.set_fact:
sysctl_update: true rhel9cis_sysctl_update: true
flush_ipv4_route: true rhel9cis_flush_ipv4_route: true
- name: "3.3.4 | PATCH | Ensure suspicious packets are logged" - name: "3.3.4 | PATCH | Ensure suspicious packets are logged"
ansible.builtin.debug: ansible.builtin.debug:
@ -101,8 +101,8 @@
block: block:
- name: "3.3.5 | PATCH | Ensure broadcast ICMP requests are ignored | Set Fact" - name: "3.3.5 | PATCH | Ensure broadcast ICMP requests are ignored | Set Fact"
ansible.builtin.set_fact: ansible.builtin.set_fact:
sysctl_update: true rhel9cis_sysctl_update: true
flush_ipv4_route: true rhel9cis_flush_ipv4_route: true
- name: 3.3.5 | PATCH | Ensure broadcast ICMP requests are ignored" - name: 3.3.5 | PATCH | Ensure broadcast ICMP requests are ignored"
ansible.builtin.debug: ansible.builtin.debug:
@ -120,8 +120,8 @@
block: block:
- name: "3.3.6 | PATCH | Ensure bogus ICMP responses are ignored | Set Fact" - name: "3.3.6 | PATCH | Ensure bogus ICMP responses are ignored | Set Fact"
ansible.builtin.set_fact: ansible.builtin.set_fact:
sysctl_update: true rhel9cis_sysctl_update: true
flush_ipv4_route: true rhel9cis_flush_ipv4_route: true
- name: "3.3.6 | PATCH | Ensure bogus ICMP responses are ignored" - name: "3.3.6 | PATCH | Ensure bogus ICMP responses are ignored"
ansible.builtin.debug: ansible.builtin.debug:
@ -139,8 +139,8 @@
block: block:
- name: "3.3.7 | PATCH | Ensure Reverse Path Filtering is enabled | Set Fact" - name: "3.3.7 | PATCH | Ensure Reverse Path Filtering is enabled | Set Fact"
ansible.builtin.set_fact: ansible.builtin.set_fact:
sysctl_update: true rhel9cis_sysctl_update: true
flush_ipv4_route: true rhel9cis_flush_ipv4_route: true
- name: "3.3.7 | PATCH | Ensure Reverse Path Filtering is enabled" - name: "3.3.7 | PATCH | Ensure Reverse Path Filtering is enabled"
ansible.builtin.debug: ansible.builtin.debug:
@ -158,8 +158,8 @@
block: block:
- name: "3.3.8 | PATCH | Ensure TCP SYN Cookies is enabled | Set Fact" - name: "3.3.8 | PATCH | Ensure TCP SYN Cookies is enabled | Set Fact"
ansible.builtin.set_fact: ansible.builtin.set_fact:
sysctl_update: true rhel9cis_sysctl_update: true
flush_ipv4_route: true rhel9cis_flush_ipv4_route: true
- name: "3.3.8 | PATCH | Ensure TCP SYN Cookies is enabled" - name: "3.3.8 | PATCH | Ensure TCP SYN Cookies is enabled"
ansible.builtin.debug: ansible.builtin.debug:
@ -177,8 +177,8 @@
block: block:
- name: "3.3.9 | PATCH | Ensure IPv6 router advertisements are not accepted | IPv6 | Set Fact" - name: "3.3.9 | PATCH | Ensure IPv6 router advertisements are not accepted | IPv6 | Set Fact"
ansible.builtin.set_fact: ansible.builtin.set_fact:
sysctl_update: true rhel9cis_sysctl_update: true
flush_ipv6_route: true rhel9cis_flush_ipv6_route: true
- name: "3.3.9 | PATCH | Ensure IPv6 router advertisements are not accepted | IPv6" - name: "3.3.9 | PATCH | Ensure IPv6 router advertisements are not accepted | IPv6"
ansible.builtin.debug: ansible.builtin.debug:

View file

@ -8,16 +8,22 @@
block: block:
- name: "4.1.4.1 | AUDIT | Ensure audit log files are mode 0640 or less permissive | discover file" - name: "4.1.4.1 | AUDIT | Ensure audit log files are mode 0640 or less permissive | discover file"
ansible.builtin.shell: grep ^log_file /etc/audit/auditd.conf | awk '{ print $NF }' ansible.builtin.shell: grep ^log_file /etc/audit/auditd.conf | awk '{ print $NF }'
register: audit_logfile
changed_when: false changed_when: false
register: audit_discovered_logfile
- name: "4.1.4.1 | AUDIT | Ensure audit log files are mode 0640 or less permissive | stat file"
ansible.builtin.stat:
path: "{{ audit_discovered_logfile.stdout }}"
changed_when: false
register: auditd_logfile
- name: | - name: |
"4.1.4.1 | PATCH | Ensure audit log files are mode 0640 or less permissive" "4.1.4.1 | PATCH | Ensure audit log files are mode 0640 or less permissive"
"4.1.4.2 | PATCH | Ensure only authorized users own audit log files" "4.1.4.2 | PATCH | Ensure only authorized users own audit log files"
"4.1.4.3 | PATCH | Ensure only authorized groups are assigned ownership of audit log files" "4.1.4.3 | PATCH | Ensure only authorized groups are assigned ownership of audit log files"
ansible.builtin.file: ansible.builtin.file:
path: "{{ audit_logfile.stdout }}" path: "{{ audit_discovered_logfile.stdout }}"
mode: 0640 mode: "{% if auditd_logfile.stat.mode != '0600' %}0640{% endif %}"
owner: root owner: root
group: root group: root
when: when:
@ -37,12 +43,12 @@
block: block:
- name: "4.1.4.4 | AUDIT | Ensure the audit log directory is 0750 or more restrictive | get current permissions" - name: "4.1.4.4 | AUDIT | Ensure the audit log directory is 0750 or more restrictive | get current permissions"
ansible.builtin.stat: ansible.builtin.stat:
path: "{{ audit_logfile.stdout | dirname }}" path: "{{ audit_discovered_logfile.stdout | dirname }}"
register: auditlog_dir register: auditlog_dir
- name: "4.1.4.4 | PATCH | Ensure the audit log directory is 0750 or more restrictive | set" - name: "4.1.4.4 | PATCH | Ensure the audit log directory is 0750 or more restrictive | set"
ansible.builtin.file: ansible.builtin.file:
path: "{{ audit_logfile.stdout | dirname }}" path: "{{ audit_discovered_logfile.stdout | dirname }}"
state: directory state: directory
mode: 0750 mode: 0750
when: not auditlog_dir.stat.mode is match('07(0|5)0') when: not auditlog_dir.stat.mode is match('07(0|5)0')

View file

@ -75,7 +75,7 @@
- name: "4.2.1.5 | PATCH | Ensure logging is configured | mail.* log setting" - name: "4.2.1.5 | PATCH | Ensure logging is configured | mail.* log setting"
ansible.builtin.blockinfile: ansible.builtin.blockinfile:
path: /etc/rsyslog.conf path: /etc/rsyslog.conf
marker: "# {mark} MAIL LOG SETTINGS (ANSIBLE MANAGED)" marker: "# {mark} MAIL LOG SETTINGS - CIS benchmark - Ansible-lockdown"
block: | block: |
# mail logging additions to meet CIS standards # mail logging additions to meet CIS standards
mail.* -/var/log/mail mail.* -/var/log/mail
@ -90,7 +90,7 @@
ansible.builtin.blockinfile: ansible.builtin.blockinfile:
path: /etc/rsyslog.conf path: /etc/rsyslog.conf
state: present state: present
marker: "# {mark} NEWS LOG SETTINGS (ANSIBLE MANAGED)" marker: "# {mark} NEWS LOG SETTINGS - CIS benchmark - Ansible-lockdown"
block: | block: |
# news logging additions to meet CIS standards # news logging additions to meet CIS standards
news.crit -/var/log/news/news.crit news.crit -/var/log/news/news.crit
@ -103,7 +103,7 @@
ansible.builtin.blockinfile: ansible.builtin.blockinfile:
path: /etc/rsyslog.conf path: /etc/rsyslog.conf
state: present state: present
marker: "# {mark} MISC. LOG SETTINGS (ANSIBLE MANAGED)" marker: "# {mark} MISC. LOG SETTINGS - CIS benchmark - Ansible-lockdown"
block: | block: |
# misc. logging additions to meet CIS standards # misc. logging additions to meet CIS standards
*.=warning;*.=err -/var/log/warn *.=warning;*.=err -/var/log/warn
@ -117,7 +117,7 @@
ansible.builtin.blockinfile: ansible.builtin.blockinfile:
path: /etc/rsyslog.conf path: /etc/rsyslog.conf
state: present state: present
marker: "#{mark} LOCAL LOG SETTINGS (ANSIBLE MANAGED)" marker: "#{mark} LOCAL LOG SETTINGS - CIS benchmark - Ansible-lockdown"
block: | block: |
# local log settings to meet CIS standards # local log settings to meet CIS standards
local0,local1.* -/var/log/localmessages local0,local1.* -/var/log/localmessages
@ -132,7 +132,7 @@
ansible.builtin.blockinfile: ansible.builtin.blockinfile:
path: /etc/rsyslog.conf path: /etc/rsyslog.conf
state: present state: present
marker: "#{mark} Auth SETTINGS (ANSIBLE MANAGED)" marker: "#{mark} Auth SETTINGS - CIS benchmark - Ansible-lockdown"
block: | block: |
# Private settings to meet CIS standards # Private settings to meet CIS standards
auth,authpriv.* /var/log/secure auth,authpriv.* /var/log/secure
@ -143,7 +143,7 @@
ansible.builtin.blockinfile: ansible.builtin.blockinfile:
path: /etc/rsyslog.conf path: /etc/rsyslog.conf
state: present state: present
marker: "#{mark} Cron SETTINGS (ANSIBLE MANAGED)" marker: "#{mark} Cron SETTINGS - CIS benchmark - Ansible-lockdown"
block: | block: |
# Cron settings to meet CIS standards # Cron settings to meet CIS standards
cron.* /var/log/cron cron.* /var/log/cron

View file

@ -19,7 +19,7 @@
path: /etc/systemd/journal-upload.conf path: /etc/systemd/journal-upload.conf
regexp: "{{ item.regexp }}" regexp: "{{ item.regexp }}"
line: "{{ item.line }}" line: "{{ item.line }}"
notify: Restart systemd_journal_upload notify: Restart journald
loop: loop:
- { regexp: 'URL=', line: 'URL={{ rhel9cis_journal_upload_url }}'} - { regexp: 'URL=', line: 'URL={{ rhel9cis_journal_upload_url }}'}
- { regexp: 'ServerKeyFile=', line: 'ServerKeyFile={{ rhel9cis_journal_upload_serverkeyfile }}'} - { regexp: 'ServerKeyFile=', line: 'ServerKeyFile={{ rhel9cis_journal_upload_serverkeyfile }}'}
@ -106,7 +106,7 @@
path: /etc/systemd/journald.conf path: /etc/systemd/journald.conf
regexp: "^#Compress=|^Compress=" regexp: "^#Compress=|^Compress="
line: Compress=yes line: Compress=yes
notify: Restart systemd_journal_upload notify: Restart journald
when: when:
- rhel9cis_rule_4_2_2_3 - rhel9cis_rule_4_2_2_3
tags: tags:
@ -121,7 +121,7 @@
path: /etc/systemd/journald.conf path: /etc/systemd/journald.conf
regexp: "^#Storage=|^Storage=" regexp: "^#Storage=|^Storage="
line: Storage=persistent line: Storage=persistent
notify: Restart systemd_journal_upload notify: Restart journald
when: when:
- rhel9cis_rule_4_2_2_4 - rhel9cis_rule_4_2_2_4
tags: tags:
@ -137,7 +137,7 @@
path: /etc/systemd/journald.conf path: /etc/systemd/journald.conf
regexp: "^ForwardToSyslog=" regexp: "^ForwardToSyslog="
line: "#ForwardToSyslog=yes" line: "#ForwardToSyslog=yes"
notify: Restart systemd_journal_upload notify: Restart journald
when: when:
- rhel9cis_rule_4_2_2_5 - rhel9cis_rule_4_2_2_5
tags: tags:
@ -153,7 +153,7 @@
path: /etc/systemd/journald.conf path: /etc/systemd/journald.conf
regexp: "{{ item.regexp }}" regexp: "{{ item.regexp }}"
line: "{{ item.line }}" line: "{{ item.line }}"
notify: Restart systemd_journal_upload notify: Restart journald
loop: loop:
- { regexp: '^#SystemMaxUse=|^SystemMaxUse=', line: 'SystemMaxUse={{ rhel9cis_journald_systemmaxuse }}'} - { regexp: '^#SystemMaxUse=|^SystemMaxUse=', line: 'SystemMaxUse={{ rhel9cis_journald_systemmaxuse }}'}
- { regexp: '^#SystemKeepFree=|^SystemKeepFree=', line: 'SystemKeepFree={{ rhel9cis_journald_systemkeepfree }}' } - { regexp: '^#SystemKeepFree=|^SystemKeepFree=', line: 'SystemKeepFree={{ rhel9cis_journald_systemkeepfree }}' }

View file

@ -48,7 +48,7 @@
ansible.builtin.blockinfile: ansible.builtin.blockinfile:
path: "{{ item.path }}" path: "{{ item.path }}"
state: "{{ item.state }}" state: "{{ item.state }}"
marker: "# {mark} CIS 5.6.3 ANSIBLE MANAGED" marker: "# {mark} - CIS benchmark - Ansible-lockdown"
create: true create: true
mode: 0644 mode: 0644
block: | block: |

View file

@ -1,7 +1,10 @@
## This file is managed by Ansible, YOUR CHANGES WILL BE LOST! ## Ansible controlled file
# Added as part of ansible-lockdown CIS baseline
# provided by MindPointGroup LLC
### YOUR CHANGES WILL BE LOST!
# This file contains users whose actions are not logged by auditd # This file contains users whose actions are not logged by auditd
{% if allow_auditd_uid_user_exclusions %} {% if rhel9cis_allow_auditd_uid_user_exclusions %}
{% for user in rhel9cis_auditd_uid_exclude %} {% for user in rhel9cis_auditd_uid_exclude %}
-a never,user -F uid!={{ user }} -F auid!={{ user }} -a never,user -F uid!={{ user }} -F auid!={{ user }}
{% endfor %} {% endfor %}

View file

@ -1,4 +1,7 @@
## This file is managed by Ansible, YOUR CHANGES WILL BE LOST! ## Ansible controlled file
# Added as part of ansible-lockdown CIS baseline
# provided by MindPointGroup LLC
### YOUR CHANGES WILL BE LOST!
# This template will set all of the auditd configurations via a handler in the role in one task instead of individually # This template will set all of the auditd configurations via a handler in the role in one task instead of individually
{% if rhel9cis_rule_4_1_3_1 %} {% if rhel9cis_rule_4_1_3_1 %}

View file

@ -1,5 +1,8 @@
# Run AIDE integrity check # Run AIDE integrity check
## This file is managed by Ansible, YOUR CHANGES WILL BE LOST! ## Ansible controlled file
# Added as part of ansible-lockdown CIS baseline
# provided by MindPointGroup LLC
### YOUR CHANGES WILL BE LOST!
# CIS 1.3.2 # CIS 1.3.2
{{ rhel9cis_aide_cron['aide_minute'] }} {{ rhel9cis_aide_cron['aide_hour'] }} {{ rhel9cis_aide_cron['aide_month'] }} {{ rhel9cis_aide_cron['aide_weekday'] }} {{ rhel9cis_aide_cron['aide_job'] }} {{ rhel9cis_aide_cron['aide_minute'] }} {{ rhel9cis_aide_cron['aide_hour'] }} {{ rhel9cis_aide_cron['aide_month'] }} {{ rhel9cis_aide_cron['aide_weekday'] }} {{ rhel9cis_aide_cron['aide_job'] }}

View file

@ -1,5 +1,5 @@
## Ansible controlled file ## Ansible controlled file
# Added as part of CIS # Added as part of ansible-lockdown CIS baseline
# provided by MindPointGroup LLC # provided by MindPointGroup LLC
# Lock desktop media-handling automount setting # Lock desktop media-handling automount setting

View file

@ -1,5 +1,5 @@
## Ansible controlled file ## Ansible controlled file
# Added as part of CIS # Added as part of ansible-lockdown CIS baseline
# provided by MindPointGroup LLC # provided by MindPointGroup LLC
# Lock desktop media-handling settings # Lock desktop media-handling settings

View file

@ -1,5 +1,5 @@
## Ansible controlled file ## Ansible controlled file
# Added as part of CIS # Added as part of ansible-lockdown CIS baseline
# provided by MindPointGroup LLC # provided by MindPointGroup LLC
[org/gnome/desktop/media-handling] [org/gnome/desktop/media-handling]

View file

@ -1,5 +1,5 @@
## Ansible controlled file ## Ansible controlled file
# Added as part of CIS # Added as part of ansible-lockdown CIS baseline
# provided by MindPointGroup LLC # provided by MindPointGroup LLC
[org/gnome/desktop/media-handling] [org/gnome/desktop/media-handling]

View file

@ -1,5 +1,5 @@
## Ansible controlled file ## Ansible controlled file
# Added as part of CIS # Added as part of ansible-lockdown CIS baseline
# provided by MindPointGroup LLC # provided by MindPointGroup LLC

View file

@ -1,5 +1,5 @@
## Ansible controlled file ## Ansible controlled file
# Added as part of CIS # Added as part of ansible-lockdown CIS baseline
# provided by MindPointGroup LLC # provided by MindPointGroup LLC
# Lock desktop screensaver idle-delay setting # Lock desktop screensaver idle-delay setting

View file

@ -1,5 +1,5 @@
## Ansible controlled file ## Ansible controlled file
# Added as part of CIS # Added as part of ansible-lockdown CIS baseline
# provided by MindPointGroup LLC # provided by MindPointGroup LLC
[org/gnome/login-screen] [org/gnome/login-screen]

4
vars/OracleLinux.yml Normal file
View file

@ -0,0 +1,4 @@
---
# OS Specific Settings
os_gpg_key_pubkey_name: gpg-pubkey-8d8b756f-629e59ec
os_gpg_key_pubkey_content: "Oracle Linux (release key 1) <secalert_us@oracle.com>"

View file

@ -10,3 +10,5 @@ rhel9cis_allowed_crypto_policies:
# Used to control warning summary # Used to control warning summary
warn_control_list: "" warn_control_list: ""
warn_count: 0 warn_count: 0
gpg_key_package: "{{ ansible_distribution | lower }}-gpg-keys"