Execution
Date 08 Dec 2025 13:40:18 +0000
Duration 00:10:06.79
Controller aio1.openstack.local
User root
Versions
Ansible 2.18.6
ara 1.7.4 / 1.7.4
Python 3.12.11
Summary
15 Hosts
608 Tasks
2412 Results
18 Plays
158 Files
0 Records

File: /home/zuul/src/opendev.org/openstack/ansible-hardening/tasks/rhel7stig/rpm.yml

---
# Copyright 2016, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

- name: Ensure RPM verification task has finished
  ansible.builtin.async_status:
    jid: "{{ rpmverify_task.ansible_job_id }}"
  failed_when: false
  changed_when: false
  register: job_result
  until: job_result.finished
  retries: 360
  delay: 10
  when:
    - rpmverify_task is not skipped
  tags:
    - rpm
    - high
    - V-71855

- name: V-71855 - Get files with invalid checksums (rpm)
  ansible.builtin.shell: "grep '^..5' {{ temp_dir }}/rpmverify.txt | awk '{ print $NF }'"
  register: invalid_checksum_files
  changed_when: false
  when:
    - security_check_package_checksums | bool
    - not check_mode | bool
    - ansible_facts['os_family'] | lower == 'redhat'
  tags:
    - rpm
    - high
    - V-71855

- name: V-71855 - The cryptographic hash of system files and commands must match vendor values (rpm)
  ansible.builtin.debug:
    msg: |
      The following files have checksums that differ from the checksum provided
      with their package. Each of these should be verified manually to ensure
      they have not been modified by an unauthorized user.

      {% for filename in invalid_checksum_files.stdout_lines %}
        {{ filename }}
      {% endfor %}
  when:
    - security_check_package_checksums | bool
    - not check_mode | bool
    - ansible_facts['os_family'] | lower == 'redhat'
    - invalid_checksum_files is defined
    - invalid_checksum_files.stdout is defined
  tags:
    - rpm
    - high
    - V-71855

- name: V-71977 - Require digital signatures for all packages
  ansible.builtin.lineinfile:
    dest: "{{ pkg_mgr_config }}"
    regexp: "{{ item.regexp }}"
    line: "{{ item.line }}"
    state: present
  with_items: "{{ rpm_gpgchecks | default([]) }}"
  tags:
    - rpm
    - high
    - V-71977
    - V-71979
    - V-71981

- name: V-71987 - Clean requirements/dependencies when removing packages (RedHat)
  ansible.builtin.lineinfile:
    dest: "{{ pkg_mgr_config }}"
    regexp: "^(#)?clean_requirements_on_remove"
    line: "clean_requirements_on_remove=1"
    state: present
  when:
    - security_package_clean_on_remove | bool
    - ansible_facts['os_family'] | lower == 'redhat'
  tags:
    - low
    - packages
    - V-71987