Skip to content

Inefficient Shell commands used #9662

@pemsith

Description

@pemsith

Describe the bug
There's shell commands used in the play to create directories and grant access. This can cause performance overhead. The recommended way is to use an Ansible moduled dedicated for these actions

To Reproduce
Instance 1: Go to ansible/configs/ocp-ha-disconnected-lab/post_ocp_nfs_config.yml
see this play. use file module instead

  • name: Step 00xxxxx post software
    hosts: support
    gather_facts: false
    become: true
    tasks:
    • name: Create user vols
      shell: "mkdir -p /srv/nfs/user-vols/vol{1..{{user_vols}}}"
    • name: chmod the user vols
      shell: "chmod -R 777 /srv/nfs/user-vols"

Instance 2: Go to ansible/configs/ocp-ha-disconnected-lab/post_software.yml
use file module instead

  • name: Configure NFS host for user-vols if required
    hosts: support
    gather_facts: false
    become: true
    tasks:
    • name: Create user vols
      shell: "mkdir -p /srv/nfs/user-vols/vol{1..{{user_vols}}}"
      tags:
      • openshift_nfs_config
    • name: chmod the user vols
      shell: "chmod -R 777 /srv/nfs/user-vols"
      tags:
      • openshift_nfs_config

Instance 3: Go to ansible/configs/ocp-ha-lab/post_ocp_nfs_config.yml
use file module instead

Instance 4: Go to ansible/configs/ocp-ha-lab/post_software.yml
use file module instead

Instance 5: go to ansible/configs/rhel-security/nbde.yml
you can use Firewalld module instead
- name: Firewalld - add cockpit service
command: /usr/bin/firewall-cmd --permanent --add-service=cockpit

Instance 6: go to ansible/configs/sap-hana/software.yml
you can use Yum module
- name: Ensure Python3 package is installed and alternatives for python updated
shell: >
yum install -y python3 && alternatives --set python /usr/bin/python3

Expected behavior
use Ansible module for better performance and avoid shell and command as much as possible

Verions (please complete the following information):

  • OS - Cent OS 9

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions