41 lines
1.4 KiB
YAML
41 lines
1.4 KiB
YAML
---
|
|
- name: remove unused repositories
|
|
file:
|
|
name: '/etc/yum.repos.d/{{ item }}.repo'
|
|
state: 'absent'
|
|
with_items:
|
|
- 'CentOS-Debuginfo'
|
|
- 'CentOS-Media'
|
|
- 'CentOS-Vault'
|
|
when: os_security_packages_clean | bool
|
|
|
|
- name: get yum-repository-files
|
|
shell: 'find /etc/yum.repos.d/ -type f -name *.repo'
|
|
changed_when: False
|
|
register: yum_repos
|
|
|
|
# for the 'default([])' see here:
|
|
# https://github.com/dev-sec/ansible-os-hardening/issues/99 and
|
|
# https://stackoverflow.com/questions/37067827/ansible-deprecation-warning-for-undefined-variable-despite-when-clause
|
|
#
|
|
# failed_when is needed because by default replace module will fail if the file doesn't exists.
|
|
# status.rc is only defined if an error accrued and only error code (rc) 257 will be ignored.
|
|
# All other errors will still be raised.
|
|
- name: activate gpg-check for config files
|
|
replace:
|
|
dest: '{{ item }}'
|
|
regexp: '^\s*gpgcheck: 0'
|
|
replace: 'gpgcheck: 1'
|
|
register: status
|
|
failed_when: status.rc is defined and status.rc != 257
|
|
with_flattened:
|
|
- '/etc/yum.conf'
|
|
- '/etc/dnf/dnf.conf'
|
|
- '{{ yum_repos.stdout_lines| default([]) }}' # noqa 104
|
|
- '/etc/yum/pluginconf.d/rhnplugin.conf'
|
|
|
|
- name: remove deprecated or insecure packages | package-01 - package-09
|
|
yum:
|
|
name: '{{ os_security_packages_list }}'
|
|
state: 'absent'
|
|
when: os_security_packages_clean | bool
|