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

Ansible remediation of rsyslog_remote_tls contains unnecessary shell commands #9621

Closed
vojtapolasek opened this issue Oct 4, 2022 · 1 comment · Fixed by #9866
Closed
Assignees
Labels
Ansible Ansible remediation update. productization-issue Issue found in upstream stabilization process.
Milestone

Comments

@vojtapolasek
Copy link
Collaborator

Description of problem:

Ansible remediation of the rule contains the following tasks:

- name: "Get omfwd configuration directive"
  shell: sed -e '/action\s*(\s*type\s*=\s*"omfwd"/,/)/!d' /etc/rsyslog.conf /etc/rsyslog.d/*.conf
  register: include_omfwd_config_output

and

- name: "Get include files directives"
  shell: >
    set -o pipefail
    echo \"{{ include_omfwd_config_output.stdout }}\"|grep  'StreamDriver=\"gtls\"'
  register: include_omfwd_gtls_config_output
  when: (include_omfwd_config_output.stdout_lines| length > 0)

We try to minimize usage of shell commands within our playbooks. I believe that these commands could be replaced by Ansible modules, e.g. replace.

SCAP Security Guide Version:

Master ace670c

Operating System Version:

RHEL 9

Steps to Reproduce:

  1. build RHEL9 datastream
  2. oscap xccdf generate fix --fix-type ansible --output /tmp/playbook.yml --profile '(all)' build/ssg-rhel9-ds.xmů
  3. search for the rsyslog_remote_tls rule within the playbook.yml and view tasks

Actual Results:

Tasks are using shell module.

Expected Results:

Tasks are not using shell module, but some different Ansible module instead. If it is not possible, it is explained with a comment.

Additional Information/Debugging Steps:

@vojtapolasek vojtapolasek added Ansible Ansible remediation update. productization-issue Issue found in upstream stabilization process. labels Oct 4, 2022
@marcusburghardt marcusburghardt added this to the 0.1.65 milestone Nov 1, 2022
@marcusburghardt
Copy link
Member

Just for history, this was the last update in this remediation: #9711

I can confirm they could be replaced by other Ansible modules and even be simplified.
The first task could use replace module or possibly even better, the lineinfile module. It depends on how many lines with the same patter might be present.

The second task is not clear to me the respective context, but it seems it could be replaced by set_fact module.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ansible Ansible remediation update. productization-issue Issue found in upstream stabilization process.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants