2022-01-07 09:06:18 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
|
|
- name: "1.2.1 | L1 | PATCH | Ensure Red Hat Subscription Manager connection is configured"
|
|
|
|
|
redhat_subscription:
|
|
|
|
|
state: present
|
|
|
|
|
username: "{{ rhel9cis_rh_sub_user }}"
|
|
|
|
|
password: "{{ rhel9cis_rh_sub_password }}"
|
|
|
|
|
auto_attach: true
|
|
|
|
|
no_log: true
|
|
|
|
|
when:
|
|
|
|
|
- ansible_distribution == "RedHat"
|
|
|
|
|
- rhel9cis_rhnsd_required
|
|
|
|
|
- rhel9cis_rule_1_2_1
|
|
|
|
|
tags:
|
|
|
|
|
- level1-server
|
|
|
|
|
- level1-workstation
|
|
|
|
|
- notscored
|
|
|
|
|
- patch
|
|
|
|
|
- rule_1.2.1
|
|
|
|
|
- skip_ansible_lint # Added as no_log still errors on ansuible-lint
|
|
|
|
|
|
|
|
|
|
- name: "1.2.2 | L1 | PATCH | Disable the rhnsd Daemon"
|
|
|
|
|
service:
|
|
|
|
|
name: rhnsd
|
|
|
|
|
state: stopped
|
2022-01-13 16:51:17 +00:00
|
|
|
enabled: false
|
2022-01-07 09:06:18 +00:00
|
|
|
masked: true
|
|
|
|
|
when:
|
|
|
|
|
- ansible_distribution == "RedHat"
|
|
|
|
|
- rhnsd_service_status.stdout == "loaded" and not rhel9cis_rhnsd_required
|
|
|
|
|
- rhel9cis_rule_1_2_2
|
|
|
|
|
tags:
|
|
|
|
|
- level1-server
|
|
|
|
|
- level1-workstation
|
|
|
|
|
- notscored
|
|
|
|
|
- patch
|
|
|
|
|
- rule_1.2.2
|
|
|
|
|
|
|
|
|
|
- name: "1.2.3 | L1 | AUDIT | Ensure GPG keys are configured"
|
2022-02-02 11:25:03 +00:00
|
|
|
shell: gpg --quiet --with-fingerprint "{{ rpm_gpg_key }}"
|
2022-01-13 12:08:30 +00:00
|
|
|
args:
|
|
|
|
|
warn: false
|
2022-01-07 09:06:18 +00:00
|
|
|
when:
|
|
|
|
|
- rhel9cis_rule_1_2_3
|
2022-02-02 11:25:03 +00:00
|
|
|
- ansible_distribution == "RedHat" or
|
|
|
|
|
ansible_distribution == "Rocky"
|
2022-01-07 09:06:18 +00:00
|
|
|
tags:
|
|
|
|
|
- level1-server
|
|
|
|
|
- level1-workstation
|
|
|
|
|
- notscored
|
|
|
|
|
- patch
|
|
|
|
|
- rule_1.2.3
|
|
|
|
|
|
|
|
|
|
- name: "1.2.4 | L1 | PATCH | Ensure gpgcheck is globally activated"
|
|
|
|
|
block:
|
|
|
|
|
- name: "1.2.4 | L1 | AUDIT | Ensure gpgcheck is globally activated | Find repos"
|
|
|
|
|
find:
|
|
|
|
|
paths: /etc/yum.repos.d
|
|
|
|
|
patterns: "*.repo"
|
|
|
|
|
register: yum_repos
|
|
|
|
|
changed_when: false
|
|
|
|
|
|
|
|
|
|
- name: "1.2.4 | L1 | PATCH | Ensure gpgcheck is globally activated | Update yum.repos"
|
|
|
|
|
replace:
|
|
|
|
|
name: "{{ item.path }}"
|
|
|
|
|
regexp: "^gpgcheck=0"
|
|
|
|
|
replace: "gpgcheck=1"
|
|
|
|
|
with_items:
|
|
|
|
|
- "{{ yum_repos.files }}"
|
|
|
|
|
when:
|
|
|
|
|
- rhel9cis_rule_1_2_4
|
|
|
|
|
tags:
|
|
|
|
|
- level1-server
|
|
|
|
|
- level1-workstation
|
|
|
|
|
- scored
|
|
|
|
|
- patch
|
|
|
|
|
- rule_1.2.4
|
|
|
|
|
|
|
|
|
|
- name: "1.2.5 | L1 | Ensure package manager repositories are configured"
|
|
|
|
|
block:
|
|
|
|
|
- name: "1.2.5 | L1 | AUDIT | Ensure package manager repositories are configured | Get repo list"
|
2022-01-13 11:27:26 +00:00
|
|
|
shell: dnf repolist
|
2022-01-13 12:08:30 +00:00
|
|
|
args:
|
|
|
|
|
warn: false
|
2022-01-07 09:06:18 +00:00
|
|
|
changed_when: false
|
|
|
|
|
failed_when: false
|
|
|
|
|
register: dnf_configured
|
2022-01-13 16:51:17 +00:00
|
|
|
check_mode: false
|
2022-01-07 09:06:18 +00:00
|
|
|
|
|
|
|
|
- name: "1.2.5 | L1 | AUDIT | Ensure package manager repositories are configured | Display repo list"
|
|
|
|
|
debug:
|
|
|
|
|
msg:
|
|
|
|
|
- "Alert! Below are the configured repos. Please review and make sure all align with site policy"
|
|
|
|
|
- "{{ dnf_configured.stdout_lines }}"
|
|
|
|
|
when:
|
|
|
|
|
- rhel9cis_rule_1_2_5
|
|
|
|
|
tags:
|
|
|
|
|
- level1-server
|
|
|
|
|
- level1-workstation
|
|
|
|
|
- notscored
|
|
|
|
|
- patch
|
|
|
|
|
- rule_1.2.5
|
|
|
|
|
- skip_ansible_lint
|