# Ansible hanging for long shell commands on OSX

**URL:** <https://forum.ansible.com/t/ansible-hanging-for-long-shell-commands-on-osx/13321>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [August 16, 2013, 7:29pm UTC](https://forum.ansible.com/t/ansible-hanging-for-long-shell-commands-on-osx/13321 "2013-08-16T19:29:32Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tristan\_Zajonc](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@Tristan\_Zajonc](https://forum.ansible.com/u/Tristan_Zajonc)\
**Post date:** [August 16, 2013, 7:29pm UTC](https://forum.ansible.com/t/ansible-hanging-for-long-shell-commands-on-osx/13321/1 "2013-08-16T19:29:32Z")

</div>

Hi,

I’m experience Ansible hanging on long-running shell tasks with Ansible 1.3 (connecting with sudo and ssh). The tasks appear to be complete if I ssh in and `ps aux` but the playbook never gets to the next task. Strangely, this problem only happens when running the playbook from OSX to Ubuntu 12.04; it appears to work fine running from Ubuntu 12.04 to Ubuntu 12.04. The type of tasks I’m running are:

- name: install llvm  
shell: cd /sense;tar -xvf llvm-3.2.src.tar.gz; cd llvm-3.2.src;./configure --enable-optimized;REQUIRES\_RTTI=1 make;make install creates=/usr/local/lib/libllvm.a

This is obviously one of those annoying to debug issues, since it’s not entirely reproducible. But perhaps this issue has cropped up for others?

Thanks,  
Tristan

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 16, 2013, 7:31pm UTC](https://forum.ansible.com/t/ansible-hanging-for-long-shell-commands-on-osx/13321/2 "2013-08-16T19:31:42Z")

</div>

I haven’t seen any signs of any OSX issues.

Are you sure your command is not going interactive or something in your Makefile is not daemonizing properly?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 16, 2013, 7:32pm UTC](https://forum.ansible.com/t/ansible-hanging-for-long-shell-commands-on-osx/13321/3 "2013-08-16T19:32:27Z")

</div>

Suggest possibly feeding it \< /dev/null BTW

---

<div class="post-metadata">

**Author:** ![Patrick\_Regan](https://avatars.discourse-cdn.com/v4/letter/p/7cd45c/32.png) [@Patrick\_Regan](https://forum.ansible.com/u/Patrick_Regan)\
**Post date:** [August 16, 2013, 7:34pm UTC](https://forum.ansible.com/t/ansible-hanging-for-long-shell-commands-on-osx/13321/4 "2013-08-16T19:34:15Z")

</div>

Couple things to look into.

First is check to see if your ssh client configs are keeping the connection alive. Look into ServerAliveInterval and ServerAliveCountMax.

I’d also highly suggest using Ansible’s async option. [http://www.ansibleworks.com/docs/playbooks2.html#asynchronous-actions-and-polling](http://www.ansibleworks.com/docs/playbooks2.html#asynchronous-actions-and-polling)

---

<div class="post-metadata">

**Author:** ![Patrick\_Regan](https://avatars.discourse-cdn.com/v4/letter/p/7cd45c/32.png) [@Patrick\_Regan](https://forum.ansible.com/u/Patrick_Regan)\
**Post date:** [August 16, 2013, 7:34pm UTC](https://forum.ansible.com/t/ansible-hanging-for-long-shell-commands-on-osx/13321/5 "2013-08-16T19:34:50Z")

</div>

Oops, just re-read it. Looks like it’s hanging not disconnecting. My suggestions may not be helpful. Sorry.

---

<div class="post-metadata">

**Author:** ![Tristan\_Zajonc](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@Tristan\_Zajonc](https://forum.ansible.com/u/Tristan_Zajonc)\
**Post date:** [August 16, 2013, 8:12pm UTC](https://forum.ansible.com/t/ansible-hanging-for-long-shell-commands-on-osx/13321/6 "2013-08-16T20:12:24Z")

</div>

Thanks, I will try the \< /dev/null trick and investigate further. Builds are slow so I can’t quickly try. I actually upgraded to latest git version, in case my Linux and OSX boxes where out of sync on 1.3. I now get an unrelated error about too many open files. I assume this is a bug that was recently introduced?

TASK: [generate locale] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [[ec2-107-22-11-109.compute-1.amazonaws.com](http://ec2-107-22-11-109.compute-1.amazonaws.com)] =\> Traceback (most recent call last):  
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ansible/runner/ **init**.py”, line 368, in \_executor  
exec\_rc = self.\_executor\_internal(host, new\_stdin)  
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ansible/runner/ **init**.py”, line 455, in \_executor\_internal  
return self.\_executor\_internal\_inner(host, self.module\_name, self.module\_args, inject, port, complex\_args=complex\_args)  
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ansible/runner/ **init**.py”, line 622, in \_executor\_internal\_inner  
result = handler.run(conn, tmp, module\_name, module\_args, inject, complex\_args)  
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ansible/runner/action\_plugins/normal.py”, line 54, in run  
return self.runner.\_execute\_module(conn, tmp, module\_name, module\_args, inject=inject, complex\_args=complex\_args)  
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ansible/runner/ **init**.py”, line 286, in \_execute\_module  
(remote\_module\_path, module\_style, shebang) = self.\_copy\_module(conn, tmp, module\_name, args, inject, complex\_args)  
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ansible/runner/ **init**.py”, line 813, in \_copy\_module  
self.\_transfer\_str(conn, tmp, module\_name, module\_data)  
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ansible/runner/ **init**.py”, line 252, in \_transfer\_str  
conn.put\_file(afile, remote)  
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ansible/runner/connection\_plugins/ssh.py”, line 244, in put\_file  
stdout=subprocess.PIPE, stderr=subprocess.PIPE)  
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py”, line 672, in **init**  
errread, errwrite)  
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py”, line 1102, in \_execute\_child

errpipe\_read, errpipe\_write = os.pipe()  
OSError: [Errno 24] Too many open files

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 16, 2013, 8:39pm UTC](https://forum.ansible.com/t/ansible-hanging-for-long-shell-commands-on-osx/13321/7 "2013-08-16T20:39:44Z")

</div>

Too many open files is probably you just needing to increase the ulimit.

I don’t think there’s a bug.

Not sure of your environmental specifics when you are running this.

---

<div class="post-metadata">

**Author:** ![Tristan\_Zajonc](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@Tristan\_Zajonc](https://forum.ansible.com/u/Tristan_Zajonc)\
**Post date:** [August 16, 2013, 8:57pm UTC](https://forum.ansible.com/t/ansible-hanging-for-long-shell-commands-on-osx/13321/8 "2013-08-16T20:57:39Z")

</div>

This cropped up immediately after upgrading ansible, with no other changes, so it feels as if some `close` isn’t happening as before. Perhaps there are just more opens though in new code path. I will increase my limits (although ideally this wouldn’t be necessary for basic ansible usable). If it’s helpful, I’m on OSX 10.7, ansible 1.3 HEAD, ssh connection, using executable inventory file that returns JSON on --list and --host.

Tristan

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [August 16, 2013, 9:18pm UTC](https://forum.ansible.com/t/ansible-hanging-for-long-shell-commands-on-osx/13321/9 "2013-08-16T21:18:17Z")

</div>

bisect!

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [August 16, 2013, 11:28pm UTC](https://forum.ansible.com/t/ansible-hanging-for-long-shell-commands-on-osx/13321/10 "2013-08-16T23:28:51Z")

</div>

Let me know if you manage to track that down with bisect.

---

<div class="post-metadata">

**Author:** ![Jimmy\_Tang](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@Jimmy\_Tang](https://forum.ansible.com/u/Jimmy_Tang)\
**Post date:** [August 19, 2013, 3:54pm UTC](https://forum.ansible.com/t/ansible-hanging-for-long-shell-commands-on-osx/13321/11 "2013-08-19T15:54:23Z")

</div>

as suggested from the closing of [https://github.com/ansible/ansible/issues/3877](https://github.com/ansible/ansible/issues/3877) – I’m seeing a similar symptom on my osx 10.7 install, my playbooks take about ~20mins before it fails with the “too open many files error”, repeated runs give me the same error.

doing “ulimit -n 2048” on my mac works around the problem. I’m going to see if i can run a bisect in the next week or so to find out where this first started happening.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 19, 2013, 4:55pm UTC](https://forum.ansible.com/t/ansible-hanging-for-long-shell-commands-on-osx/13321/12 "2013-08-19T16:55:03Z")

</div>

Ok, yeah, so we need a lot more info…

How many hosts do you have?  
What Ansible version?

What tasks?

etc

Help us with how to reproduce this.

Thanks!

---

<div class="post-metadata">

**Author:** ![Jimmy\_Tang](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@Jimmy\_Tang](https://forum.ansible.com/u/Jimmy_Tang)\
**Post date:** [August 19, 2013, 6:29pm UTC](https://forum.ansible.com/t/ansible-hanging-for-long-shell-commands-on-osx/13321/13 "2013-08-19T18:29:32Z")

</div>

Just some info on the current system FYI…

- it fails on 4 hosts (also just fails on my vagrant test system, which consists of one host)
- it’s a recent version of ansible – as of commit 5847720746de4109f802a8337b4e1a581719ea9b
- there’s about ~110 steps in total, it seems to fail at different points on my two macs

ansible seems to open up either lots of file handles or processes, i’ve noticed when im running the playbooks which causes the crash I am unable to log into the host that launched the playbook and I get a resource not available error. again, i’ll try and run git bisect when i get a chance during the week or next week.

Thanks,  
Jimmy
