Skip to content

Commit

Permalink
replace sed with replace-module
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Gumprich authored and chris-rock committed Jun 1, 2015
1 parent c9252b1 commit e6f2253
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions roles/ansible-os-hardening/tasks/yum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,23 @@
- 'CentOS-Vault'
when: os_security_packages_clean

- 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
shell: "sed -i 's/gpgcheck=0/gpgcheck=1/g' {{item}}"
replace: dest='{{item}}' regexp='^\s*gpgcheck=0' replace='gpgcheck=1'
with_items:
- '{{ yum_repos.stdout_lines }}'
- '/etc/yum.conf'
- '/etc/yum.repos.d/*.repo'

- name: activate gpg-check for yum rhn if it exists
shell: sed -i 's/gpgcheck=0/gpgcheck=1/g' /etc/yum/pluginconf.d/rhnplugin.conf removes='/etc/yum/pluginconf.d/rhnplugin.conf'
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
Expand Down

0 comments on commit e6f2253

Please sign in to comment.