# /bin/sh: sudo: command not found

**URL:** <https://forum.ansible.com/t/bin-sh-sudo-command-not-found/36854>\
**Category:** AWX Project\
**Tags:** rhel, awx\
**Created:** [July 15, 2022, 7:20am UTC](https://forum.ansible.com/t/bin-sh-sudo-command-not-found/36854 "2022-07-15T07:20:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rob\_Cal](https://avatars.discourse-cdn.com/v4/letter/r/eb9ed0/32.png) [@Rob\_Cal](https://forum.ansible.com/u/Rob_Cal)\
**Post date:** [July 15, 2022, 7:20am UTC](https://forum.ansible.com/t/bin-sh-sudo-command-not-found/36854/1 "2022-07-15T07:20:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Mathias\_Homann](https://avatars.discourse-cdn.com/v4/letter/m/f05b48/32.png) [@Mathias\_Homann](https://forum.ansible.com/u/Mathias_Homann)\
**Post date:** [July 15, 2022, 7:29am UTC](https://forum.ansible.com/t/bin-sh-sudo-command-not-found/36854/2 "2022-07-15T07:29:33Z")

</div>

let me guess: RHEL9?

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

Cheers  
MH

---

<div class="post-metadata">

**Author:** ![Rob\_Cal](https://avatars.discourse-cdn.com/v4/letter/r/eb9ed0/32.png) [@Rob\_Cal](https://forum.ansible.com/u/Rob_Cal)\
**Post date:** [July 15, 2022, 9:30am UTC](https://forum.ansible.com/t/bin-sh-sudo-command-not-found/36854/3 "2022-07-15T09:30:10Z")

</div>

It’s RHEL 8\_4 actually.

---

<div class="post-metadata">

**Author:** ![AWX\_Project](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@AWX\_Project](https://forum.ansible.com/u/AWX_Project)\
**Post date:** [July 19, 2022, 8:40am UTC](https://forum.ansible.com/t/bin-sh-sudo-command-not-found/36854/4 "2022-07-19T08:40:24Z")

</div>

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
