How redhatofficial/ansible-role-rhel9-cui works
Project type and purpose
• This is an Ansible Role whose sole purpose is to configure Red Hat Enterprise Linux 9 in accordance with the NIST 800-171 profile for protecting Controlled Unclassified Information (CUI).
• It is not a client-server app or microservices system—it is automation code that runs on an Ansible control node and targets one or more managed RHEL9 hosts.
File structure
• Top-level files:
• LICENSE, README.md – documentation and licensing.
• defaults/main.yml – default variables that parameterize the role.
• handlers/main.yml – handler definitions triggered by “notify” statements in tasks.
• meta/main.yml – role metadata (dependencies, author, platform support).
• tasks/main.yml – primary task list calling modules and other task files.
• vars/main.yml – fixed variables that override defaults if needed.
• tests/ – sample inventory and playbook (test.yml) for validation.
• No “playbooks” directory here—this is a single role. The playbook lives outside this tree and invokes the role.
Extract insights from the README
• The role’s tasks are generated via OpenSCAP (an external compliance-scan and playbook generator).
• It enforces both basic requirements (from FIPS 200) and derived controls (from SP 800-53).
• No external service dependencies—only Ansible (v2.9+) and the target RHEL9 hosts.
Main components
a. Ansible Control Node
• Hosts the role directory.
• Runs ansible-playbook with SSH inventory.
• Loads variables (defaults + vars), metadata, tasks, handlers.
b. OpenSCAP Engine (external generator)
• Generates the tasks files prior to role execution (this can be shown as a pre-processing step).
c. Managed Nodes (RHEL 9 Hosts)
• One or more Linux servers configured to accept SSH and python for Ansible.
• Target of configuration changes.
d. Role internals
• Variable layer (defaults & vars).
• Task execution layer, using built-in Ansible modules (e.g., file, lineinfile, yum).
• Handler layer for deferred actions (e.g., service restarts).
e. Tests
• A test inventory and a test playbook under tests/ for local verification (check mode).
Relationships and interactions
• Control Node → SSH → Managed Nodes: runs modules to enforce settings.
• Control Node loads defaults/main.yml, merges with vars/main.yml.
• tasks/main.yml calls each compliance control as a module invocation.
• When a task signals a change, it calls “notify” to trigger handlers/main.yml.
• Handlers run at the end of each play on the node.
• Tests directory can be invoked from the control node in check mode to validate idempotency.
Key architectural patterns and principles
• Separation of concerns: variables vs. tasks vs. handlers vs. metadata.
• Idempotent operations via Ansible modules.
• Declarative configuration management.
• Extensibility point: OpenSCAP playbook generation can re-source or update tasks.
Final advice
• Be as detailed as possible: show every directory’s role (defaults, tasks, handlers, etc.).
• Idempotent, declarative nature of Ansible by annotating task modules with “ensure present”, “ensure absent”, etc.