# unable to sudo su to another user and execute commands

**URL:** <https://forum.ansible.com/t/unable-to-sudo-su-to-another-user-and-execute-commands/24529>\
**Category:** Ansible Project\
**Created:** [May 20, 2017, 8:33am UTC](https://forum.ansible.com/t/unable-to-sudo-su-to-another-user-and-execute-commands/24529 "2017-05-20T08:33:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vish\_man](https://avatars.discourse-cdn.com/v4/letter/v/e68b1a/32.png) [@vish\_man](https://forum.ansible.com/u/vish_man)\
**Post date:** [May 20, 2017, 8:33am UTC](https://forum.ansible.com/t/unable-to-sudo-su-to-another-user-and-execute-commands/24529/1 "2017-05-20T08:33:47Z")

</div>

Hi,

Thanks in advance for helping me.

my ladap user on production server is “viman”  
my sudo su user on production server is “cassdb”

I am trying to execute commands as cassdb user like id, ps -ef|grep …,

but it gives error

10.45.206.104 | FAILED! =\> {  
“changed”: false,  
“failed”: true,  
“module\_stderr”: “”,  
“module\_stdout”: “\r\nSorry, user viman is not allowed to execute ‘/bin/sh -c echo BECOME-SUCCESS-uqhffxyayhqcqqdiouilnxxqumlcxobw; /usr/bin/python /tmp/ansible-tmp-1495268464.677336-247138043012258/command.py’ as cassdb on [TXN-cappblx042-03.prod.XXXY.com](http://TXN-cappblx042-03.prod.XXXY.com).\r\n”,  
“msg”: “MODULE FAILURE”,  
“rc”: 1  
}

commands I used tried are

ansible all -b -m shell -a ‘id -a’ --become-user=cassdb

cfg file is

defaults]  
inventory = /Users/viman/inventory  
remote\_tmp = /tmp  
forks = 5  
poll\_interval = 15  
sudo\_user = cassdb  
ask\_sudo\_pass = True  
ask\_pass = True  
transport = smart  
remote\_port = 22  
module\_lang = C  
gathering = implicit  
host\_key\_checking = False  
sudo\_exe = sudo  
timeout = 10  
remote\_user = viman  
module\_name = shell  
ansible\_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host}  
action\_plugins = /usr/share/ansible\_plugins/action\_plugins  
callback\_plugins = /usr/share/ansible\_plugins/callback\_plugins  
connection\_plugins = /usr/share/ansible\_plugins/connection\_plugins  
lookup\_plugins = /usr/share/ansible\_plugins/lookup\_plugins  
vars\_plugins = /usr/share/ansible\_plugins/vars\_plugins  
filter\_plugins = /usr/share/ansible\_plugins/filter\_plugins  
fact\_caching = memory  
[privilege\_escalation]  
become\_method=‘sudo’  
become\_user=‘cassdb’  
[paramiko\_connection]  
[ssh\_connection]  
pipelining = True  
scp\_if\_ssh = True  
[accelerate]  
accelerate\_port = 5099  
accelerate\_timeout = 30  
accelerate\_connect\_timeout = 5.0  
accelerate\_daemon\_timeout = 30  
[selinux]  
[colors]  
[diff]

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [May 26, 2017, 6:11pm UTC](https://forum.ansible.com/t/unable-to-sudo-su-to-another-user-and-execute-commands/24529/2 "2017-05-26T18:11:11Z")

</div>

It's not possible to combine sudo with su in Ansible, you need to choose one of them.
