/bin/sh: sudo: command not found

Hi,

My environment is as follows:

AWX 19.2.2

Ansible 2.9.13

config file = /etc/ansible/ansible.cfg
configured module search path = [‘/usr/share/ansible/openshift’]
ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.6.8 (default, Dec 5 2019, 15:45:45) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]

I’m having issues running an existing VM provisioning playbook (VM being provisioned is RHEL) - it’s now failing with:

{

“module_stdout”: “”,
“module_stderr”: “/bin/sh: sudo: command not found\n”,
“msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”,
“rc”: 127,
“_ansible_no_log”: false,
“changed”: false,
“item”: { /bin/sh sudo: command not found }

}

Adding sudo at playbook level returns:

{
“ansible_facts”: {},
“msg”: “The following modules failed to execute: ansible.legacy.setup\n”,
“failed_modules”: {
“ansible.legacy.setup”: {
“failed”: true,
“module_stdout”: “/bin/sh: /usr/bin/python: No such file or directory\r\n”,
“module_stderr”: “Shared connection to 172.18.10.104 closed.\r\n”,
“msg”: “The module failed to execute correctly, you probably need to set the interpreter.\nSee stdout/stderr for the exact error”,
“rc”: 127
}
},
“_ansible_verbose_override”: true,
“_ansible_no_log”: false,
“changed”: false
}

Anyone has a clue?

Thanks for your assistance!

Roberto

let me guess: RHEL9?

RHEL9 does not have python2 anymore. You might want to force ansible to use
python3 by host var.

Cheers
MH

It’s RHEL 8_4 actually.

We’ve seen this before when delegating a task which has sudo on it to localhost. The default execution environment (awx-ee) container does not have sudo installed so when ansible attempts to run the task you get the “sudo: command not found”.
So having a task like this might be the culprit:

  • name: Run something

    delegate_to: localhost

If this is the scenario you are hitting you can get around it by adding “become: false” to your delegated task. This will run the task on localhost (i.e. inside the EE container) and have it not try and use sudo.

-The AWX team