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

Consider using find module instead of shell #293

Closed
danielkubat opened this issue Aug 12, 2020 · 2 comments
Closed

Consider using find module instead of shell #293

danielkubat opened this issue Aug 12, 2020 · 2 comments

Comments

@danielkubat
Copy link
Contributor

danielkubat commented Aug 12, 2020

generally is not recommended to use shell module, if there is a native module in place.

current state:
https://github.com/dev-sec/ansible-os-hardening/blob/eb777fbe2f1f8677ff80b9cf5f37bedb9648476e/tasks/yum.yml#L13

using find module example:

- name: get yum-repository-files
  find:
    paths: '/etc/yum.repos.d'
    patterns: '*.repo'
  register: yum_repos

therefore in context:

- name: get yum-repository-files
  find:
    paths: '/etc/yum.repos.d'
    patterns: '*.repo'
  register: yum_repos

- name: activate gpg-check for yum-repository-files
  replace:
    dest: '{{ item.path }}'
    regexp: '^\s*gpgcheck.*'
    replace: 'gpgcheck=1'
  with_items:
    - '{{ yum_repos.files | default([]) }}'
@rndmh3ro
Copy link
Member

Good find, you're totally right. Do you want to create a PR to fix that?

@danielkubat
Copy link
Contributor Author

Good find, you're totally right. Do you want to create a PR to fix that?

yeah, I will create it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants