Ansible command line got stuck with shell module

Hi,

I am new to Ansible and immediately fall in love with its simplicity and power. I have tried Cfengine, Puppet, Chef and even Salt before. I went nowhere with any of them. Now with Ansible I can fast and effectively do what I need.

Today I have a strange issue with the shell module : I wanted to grab some data from remote web access logs :

ansible 192.168.1.1:192.168.1.2 -m shell -a ‘zcat /usr/local/apache/logs/access.log.1.gz | grep -i fbbd6daa045796e06098132d79’

Then the command just hung there. I checked out both 1.1 and 1.2, the python processes came and went pretty soon and scripts have already exit. But the managing Ansible command just still sat there.

If I changed the grep pattern to something like “index.php” and the results would get back. But sometimes some patterns just didn’t get through.

I uses -vvv to investigate and the last two lines were:

<192.168.1.1> EXEC /bin/sh -c ‘LANG=C LC_CTYPE=C /usr/bin/python /root/.ansible/tmp/ansible-tmp-1407579630.71-67715905644258/command; rm -rf /root/.ansible/tmp/ansible-tmp-1407579630.71-67715905644258/ >/dev/null 2>&1’
<192.168.1.2> EXEC /bin/sh -c ‘LANG=C LC_CTYPE=C /usr/bin/python /root/.ansible/tmp/ansible-tmp-1407579630.73-200216735938517/command; rm -rf /root/.ansible/tmp/ansible-tmp-1407579630.73-200216735938517/ >/dev/null 2>&1’

Now my workaround is

ansible 192.168.1.1:192.168.1.2 -m shell -a 'zcat /usr/local/apache/logs/access.log.1.gz | grep -i fbbd6daa045796e06098132d79 > /tmp/result.txt 2>&1 ’

But this is just too tiresome.

I have tried various combinations : from CentOS 5 (ActivePython 2.7.8) to CentOS 5 (stock python 2.4.3) , and CentOS 6 (stock python 2.6.6) to CentOS 6 (stock python 2.6.6). CentOS5 running with stock openssh4.3 and 6 with stock openssh 5.3.

I have checked syslogs on managing and managed hosts and saw no special messages. I don’t know if this is a bug. If so, I 'd love to file a bug report. Is there anything I can do to look into this further ?

Thanks for your attention.

ywliu

Hi!

I check this command in my enviroment and everything is ok.

ansible -i hosts/prod-hosts.ini all --limit=“app1” -m shell -a ‘zcat /var/log/nginx/access.log-20140806.gz | grep “02:44:20”’ show string from file

Why you use old version of ansible? I have 1.4.3 in production and 1.5.X in test.

“Why you use old version of ansible? I have 1.4.3 in production and 1.5.X in test.”

The latest release is 1.7.0, so you are also running a very old version and should update too :slight_smile:

For efficiency purposes on this list, we can only really only answer questions about the latest release.

Wow. I forgot to mention the most important info : I use the latest 1.7.0 on CentOS5 managing node and devel-branch on CentOS 6 one.

This is a very weird situation. It doesn’t happen all the time. Is there anything I can do myself to debug this one ?

ywliu