8000 GitHub - ansible-lockdown/RHEL8-CIS: Automated CIS Benchmark Compliance Remediation for RHEL 8 with Ansible · GitHub
[go: up one dir, main page]

Skip to content

Repository files navigation

RHEL 8 CIS

Configure a RHEL 8 machine to be CIS compliant

Remediation role for RHEL 8 and compatible EL8 distributions (AlmaLinux, Rocky Linux, Oracle Linux), with an optional goss based audit that runs before and after remediation.


Contents


Status

Public Repository

Org Stars Stars Forks Followers X URL Discord Badge License

Lint & Pre-Commit Tools

YamlLint Ansible-Lint

Community Release Information

Release Branch Release Tag Main Release Date Benchmark Version Main Benchmark Version Devel

Main Pipeline Status Devel Pipeline Status

Devel Commits Open Issues Closed Issues Pull Requests

Subscriber Release Information

Private Release Branch Private Benchmark Version Private Remediate Pipeline Private Pull Requests Private Closed Issues


Caution(s)

This role will make changes to the system which may have unintended consequences. This is not an auditing tool but rather a remediation tool to be used after an audit has been conducted.

  • Testing is the most important thing you can do. Did we mention testing?
  • Check mode is not supported. The role will complete in check mode without errors, but use it with caution.
  • This role was developed against a clean install of the operating system. If you are applying it to an existing system, review the role for any site specific changes that are needed.
  • To use a release version, point to the main branch and the release for the benchmark you wish to work with.
  • Some controls are disruptive and are only applied when rhel8cis_disruption_high: true (default false), for example PAM/authselect changes and removing the GUI package group. Review them before enabling.

Requirements

General:

  • Basic knowledge of Ansible. If you are unfamiliar with Ansible, these links help get started:
  • A functioning Ansible installation (or AWX / Automation Controller), configured and able to reach the target hosts.
  • Read through the tasks in this role to understand what each control does. Some tasks are disruptive and can have unintended consequences on a live production system. Also familiarise yourself with the variables in defaults/main/main.yml.

Technical Dependencies:

  • RHEL family OS 8
  • ansible-core 2.16.1 or newer
  • Collections listed in collections/requirements.yml: community.general, ansible.posix
  • If using the audit: access to download or add the goss binary and audit content to the system (other options are available for getting the content onto the host)
  • If generating your own bootloader password hash on the controller: passlib

Quick Start

Install the collections, then point a playbook at the role:

ansible-galaxy collection install -r collections/requirements.yml
- name: Apply CIS hardening
  hosts: rhel8_servers
  become: true
  roles:
    - role: RHEL8-CIS

The repository includes a ready made site.yml that targets all hosts, or the hosts passed in the hosts variable:

ansible-playbook -i inventory site.yml -e hosts=rhel8_servers

To run the audit before and after remediation, set setup_audit: true and run_audit: true (see Auditing).


Customising the Role

This role is designed so that the end user should not have to edit the tasks themselves. All customising should be done by overriding variables from defaults/main/main.yml (remediation) and defaults/main/audit.yml (audit), for example in group_vars, host_vars or with extra vars in the project, job or workflow.

  • Every control has a toggle named after its ID, for example rhel8cis_rule_1_1_1_1, so individual controls can be switched off.
  • Each section can be switched off with rhel8cis_section1 to rhel8cis_section7.

Matching a Security Level

It is possible to only run level 1 or level 2 controls for CIS. This is managed using tags:

  • level1-server
  • level1-workstation
  • level2-server
  • level2-workstation

Select a level with --tags, for example --tags level1-server. Do not use --skip-tags level2-server,level2-workstation to leave out Level 2: a control that is Level 1 Server and Level 2 Workstation carries both tags and would be skipped too.

The level variables in defaults/main/main.yml also need to reflect this, as they control the testing that takes place if you are using the audit component.

Tags

There are many tags available for added control precision. Each control has its own set of tags noting what level, what OS element it relates to, whether it is a patch or audit, and the rule number. NIST references follow a specific conversion format for consistency and clarity.

Below is an example of the tag section from a control within this role. Using this example, if you set your run to skip all controls with the tag cramfs, this task will be skipped. The opposite can also happen where you run only controls tagged with cramfs.

  tags:
    - level1-server
    - level1-workstation
    - automated
    - patch
    - rule_1.1.1.1
    - NIST800-53R5_CM-7
    - CCI-000381
    - cramfs

Conversion format for NIST references:

  1. Standard prefix: all references are prefixed with "NIST".
  2. Standard types:
    • "800-53" references are formatted as NIST800-53.
    • "800-53r5" references are formatted as NIST800-53R5 (with 'R' capitalised).
    • "800-171" references are formatted as NIST800-171.
  3. Details:
    • Section and subsection numbers use periods (.) for numeric separators.
    • Parenthetical elements are separated by underscores (_), e.g., IA-5(1)(d) becomes IA-5_1_d.
    • Subsection letters (e.g., "b") are appended with an underscore.

Auditing

This can be turned on or off with the variables setup_audit and run_audit in defaults/main/audit.yml. The value is false by default, please refer to the wiki for more details. The role passes its variables to the audit, so only the controls that are enabled in the role are checked.

The audit uses a small (16MB) go binary called goss along with the relevant configurations to check, without the need for infrastructure or other tooling. It is a quick, lightweight check of both the configuration and the live/running settings, which aims to remove false positives in the process.

Refer to RHEL8-CIS-Audit.


Documentation


Looking for support?

Lockdown Enterprise

Ansible support

Community

On our Discord Server to ask questions, discuss features, or just chat with other Ansible-Lockdown users

Contributing

Bug reports and feature requests are welcome from everyone, please raise an issue.

Pull requests are accepted from approved contributors only. To be onboarded, join the Discord Server and request contributor access. See CONTRIBUTING.md for the full process.


Testing

Pipeline Testing

Automated tests run on pull requests into devel:

  • self-hosted runners using OpenTofu
  • ansible collections pulled at the latest version from the requirements file
  • the audit runs using the devel branch

Local Testing

Molecule scenarios: default, localhost, wsl.

molecule test -s default

Known Issues

  • AlmaLinux BaseOS, EPEL and many cloud provider repositories do not support gpgcheck (rule_1.2.1.2) or repo_gpgcheck (rule_1.2.1.3). This will cause issues during the playbook unless a workaround is found.

Credits and Thanks

Massive thanks to the fantastic community and all its members.

This includes a huge thanks and credit to the original authors and maintainers.

Mark Bolwell, George Nalen, Steve Williams, Fred Witty

0