# ansible 2 ping failure

**URL:** <https://forum.ansible.com/t/ansible-2-ping-failure/20188>\
**Category:** Ansible Project\
**Created:** [January 13, 2016, 12:04am UTC](https://forum.ansible.com/t/ansible-2-ping-failure/20188 "2016-01-13T00:04:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fed](https://avatars.discourse-cdn.com/v4/letter/f/ed8c4c/32.png) [@Fed](https://forum.ansible.com/u/Fed)\
**Post date:** [January 13, 2016, 12:04am UTC](https://forum.ansible.com/t/ansible-2-ping-failure/20188/1 "2016-01-13T00:04:45Z")

</div>

Hi Guys,  
I’m having some trouble with the new Ansible 2 when trying to run ping on a host that works with 1.9.4.

I’m getting the following:

$ ansible -i test all -m ping -u root -vvvvv -c paramiko

Loaded callback minimal of type stdout, v2.0  
\<10.10.0.242\> ESTABLISH CONNECTION FOR USER: root on PORT 22 TO 10.10.0.242  
\<10.10.0.242\> EXEC mkdir -p “$( echo $HOME/.ansible/tmp/ansible-tmp-1452643119.18-173252181839542 )” && echo “$( echo $HOME/.ansible/tmp/ansible-tmp-1452643119.18-173252181839542 )”  
\<10.10.0.242\> PUT /var/folders/1d/nqrbvtz120nb7r2rjqzpvs7m0000gn/T/tmpjR2gSS TO /home/root/.ansible/tmp/ansible-tmp-1452643119.18-173252181839542/ping  
\<10.10.0.242\> EXEC LANG=en\_US.UTF-8 LC\_ALL=en\_US.UTF-8 LC\_MESSAGES=en\_US.UTF-8 /usr/bin/python /home/root/.ansible/tmp/ansible-tmp-1452643119.18-173252181839542/ping; rm -rf “/home/root/.ansible/tmp/ansible-tmp-1452643119.18-173252181839542/” \> /dev/null 2\>&1  
10.10.0.242 | FAILED! =\> {  
“changed”: false,  
“failed”: true,  
“invocation”: {  
“module\_name”: “ping”  
},  
“module\_stderr”: “”,  
“module\_stdout”: “\u001b[?1034h{"invocation": {"module\_args": {"data": null}}, "changed": false, "ping": "pong"}\r\n”,  
“msg”: “MODULE FAILURE”,  
“parsed”: false  
}

Previously on 1.9.4 I would get:

$ ansible -i test all -m ping -u root -vvvvv -c paramiko  
\<10.10.0.242\> ESTABLISH CONNECTION FOR USER: root on PORT 22 TO 10.10.0.242  
\<10.10.0.242\> REMOTE\_MODULE ping  
\<10.10.0.242\> EXEC /bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1452643204.88-178243528154466 && echo $HOME/.ansible/tmp/ansible-tmp-1452643204.88-178243528154466’  
\<10.10.0.242\> PUT /var/folders/1d/nqrbvtz120nb7r2rjqzpvs7m0000gn/T/tmpqHPWsg TO /home/root/.ansible/tmp/ansible-tmp-1452643204.88-178243528154466/ping  
\<10.10.0.242\> EXEC /bin/sh -c ‘LANG=en\_US.UTF-8 LC\_CTYPE=en\_US.UTF-8 /usr/bin/python /home/root/.ansible/tmp/ansible-tmp-1452643204.88-178243528154466/ping; rm -rf /home/root/.ansible/tmp/ansible-tmp-1452643204.88-178243528154466/ \>/dev/null 2\>&1’  
10.10.0.242 | success \>\> {  
“changed”: false,  
“ping”: “pong”  
}

Any idea what the culprit might be? At first glance the only real difference I can see is that the older version had /bin/sh -c in front, but that could just be a change in logging.

Cheers

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [January 13, 2016, 3:50pm UTC](https://forum.ansible.com/t/ansible-2-ping-failure/20188/2 "2016-01-13T15:50:01Z")

</div>

Hrm, looks like there’s some garbage in front of the result. Can you open a github issue for this, with details on the target system included?

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [January 13, 2016, 5:17pm UTC](https://forum.ansible.com/t/ansible-2-ping-failure/20188/3 "2016-01-13T17:17:59Z")

</div>

Looks like your shell is injecting control characters into the output  
stream. (the initial junk is a terminal control code sequence:  
ESC[?1034h ). We'll probably need information about the shell you're  
using on the remote machine and its configuration.

-Toshio

---

<div class="post-metadata">

**Author:** ![Jurgen\_Haas2](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@Jurgen\_Haas2](https://forum.ansible.com/u/Jurgen_Haas2)\
**Post date:** [January 14, 2016, 9:35am UTC](https://forum.ansible.com/t/ansible-2-ping-failure/20188/4 "2016-01-14T09:35:05Z")

</div>

I’m having a similar issue:

`  
$ ansible -i inventory crcweb -m ping -vvv  
Using /home/jurgenhaas/.ansible.cfg as config file  
 ESTABLISH SSH CONNECTION FOR USER: jurgenhaas  
 SSH: EXEC ssh -C -q -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=jurgenhaas -o ConnectTimeout=10 -o ControlPath=/home/jurgenhaas/.ansible/cp/ansible-ssh-%h-%p-%r -tt crcweb ‘( umask 22 && mkdir -p “$( echo $HOME/.ansible/tmp/ansible-tmp-1452763749.58-212919486518705 )” && echo “$( echo $HOME/.ansible/tmp/ansible-tmp-1452763749.58-212919486518705 )” )’  
 PUT /tmp/tmpEhWM\_e TO ^/ping  
 SSH: EXEC scp -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=jurgenhaas -o ConnectTimeout=10 -o ControlPath=/home/jurgenhaas/.ansible/cp/ansible-ssh-%h-%p-%r /tmp/tmpEhWM\_e ‘[crcweb]:’“'”’ ^/ping’“'”‘’  
crcweb | FAILED! =\> {  
“failed”: true,  
“msg”: “ERROR! failed to transfer file to ^/ping:\n\nscp: ^/ping: No such file or directory\n”  
}

`

On the remote hosts we are using the fish shell instead of bash or others and that seems to be the root of the problem. When changing to bash as the login shell, Ansible would work just fine, but that’s not really an option.

---

<div class="post-metadata">

**Author:** ![Jurgen\_Haas2](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@Jurgen\_Haas2](https://forum.ansible.com/u/Jurgen_Haas2)\
**Post date:** [January 14, 2016, 9:40am UTC](https://forum.ansible.com/t/ansible-2-ping-failure/20188/5 "2016-01-14T09:40:38Z")

</div>

Reported at GitHub: [https://github.com/ansible/ansible/issues/13882](https://github.com/ansible/ansible/issues/13882)

---

<div class="post-metadata">

**Author:** ![Fed](https://avatars.discourse-cdn.com/v4/letter/f/ed8c4c/32.png) [@Fed](https://forum.ansible.com/u/Fed)\
**Post date:** [January 14, 2016, 5:54pm UTC](https://forum.ansible.com/t/ansible-2-ping-failure/20188/6 "2016-01-14T17:54:36Z")

</div>

I’ll check out the github issue, but I just wanted to post back here.

I narrowed down the issue to being related to the local TERM environment variable (xterm-256color). Because my local terminal was consuming the garbage characters when I was running the ping command remotely, the only way to see the escape characters is to redirect to a file &\> out and you’ll see them there (it took a moment to realize what was going on because originally I was just running the python ping command by hand and I wasn’t seeing the starting escape characters).

If you plaster TERM=vt100 in front of any of your ansible commands things work great and the ping command works.  
Another interesting thing to note is that if you enable pipelining=true in your ansible.cfg, you don’t need TERM=vt100 to be set.

I didn’t think sending my local term was intended - I was able to track down the issue in the paramiko code (it calls os.sys to get the local term) but I couldn’t find the corresponding openssh issue.

Cheers

---

<div class="post-metadata">

**Author:** ![Fed](https://avatars.discourse-cdn.com/v4/letter/f/ed8c4c/32.png) [@Fed](https://forum.ansible.com/u/Fed)\
**Post date:** [January 14, 2016, 9:33pm UTC](https://forum.ansible.com/t/ansible-2-ping-failure/20188/7 "2016-01-14T21:33:42Z")

</div>

@abadger opened up an issue for my particular problem:

[https://github.com/ansible/ansible/issues/13895](https://github.com/ansible/ansible/issues/13895)

cheers!
