Skip to content
Open
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
3 changes: 3 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
with_items:
- aidecheck.timer
- aidecheck
- auditd
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure this will not impact Debian tasks


- name: Rebuild module dependencies
command: depmod -a
- name: Reload systemd units
systemd:
daemon_reload: yes
Expand Down
4 changes: 4 additions & 0 deletions tasks/amazon_linux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- name: Amazon Linux 2 | Disable kernal module
include_tasks: filesystem_kernel_modules_al2

50 changes: 50 additions & 0 deletions tasks/filesystem_kernel_modules_al2
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
# Configure Filesystem Kernel Modules (CIS 1.1.1.1 - 1.1.1.8)
# Combined single playbook to disable all unused filesystem kernel modules

- name: "Disable unused filesystem kernel modules"
block:

# ---------------------------------------------------------
# Step 1: Create/update modprobe configuration (blockinfile)
# ---------------------------------------------------------
- name: "Block and blacklist filesystem modules in /etc/modprobe.d/cis.conf"
ansible.builtin.blockinfile:
path: /etc/modprobe.d/cis.conf
create: yes
block: |
install {{ item.name }} /bin/true
blacklist {{ item.name }}
marker: "# {mark} {{ item.name }} module disable"
loop:
- { name: "cramfs", desc: "1.1.1.1 Ensure cramfs kernel module is not available" }
- { name: "freevxfs", desc: "1.1.1.2 Ensure freevxfs kernel module is not available" }
- { name: "hfs", desc: "1.1.1.3 Ensure hfs kernel module is not available" }
- { name: "hfsplus", desc: "1.1.1.4 Ensure hfsplus kernel module is not available" }
- { name: "jffs2", desc: "1.1.1.5 Ensure jffs2 kernel module is not available" }
- { name: "usb-storage", desc: "1.1.1.8 Ensure usb-storage kernel module is not available" }
loop_control:
label: "{{ item.desc }}"
notify: Rebuild module dependencies

# ---------------------------------------------------------
# Step 2: Unload modules if they’re currently loaded
# ---------------------------------------------------------
- name: "Unload filesystem modules if loaded"
become: true
ansible.builtin.command: "modprobe -r {{ item.name }}"
register: unload_result
failed_when: false
changed_when: unload_result.rc == 0
loop:
- { name: "cramfs" }
- { name: "freevxfs" }
- { name: "hfs" }
- { name: "hfsplus" }
- { name: "jffs2" }
- { name: "usb-storage" }
loop_control:
label: "Unload {{ item.name }} module if loaded"

when: ansible_os_family == "RedHat"

19 changes: 11 additions & 8 deletions tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
---
- name: Include CIS Stage Specific vars
include_vars: cis-{{ cis_Stage }}.yaml

- name: Debian realted Specification
include_tasks: configure_Debian.yaml
- name: Ubuntu related Specification
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why Debian tasks change requires

include_tasks: ubuntu.yaml
when:
ansible_os_family == 'Debian'

- name: Centos realted Specification
include_tasks: configure_RedHat.yaml
- name: CentOS related Specification
include_tasks: centos.yaml
when:
ansible_os_family == 'RedHat' and ansible_distribution != 'Amazon'

- name: Amazon Linux 2 related Specification
include_tasks: amazon_linux.yaml
when:
ansible_os_family == 'RedHat'
ansible_distribution == 'Amazon'

# - name: Special purpose services
# include_tasks: services.yaml
Expand All @@ -35,3 +37,4 @@

# - name: Ensure dccp and sctp is disabled
# include_tasks: network_protocol_and_unusedFilesystem.yaml