# I may find a bug in ansible 1.5

**URL:** <https://forum.ansible.com/t/i-may-find-a-bug-in-ansible-1-5/15081>\
**Category:** Ansible Project\
**Created:** [April 24, 2014, 4:28am UTC](https://forum.ansible.com/t/i-may-find-a-bug-in-ansible-1-5/15081 "2014-04-24T04:28:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![qiu\_jiawei](https://avatars.discourse-cdn.com/v4/letter/q/ad7895/32.png) [@qiu\_jiawei](https://forum.ansible.com/u/qiu_jiawei)\
**Post date:** [April 24, 2014, 4:28am UTC](https://forum.ansible.com/t/i-may-find-a-bug-in-ansible-1-5/15081/1 "2014-04-24T04:28:27Z")

</div>

I run an simple ansible module unarchive in ansible-playbook.  
the module look like below:

`

- name: untar the psutil module  
sudo: yes  
unarchive: src=psutil-2.1.0.tar.gz dest=/tmp/

`

then, the stange thing happen.  
it crash at one machine.

`

failed: [hadoop4] =\> {“failed”: true, “item”: “”}  
msg: dest ‘/tmp/’ must be an existing dir

`

absolutely,the dir must exist

After some debug, I found the bug is locate at ansible/runner/connection\_plugins/ paramiko\_ssh.py

`

def exec\_command(self, cmd, tmp\_path, sudo\_user=None, sudoable=False, executable=‘/bin/sh’, in\_data=None, su=None, su\_user=None):  
…  
try:  
chan.exec\_command(shcmd)  
if self.runner.sudo\_pass or self.runner.su\_pass:  
while not sudo\_output.endswith(prompt) and success\_key not in sudo\_output:  
chunk = chan.recv(bufsize)  
if not chunk:  
if ‘unknown user’ in sudo\_output:  
raise errors.AnsibleError(  
‘user %s does not exist’ % sudo\_user)  
else:  
raise errors.AnsibleError('ssh connection ’ +  
‘closed waiting for password prompt’)  
sudo\_output += chunk  
print “sudo\_op”  
print sudo\_output  
print “end”  
if success\_key not in sudo\_output:  
if sudoable:  
chan.sendall(self.runner.sudo\_pass + ‘\n’)  
elif su:  
chan.sendall(self.runner.su\_pass + ‘\n’)  
except socket.timeout:  
raise errors.AnsibleError(‘ssh timed out waiting for sudo.\n’ + sudo\_output)

stdout = ‘’.join(chan.makefile(‘rb’, bufsize))  
stderr = ‘’.join(chan.makefile\_stderr(‘rb’, bufsize))  
print “stdout”  
print stdout  
print “stderr”  
print stderr

`

after i add some print out code,I get the result look like below:  
correct machine:

`

make sudo cmd  
/bin/sh -c ‘sudo -k && sudo -H -S -p “[sudo via ansible, key=bbjyibguhjvfwaabbsfzxyenmjrwggts] password: " -u root /bin/sh -c '”’“‘echo SUDO-SUCCESS-bbjyibguhjvfwaabbsfzxyenmjrwggts; rc=0; [-r “/tmp/”] || rc=2; [-f “/tmp/”] || rc=1; [-d “/tmp/”] && echo 3 && exit 0; (/usr/bin/md5sum /tmp/ 2\>/dev/null) || (/sbin/md5sum -q /tmp/ 2\>/dev/null) || (/usr/bin/digest -a md5 /tmp/ 2\>/dev/null) || (/sbin/md5 -q /tmp/ 2\>/dev/null) || (/usr/bin/md5 -n /tmp/ 2\>/dev/null) || (/bin/md5 -q /tmp/ 2\>/dev/null) || (/usr/bin/csum -h MD5 /tmp/ 2\>/dev/null) || (/bin/csum -h MD5 /tmp/ 2\>/dev/null) || (echo “${rc} /tmp/”)’”‘"’’  
prompt  
[sudo via ansible, key=bbjyibguhjvfwaabbsfzxyenmjrwggts] password:  
success\_key  
SUDO-SUCCESS-bbjyibguhjvfwaabbsfzxyenmjrwggts  
sudo\_op  
[sudo via ansible, key=bbjyibguhjvfwaabbsfzxyenmjrwggts] password:  
end  
stdout

SUDO-SUCCESS-bbjyibguhjvfwaabbsfzxyenmjrwggts  
3

stderr

SUDO-SUCCESS-bbjyibguhjvfwaabbsfzxyenmjrwggts  
3

`  
the worng machine

`

make sudo cmd  
/bin/sh -c ‘sudo -k && sudo -H -S -p “[sudo via ansible, key=gvmwhrpunjinmzgbhpwhmnxnzmhyzupt] password: " -u root /bin/sh -c '”’“‘echo SUDO-SUCCESS-gvmwhrpunjinmzgbhpwhmnxnzmhyzupt; rc=0; [-r “/tmp/”] || rc=2; [-f “/tmp/”] || rc=1; [-d “/tmp/”] && echo 3 && exit 0; (/usr/bin/md5sum /tmp/ 2\>/dev/null) || (/sbin/md5sum -q /tmp/ 2\>/dev/null) || (/usr/bin/digest -a md5 /tmp/ 2\>/dev/null) || (/sbin/md5 -q /tmp/ 2\>/dev/null) || (/usr/bin/md5 -n /tmp/ 2\>/dev/null) || (/bin/md5 -q /tmp/ 2\>/dev/null) || (/usr/bin/csum -h MD5 /tmp/ 2\>/dev/null) || (/bin/csum -h MD5 /tmp/ 2\>/dev/null) || (echo “${rc} /tmp/”)’”‘"’’  
prompt  
[sudo via ansible, key=gvmwhrpunjinmzgbhpwhmnxnzmhyzupt] password:  
success\_key  
SUDO-SUCCESS-gvmwhrpunjinmzgbhpwhmnxnzmhyzupt  
sudo\_op  
SUDO-SUCCESS-gvmwhrpunjinmzgbhpwhmnxnzmhyzupt  
3

end  
stdout

stderr

`

It look like the the stdout shoule add back the sudo\_output??

And I want to know is it possible to reset some config for the worng machine to work right.

---

<div class="post-metadata">

**Author:** ![qiu\_jiawei](https://avatars.discourse-cdn.com/v4/letter/q/ad7895/32.png) [@qiu\_jiawei](https://forum.ansible.com/u/qiu_jiawei)\
**Post date:** [April 24, 2014, 6:24am UTC](https://forum.ansible.com/t/i-may-find-a-bug-in-ansible-1-5/15081/2 "2014-04-24T06:24:48Z")

</div>

Oh I find more infomation that the worng machine’s user could sudo without passwd.

在 2014年4月24日星期四UTC+8下午12时28分27秒，qiu jiawei写道：

---

<div class="post-metadata">

**Author:** ![qiu\_jiawei](https://avatars.discourse-cdn.com/v4/letter/q/ad7895/32.png) [@qiu\_jiawei](https://forum.ansible.com/u/qiu_jiawei)\
**Post date:** [April 24, 2014, 7:19am UTC](https://forum.ansible.com/t/i-may-find-a-bug-in-ansible-1-5/15081/3 "2014-04-24T07:19:54Z")

</div>

I make an pull request  
[https://github.com/ansible/ansible/pull/7148](https://github.com/ansible/ansible/pull/7148)

在 2014年4月24日星期四UTC+8下午2时24分48秒，qiu jiawei写道：
