Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add task to remove unused repos and pkgs #11

Merged
merged 3 commits into from
Jun 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions roles/ansible-os-hardening/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@
- include: securetty.yml
- include: suid_sgid.yml
- include: sysctl.yml

- include: yum.yml
when: ansible_os_family == 'RedHat' or ansible_os_family == 'Oracle Linux'
40 changes: 34 additions & 6 deletions roles/ansible-os-hardening/tasks/yum.yml
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