# Can't execute command with su

**URL:** <https://forum.ansible.com/t/cant-execute-command-with-su/17067>\
**Category:** Ansible Project\
**Created:** [December 15, 2014, 4:46pm UTC](https://forum.ansible.com/t/cant-execute-command-with-su/17067 "2014-12-15T16:46:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![adrien\_nayrat](https://avatars.discourse-cdn.com/v4/letter/a/9dc877/32.png) [@adrien\_nayrat](https://forum.ansible.com/u/adrien_nayrat)\
**Post date:** [December 15, 2014, 4:46pm UTC](https://forum.ansible.com/t/cant-execute-command-with-su/17067/1 "2014-12-15T16:46:24Z")

</div>

##### ##### Hello,

I have an issue when using su mode in ansible. I wan’t ansible to log with the user “bill” and execute command with the user root. So to log with “bill” and then do an “su root”.

##### Ansible Version: 1.7.2##### Environment: Centos 6#####

##### Steps To Reproduce:

Do a simple test with ping command :  
ansible all -i host.txt -S -u bill --ask-su-pass --ask-pass -vvvv -f 1 -m ping

##### Actual Results:

The result is :  
ESTABLISH CONNECTION FOR USER: bill  
REMOTE\_MODULE ping  
EXEC [‘sshpass’, ‘-d6’, ‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘StrictHostKeyChecking=no’, ‘-o’, ‘Port=22’, ‘-o’, ‘GSSAPIAuthentication=no’, ‘-o’, ‘PubkeyAuthentication=no’, ‘-o’, ‘User=bill’, ‘-o’, ‘ConnectTimeout=10’, ‘[server.com](http://server.com)’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1418638075.39-50125361119600 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1418638075.39-50125361119600 && echo $HOME/.ansible/tmp/ansible-tmp-1418638075.39-50125361119600’”]  
PUT /tmp/tmptlkouT TO /home/bill/.ansible/tmp/ansible-tmp-1418638075.39-50125361119600/ping  
EXEC [‘sshpass’, ‘-d6’, ‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘StrictHostKeyChecking=no’, ‘-o’, ‘Port=22’, ‘-o’, ‘GSSAPIAuthentication=no’, ‘-o’, ‘PubkeyAuthentication=no’, ‘-o’, ‘User=bill’, ‘-o’, ‘ConnectTimeout=10’, ‘[server.com](http://server.com)’, u’/bin/sh -c 'su root -c “/bin/sh -c '”'“'echo SUDO-SUCCESS-mlqtvpmqewypsiiaqunboskgbigmqyja; LANG=C LC\_CTYPE=C /usr/bin/python /home/bill/.ansible/tmp/ansible-tmp-1418638075.39-50125361119600/ping; rm -rf /home/bill/.ansible/tmp/ansible-tmp-1418638075.39-50125361119600/ \>/dev/null 2\>&1'”'“'”'']

And ansible hang, nothing happen.  
When I check the permissions of “/home/bill/.ansible/tmp/ansible-tmp-1418638075.39-50125361119600/ping” the file isn’t executable by root :  
-rw------- 1 bill bill 52K 15 déc. 11:07 ping  
So when I try to execute manually “ping” I have a permission denied.

Why ansible doesn’t create ping file in root HOME instead of bill home ?
