How gangadhariy/rhel9.0-l1-cis works
Project Type and Purpose
• This is an Ansible Role named “RHEL9-CIS” designed to enforce CIS Benchmark v1.0.0 controls on RHEL-9 and compatible distributions.
• It is not a typical client-server application but an automation “remediation” tool (not an audit-only tool) that applies OS configuration changes via Ansible.
High-Level Architecture Overview
• Control Plane (Ansible Control Node)
• Runs ansible-playbook, loads this role from a play or Tower.
• Parses inventory, loads defaults/vars/collections, runs tasks.
• Integrates with GitHub Actions for CI (main_pipeline_validation, devel_pipeline_validation).
• Runs Molecule for local testing against containers or WSL.
• Managed Nodes (Target Hosts)
• Systems running RHEL9, AlmaLinux9, Rocky9 or OracleLinux9.
• Ansible connects via SSH or WinRM, gathers facts, enforces configurations.
• May host the Goss binary for “live” auditing (if setup_audit is true).
• External Components
• GitHub (source repository, Actions CI).
• Ansible Galaxy (role distribution).
• Collection dependencies (defined in collections/requirements.yml).
• Goss (embedded Go binary + YAML checks for auditing).
• Molecule (Docker/Podman drivers for converge/verify).
Directory-to-Component Mapping
• defaults/main.yml
• Default variables controlling audit, CIS level, os_check, etc.
• vars/*.yml
• OS-specific variables per distribution.
• tasks/
• Entry point main.yml → includes check_prereqs, auditd, sections 1–6, post_remediation, handlers.
• Section subdirectories model CIS domains (1=Initial Setup, 2=Services, …).
• handlers/main.yml
• Notifications, service restarts (e.g., systemd unit reload after template changes).
• templates/
• Jinja2 templates for configuration files (sysctl.d, audit rules, dconf, chrony, tmp.mount).
• files/
• Static files (e.g., systemd tmp.mount unit) to copy.
• meta/main.yml
• Role metadata, Galaxy dependencies.
• molecule/
• Scenarios for default, localhost, wsl: converge.yml + verify.yml + molecule.yml.
• .github/workflows/
• CI pipelines invoking linting, molecule testing, pre-commit.
Relationships and Data Flow
1. Developer commits code → GitHub Actions triggers pipelines.
2. In CI:
• ansible-lint, yamllint, pre-commit checks.
• Molecule spins up ephemeral VM/container → runs converge, then verify.
3. End user runs ansible-playbook:
• Control node reads defaults & vars → composes task list.
• SSH to each managed host → gather_facts.
• Execute tasks in order: parse_etc_password, check_prereqs, auditd setup, section tasks, post.
• Each template copy triggers handler events (service reloads).
• If setup_audit & run_audit true → push Goss binary + configs, run goss tests.
4. Managed hosts report status; playbook returns success/failure.
Architectural Patterns & Design Principles
• Layered modularization by CIS sections to keep tasks granular.
• Divide default configuration vs. override vars per OS.
• Idempotent task design (Ansible best practice).
• Use of tagging for selective runs (level1-server, scored, services, rule_X.Y.Z).
• Test-driven infrastructure via Molecule.
• CI gating to ensure role quality before merge.