-
Notifications
You must be signed in to change notification settings - Fork 704
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from hardening-io/yum_rm_pkg
Add task to remove unused repos and pkgs
- Loading branch information
Showing
2 changed files
with
36 additions
and
6 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 |
---|---|---|
@@ -1,8 +1,36 @@ | ||
--- | ||
- name: activate gpg-check for yum-repos in yum.conf | ||
shell: "sed -i 's/gpgcheck=0/gpgcheck=1/g' /etc/yum.conf" | ||
when: ansible_os_family == 'RedHat' or ansible_os_family == 'Oracle Linux' | ||
- 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 | ||
|
||
- name: activate gpg-check for yum-repos in yum-repositories | ||
shell: "sed -i 's/gpgcheck=0/gpgcheck=1/g' /etc/yum.repos.d/*.repo" | ||
when: ansible_os_family == 'RedHat' or ansible_os_family == 'Oracle Linux' | ||
- name: get yum-repository-files | ||
shell: 'find /etc/yum.repos.d/ -type f -name *.repo' | ||
register: yum_repos | ||
|
||
- name: check if rhnplugin.conf exists | ||
stat: path='/etc/yum/pluginconf.d/rhnplugin.conf' | ||
register: rhnplugin_file | ||
|
||
- name: activate gpg-check for yum-repos | ||
replace: dest='{{item}}' regexp='^\s*gpgcheck=0' replace='gpgcheck=1' | ||
with_items: | ||
- '{{ yum_repos.stdout_lines }}' | ||
- '/etc/yum.conf' | ||
|
||
- name: activate gpg-check for yum rhn if it exists | ||
replace: dest='/etc/yum/pluginconf.d/rhnplugin.conf' regexp='^\s*gpgcheck=0' replace='gpgcheck=1' | ||
when: rhnplugin_file.stat.exists | ||
|
||
- name: remove packages | ||
yum: name='{{item}}' state=removed | ||
with_items: | ||
- xinetd | ||
- inetd | ||
- ypserv | ||
- telnet-server | ||
- rsh-server | ||
when: os_security_packages_clean |