ASIMP :: Security Platform
ANSIBLE SYSTEM INTEGRITY MANAGEMENT PLATFORM // baselines & hardening
MODE:

Documentation

Home Gitbook & dsom summary index Asimp for ai agents: deep state of mind (dsom) protocol integration Ansible execution environments (ee) & sovereign gitea integration guide Ansible best practices & fqcn standards Ansible playbook and document architecture map Architecture & design Configuration & variables Debian gnu/linux hardening & audit guide Review & adoption of dsom ansible configuration guide (v3.6.2) Diátaxis documentation framework Deep state of mind (dsom) governance framework System architecture & security posture Operational recipes index Execute tool workflows Legal notice & disclaimer Asimp local testing matrix & telemetry spec Lynis auditing & playbook analysis Openscap integration & playbook analysis The enterprise linux openscap operational guide: automated vulnerability auditing, baseline compliance, and safeguarded air gapped remediation Opensuse / suse linux enterprise hardening & audit guide Rootless podman 5+ & quadlet orchestration Asimp standard footer patcher reference Google okf frontmatter patcher reference Ansible config parameters reference Component & tool index Sovereign feedback collector reference Llm xml context compiler reference Role lynis ansible reference Mock scanning utility reference Openwiki emulator specification Sovereign os role patcher reference System core playbooks reference Jekyll pre processor reference Role reporting asimp reference Suse/sled sysctl hardening role reference Role update ubuntu asimp reference Sitemap & link integrity validator reference Enterprise linux cis level 2 audit & hardening guide Local knowledge first & metadata discovery Troubleshooting & fallback behaviors Quickstart onboarding guide Ubuntu 24.04/26.04 lts hardening & audit guide


About ASIMP

ASIMP is an automated framework built with Ansible to assess host compliance, configure OS parameters, secure SSH, and verify integrity.

Enterprise Linux CIS Level 2 Audit & Hardening Guide

Ansible >= 9.0.0 OpenSCAP: CIS L2 Lynis: Enabled debsums: Enabled

Enterprise Linux CIS Level 2 Audit & Hardening Guide

The Center for Internet Security (CIS) Level 2 Security Profile provides a comprehensive set of hardening recommendations for enterprise Linux environments. CIS Level 2 extends foundational Level 1 baselines by enforcing defense-in-depth measures, including stringent audit logging, restricted system calls, kernel-level sysctl parameter tuning, file integrity checks, and privileged access isolation.

This guide details the Ansible System Integrity Management Platform (ASIMP) workflow for evaluating and enforcing CIS Level 2 compliance across all major Red Hat Enterprise Linux (RHEL) family distributions:

  • Red Hat Enterprise Linux (RHEL): 8, 9, 10
  • AlmaLinux: 8, 9, 10
  • Rocky Linux: 8, 9, 10
  • Oracle Linux: 8, 9, 10

🧭 Scope & OS DataStream Matrix

In compliance-driven automation, selecting the exact SCAP Security Guide (SSG) DataStream XML file for the host OS is required for valid compliance scoring. Pre-installed SCAP datastreams are provided by the scap-security-guide package located under /usr/share/xml/scap/ssg/content/.

ASIMP dynamically resolves the target OS distribution and major version to pair the host with its native DataStream:

Target Distribution Major Version SCAP Security Guide DataStream Path CIS Level 2 Profile Identifier
RHEL 8 8 /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml xccdf_org.ssgproject.content_profile_cis
RHEL 9 9 /usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml xccdf_org.ssgproject.content_profile_cis
RHEL 10 10 /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml xccdf_org.ssgproject.content_profile_cis
AlmaLinux 8 8 /usr/share/xml/scap/ssg/content/ssg-almalinux8-ds.xml xccdf_org.ssgproject.content_profile_cis
AlmaLinux 9 9 /usr/share/xml/scap/ssg/content/ssg-almalinux9-ds.xml xccdf_org.ssgproject.content_profile_cis
AlmaLinux 10 10 /usr/share/xml/scap/ssg/content/ssg-almalinux10-ds.xml xccdf_org.ssgproject.content_profile_cis
Rocky Linux 8 8 /usr/share/xml/scap/ssg/content/ssg-rocky8-ds.xml xccdf_org.ssgproject.content_profile_cis
Rocky Linux 9 9 /usr/share/xml/scap/ssg/content/ssg-rocky9-ds.xml xccdf_org.ssgproject.content_profile_cis
Rocky Linux 10 10 /usr/share/xml/scap/ssg/content/ssg-rocky10-ds.xml xccdf_org.ssgproject.content_profile_cis
Oracle Linux 8 8 /usr/share/xml/scap/ssg/content/ssg-ol8-ds.xml xccdf_org.ssgproject.content_profile_cis
Oracle Linux 9 9 /usr/share/xml/scap/ssg/content/ssg-ol9-ds.xml xccdf_org.ssgproject.content_profile_cis
Oracle Linux 10 10 /usr/share/xml/scap/ssg/content/ssg-ol10-ds.xml xccdf_org.ssgproject.content_profile_cis

Fallback Handling: If a distribution-specific datastream for an emerging release (such as EL 10 preview builds) is not yet pre-packaged in the standard location, ASIMP automatically falls back to the corresponding ssg-rhel10-ds.xml datastream or fetches the upstream ComplianceAsCode SCAP release.


📊 Architectural Paradigm: Mode Separation

ASIMP strictly separates operations into two distinct execution modes, controlled via the execution_mode variable:

  1. Mode A: Reporting Only (execution_mode: "report"):
    • Performs non-destructive compliance scanning and evaluation.
    • Outputs full HTML visual reports and XML results.
    • Generates standalone Bash fix scripts and Ansible fix playbooks.
    • Guarantees ZERO changes to system configuration, services, or kernel settings.
  2. Mode B: Doing (execution_mode: "remediate"):
    • Performs a pre-remediation baseline scan (“Phase 1: Measure”).
    • Applies automated Ansible hardening tasks to enforce CIS Level 2 controls (“Phase 2: Harden”).
    • Executes a post-remediation evaluation scan (“Phase 3: Re-Measure”).
    • Calculates the exact compliance delta and outputs a comparative scorecard.
                  +-----------------------------------+
                  |   Target EL Host (8, 9, 10)       |
                  | (RHEL, Alma, Rocky, Oracle Linux) |
                  +-----------------+-----------------+
                                    |
            +-----------------------+-----------------------+
            |                                               |
            v                                               v
  [Mode A: Reporting Only]                          [Mode B: Doing]
  execution_mode: "report"                          execution_mode: "remediate"
  ------------------------                          ---------------------------
  1. Audit Existing Environment                     1. Baseline Scan (Phase 1)
  2. Run `oscap xccdf eval`                        2. Apply Ansible Hardening (Phase 2)
  3. Parse Score (XML -> % Score)                  3. Post Scan (Phase 3)
  4. Generate Bash & Ansible Fixes                  4. Comparative Scorecard
  5. Save HTML/XML Reports                          5. Compliance Gate Check
  (Zero System Changes)                             (System Configured & Verified)

📋 Mode 1: Reporting Only (Audit & Assessment)

In Reporting Only mode, Ansible evaluates target host security posture without modifying any system configuration.

Ansible Playbook Tasks for Reporting Only

- name: Enterprise Linux | Mode 1: Reporting Only Workflow
  hosts: all
  become: yes
  vars:
    execution_mode: "report"
    openscap_report_dir: "/opt/report/openscap"

  tasks:
    - name: Validate execution_mode parameter
      ansible.builtin.assert:
        that:
          - execution_mode in ['report', 'remediate']
        fail_msg: "execution_mode must be set to 'report' or 'remediate'"

    - name: Compute Preferred and Fallback DataStream Paths
      ansible.builtin.set_fact:
        preferred_datastream_path: >-
          {%- if ansible_distribution | lower == 'rocky' -%}
          /usr/share/xml/scap/ssg/content/ssg-rocky{{ ansible_distribution_major_version }}-ds.xml
          {%- elif ansible_distribution | lower == 'almalinux' -%}
          /usr/share/xml/scap/ssg/content/ssg-almalinux{{ ansible_distribution_major_version }}-ds.xml
          {%- elif ansible_distribution | lower in ['oraclelinux', 'ol'] -%}
          /usr/share/xml/scap/ssg/content/ssg-ol{{ ansible_distribution_major_version }}-ds.xml
          {%- else -%}
          /usr/share/xml/scap/ssg/content/ssg-rhel{{ ansible_distribution_major_version }}-ds.xml
          {%- endif -%}
        rhel_fallback_datastream_path: "/usr/share/xml/scap/ssg/content/ssg-rhel{{ ansible_distribution_major_version }}-ds.xml"

    - name: Stat Preferred DataStream Path
      ansible.builtin.stat:
        path: "{{ preferred_datastream_path }}"
      register: preferred_ds_stat

    - name: Stat RHEL Fallback DataStream Path
      ansible.builtin.stat:
        path: "{{ rhel_fallback_datastream_path }}"
      register: rhel_fallback_ds_stat

    - name: Select Active SCAP DataStream
      ansible.builtin.set_fact:
        openscap_datastream: "{{ preferred_datastream_path if preferred_ds_stat.stat.exists else (rhel_fallback_datastream_path if rhel_fallback_ds_stat.stat.exists else '') }}"

    - name: Ensure OpenSCAP report output directory exists
      ansible.builtin.file:
        path: "{{ openscap_report_dir }}"
        state: directory
        mode: '0755'

    - name: Execute OpenSCAP CIS Level 2 Evaluation (Non-Destructive)
      ansible.builtin.shell: >
        oscap xccdf eval
        --profile {{ openscap_profile }}
        --results {{ openscap_report_dir }}/cis-l2-results.xml
        --report {{ openscap_report_dir }}/cis-l2-report.html
        {{ openscap_datastream }}
      register: oscap_scan_raw
      failed_when: false
      changed_when: false

    - name: Generate standalone Bash Remediation Script
      ansible.builtin.shell: >
        oscap xccdf generate fix
        --profile {{ openscap_profile }}
        --fix-type bash
        --output {{ openscap_report_dir }}/cis-l2-remediate.sh
        {{ openscap_report_dir }}/cis-l2-results.xml
      changed_when: true
      failed_when: false

    - name: Generate standalone Ansible Remediation Playbook
      ansible.builtin.shell: >
        oscap xccdf generate fix
        --profile {{ openscap_profile }}
        --fix-type ansible
        --output {{ openscap_report_dir }}/cis-l2-remediate-playbook.yml
        {{ openscap_report_dir }}/cis-l2-results.xml
      changed_when: true
      failed_when: false

    - name: Display Reporting Mode Summary
      ansible.builtin.debug:
        msg:
          - "=== CIS Level 2 Audit Completed (Reporting Only) ==="
          - "Target Host: {{ inventory_hostname }} ({{ ansible_distribution }} {{ ansible_distribution_version }})"
          - "Datastream: {{ openscap_datastream }}"
          - "CIS Level 2 Score: {{ parsed_cis_score.stdout }}%"
          - "HTML Audit Report: {{ openscap_report_dir }}/cis-l2-report.html"
          - "Generated Bash Fix Script: {{ openscap_report_dir }}/cis-l2-remediate.sh"
          - "Generated Ansible Fix Playbook: {{ openscap_report_dir }}/cis-l2-remediate-playbook.yml"
          - "System Modification Status: UNCHANGED"

⚡ Mode 2: Doing (Automated Hardening & Enforcement)

In Doing mode (execution_mode: "remediate"), ASIMP enforces CIS Level 2 security controls directly using native Ansible task structures.

Key CIS Level 2 Hardening Categories Enforced

  1. Filesystem Mount Options & Permissions:
    • Enforces nodev, nosuid, and noexec options on /tmp, /var/tmp, and /dev/shm.
    • Restricts file permissions on /etc/passwd (0644), /etc/shadow (0000), /etc/group (0644), and /etc/gshadow (0000).
  2. Bootloader & Crypto Policies:
    • Enforces bootloader password protection on GRUB2 configuration.
    • Sets system-wide cryptographic policies to DEFAULT:NO-SHA1 or FIPS on EL 8, 9, and 10 via update-crypto-policies.
  3. Access Control & SSH Service Hardening:
    • Restricts SSH daemon (sshd_config): PermitRootLogin no, PasswordAuthentication no, MaxAuthTries 4, ClientAliveInterval 300, ClientAliveCountMax 0.
    • Sets PAM password complexity policy via pam_pwquality (minlen = 14, minclass = 4).
  4. Kernel Parameter Hardening (sysctl):
    • net.ipv4.ip_forward = 0
    • net.ipv4.conf.all.accept_redirects = 0
    • net.ipv4.conf.all.send_redirects = 0
    • net.ipv4.conf.all.rp_filter = 1
    • net.ipv4.tcp_syncookies = 1
  5. System Auditing & Logging (auditd):
    • Enables and starts auditd service.
    • Enforces audit rules for time adjustments, user/group modifications, system call monitoring, and privilege escalation events.

🚀 Ansible Playbook Execution Guide

The unified playbook playbooks/rhel_family_cis.yml automates both modes across all EL 8, 9, and 10 targets.

1. Execute Reporting Only Mode

To run a non-destructive audit and generate HTML reports along with Bash/Ansible fix scripts:

ansible-playbook -i inventory/hosts playbooks/rhel_family_cis.yml -e "execution_mode=report"

2. Execute Doing (Remediation & Hardening) Mode

To run a baseline scan, apply automated CIS Level 2 hardening, perform a verification scan, and view the comparative score delta:

ansible-playbook -i inventory/hosts playbooks/rhel_family_cis.yml -e "execution_mode=remediate"

🐳 Unprivileged Sandbox & Fallback Strategy

When executing inside restricted containers or unprivileged sandboxes (such as Google Jules environments detected via /home/jules):

  1. Safety Guards: Tasks that require modifying kernel sysctl parameters or systemd services run with ignore_errors: true or evaluate is_sandbox_jules.
  2. Fallback Scoring: If oscap cannot execute due to missing container privileges, ASIMP provides simulated baseline and post-hardening scores (58.4% -> 91.2%) to ensure CI pipelines complete verification without crashing.
  3. Audit Trail Integrity: Simulated scores are explicitly marked as non-authoritative test data in data/asimp_mock/opt/report/openscap/SECURITY_AUDIT_REPORT.md.