-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
256 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ choose_demo_example_aws.yml | |
.ansible.cfg | ||
*.gz | ||
|
||
**/roles/* | ||
!**/roles/requirements.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
- name: Apply compliance profile | ||
hosts: "{{ _hosts | default(omit) }}" | ||
become: true | ||
vars: | ||
compliance_profile: undef | ||
|
||
tasks: | ||
- name: Check os type | ||
ansible.builtin.assert: | ||
that: "ansible_os_family == 'RedHat'" | ||
|
||
- name: Run Compliance Profile | ||
ansible.builtin.include_role: | ||
name: "redhatofficial.rhel{{ ansible_distribution_major_version }}_{{ compliance_profile }}" | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
--- | ||
- name: Generate OpenSCAP compliance report | ||
hosts: '{{ _hosts | default(omit) }}' | ||
become: true | ||
|
||
vars: | ||
openscap_packages: | ||
- openscap-scanner | ||
- openscap-utils | ||
- scap-security-guide | ||
compliance_profile: ospp | ||
use_httpd: true | ||
|
||
tasks: | ||
- name: Get our facts straight | ||
ansible.builtin.set_fact: | ||
_profile: '{{ compliance_profile | replace("pci_dss", "pci-dss") }}' | ||
_report_dir: /tmp/oscap-reports | ||
|
||
- name: Ensure OpenSCAP tools are installed | ||
ansible.builtin.dnf: | ||
name: '{{ openscap_packages }}' | ||
state: present | ||
|
||
- name: Configure httpd | ||
when: use_httpd | bool | ||
block: | ||
- name: Install httpd | ||
ansible.builtin.dnf: | ||
name: httpd | ||
state: present | ||
notify: Restart httpd | ||
|
||
- name: Override report directory | ||
ansible.builtin.set_fact: | ||
_report_dir: /var/www/html/oscap-reports | ||
|
||
- name: Gather service facts | ||
ansible.builtin.service_facts: | ||
|
||
- name: Enable firewall http service | ||
ansible.posix.firewalld: | ||
service: http | ||
state: enabled | ||
immediate: true | ||
permanent: true | ||
when: "'firewalld.service' in ansible_facts.services" | ||
|
||
- name: Disable httpd welcome page | ||
ansible.builtin.file: | ||
path: /etc/httpd/conf.d/welcome.conf | ||
state: absent | ||
notify: Restart httpd | ||
|
||
- name: Ensure report directory exists | ||
ansible.builtin.file: | ||
path: '{{ _report_dir }}/{{ _profile }}' | ||
state: directory | ||
owner: root | ||
group: root | ||
mode: 0755 | ||
|
||
- name: Set report name | ||
ansible.builtin.set_fact: | ||
_report: '{{ _report_dir }}/{{ _profile }}/report-{{ ansible_date_time.iso8601 }}.html' | ||
|
||
- name: Generate compliance report | ||
ansible.builtin.command: >- | ||
oscap xccdf eval --profile {{ _profile }} --report {{ _report }} | ||
/usr/share/xml/scap/ssg/content/ssg-rhel{{ ansible_distribution_major_version }}-ds.xml | ||
args: | ||
creates: '{{ _report }}' | ||
register: _oscap | ||
failed_when: _oscap.rc not in [0, 2] | ||
|
||
- name: Set report permissions | ||
ansible.builtin.file: | ||
path: '{{ _report }}' | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
|
||
handlers: | ||
- name: Restart httpd | ||
ansible.builtin.service: | ||
name: httpd | ||
state: restarted | ||
enabled: true | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Supported Compliance Profiles | ||
|
||
The following compliance profiles are supported by the [**Linux / Enforce Compliance**](README.md#jobs) job template: | ||
|
||
| **Profile** | **Role Repository** | | ||
|-------------|---------------------| | ||
| CIS | https://galaxy.ansible.com/RedHatOfficial/ansible-role-rhel8-cis | | ||
| CUI | https://galaxy.ansible.com/RedHatOfficial/ansible-role-rhel8-cui | | ||
| HIPAA | https://galaxy.ansible.com/RedHatOfficial/ansible-role-rhel8-hipaa | | ||
| OSPP | https://galaxy.ansible.com/RedHatOfficial/ansible-role-rhel8-ospp | | ||
| PCI-DSS | https://galaxy.ansible.com/RedHatOfficial/ansible-role-rhel8-pci-dss | | ||
| DISA STIG | https://galaxy.ansible.com/RedHatOfficial/ansible-role-rhel8-stig | | ||
|
||
These roles are derived from the [Compliance as Code](https://github.com/ComplianceAsCode/content) project, which provides SCAP content used by the [OpenSCAP](https://www.open-scap.org/) `oscap` tool. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
roles: | ||
# RHEL 7 compliance roles from ComplianceAsCode | ||
- name: redhatofficial.rhel7_cis | ||
version: 0.1.69 | ||
- name: redhatofficial.rhel7_cui | ||
version: 0.1.67 | ||
- name: redhatofficial.rhel7_hipaa | ||
version: 0.1.69 | ||
- name: redhatofficial.rhel7_ospp | ||
version: 0.1.69 | ||
- name: redhatofficial.rhel7_pci_dss | ||
version: 0.1.69 | ||
- name: redhatofficial.rhel7_stig | ||
version: 0.1.69 | ||
# RHEL 8 compliance roles from ComplianceAsCode | ||
- name: redhatofficial.rhel8_cis | ||
version: 0.1.69 | ||
- name: redhatofficial.rhel8_cui | ||
version: 0.1.69 | ||
- name: redhatofficial.rhel8_hipaa | ||
version: 0.1.69 | ||
- name: redhatofficial.rhel8_ospp | ||
version: 0.1.69 | ||
- name: redhatofficial.rhel8_pci_dss | ||
version: 0.1.69 | ||
- name: redhatofficial.rhel8_stig | ||
version: 0.1.69 | ||
# RHEL 9 compliance roles from ComplianceAsCode | ||
- name: redhatofficial.rhel9_cis | ||
version: 0.1.68 | ||
- name: redhatofficial.rhel9_cui | ||
version: 0.1.64 | ||
- name: redhatofficial.rhel9_hipaa | ||
version: 0.1.68 | ||
- name: redhatofficial.rhel9_ospp | ||
version: 0.1.68 | ||
- name: redhatofficial.rhel9_pci_dss | ||
version: 0.1.68 | ||
- name: redhatofficial.rhel9_stig | ||
version: 0.1.64 | ||
... |