# Command module hangs indefinitely

**URL:** <https://forum.ansible.com/t/command-module-hangs-indefinitely/24670>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [June 7, 2017, 12:10pm UTC](https://forum.ansible.com/t/command-module-hangs-indefinitely/24670 "2017-06-07T12:10:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sania\_Zara](https://avatars.discourse-cdn.com/v4/letter/s/cdc98d/32.png) [@Sania\_Zara](https://forum.ansible.com/u/Sania_Zara)\
**Post date:** [June 7, 2017, 12:10pm UTC](https://forum.ansible.com/t/command-module-hangs-indefinitely/24670/1 "2017-06-07T12:10:44Z")

</div>

Hi folks,

I am facing a rather peculiar issue. I am trying to build zlib library on an Ubuntu 16.04 server using Ansible 2.2.1.0. Here is what my playbook (role) looks like,

`

- name: Build Zlib.

command: “{{ item }}”

args:

chdir: “{{ zlibBuildDir }}”  
with\_items:

- “./configure”

- “make”

- “make install”  
register: commandStatus

- name: Display status  
debug:  
msg:“status → {{ commandStatus }}”

`

The problem I am facing is that when I run these commands manually, they all run successfully. But when executing with the Ansible, it executes the _configure_, _make_ and _make install_ commands successfully but then hangs and does not move to the next task at all. In the above code there is a dummy task “Display status” but it never gets executed and playbook hangs there indefinitely.

I have also tried running the commands using the shell module, but got the same result.

I have attached the console logs with maximum verbosity. I have to manually do “Ctrl+C” to free the terminal. Has anyone else faced this issue?

Thanks in advance.  
-Sania

---

<div class="post-metadata">

**Author:** ![Karol\_Czeryna](https://avatars.discourse-cdn.com/v4/letter/k/ed655f/32.png) [@Karol\_Czeryna](https://forum.ansible.com/u/Karol_Czeryna)\
**Post date:** [June 7, 2017, 2:06pm UTC](https://forum.ansible.com/t/command-module-hangs-indefinitely/24670/2 "2017-06-07T14:06:20Z")

</div>

Hi Sania!

You don’t need to check status that way. Ansible will check return code for each step you provided and if it’s not equal 0 - it will throw an error.

Regards your problem, I would say the buffer is quite big… (make is noisy) and that’s why Ansible may hang.

Best,  
Karol

---

<div class="post-metadata">

**Author:** ![Sania\_Zara](https://avatars.discourse-cdn.com/v4/letter/s/cdc98d/32.png) [@Sania\_Zara](https://forum.ansible.com/u/Sania_Zara)\
**Post date:** [June 8, 2017, 9:56am UTC](https://forum.ansible.com/t/command-module-hangs-indefinitely/24670/3 "2017-06-08T09:56:59Z")

</div>

Hi Karol,

Here check status is a dummy task. It doesn’t matter what task do I have after “Build Zlib” task, it hangs.

---

<div class="post-metadata">

**Author:** ![Karol\_Czeryna](https://avatars.discourse-cdn.com/v4/letter/k/ed655f/32.png) [@Karol\_Czeryna](https://forum.ansible.com/u/Karol_Czeryna)\
**Post date:** [June 8, 2017, 11:13am UTC](https://forum.ansible.com/t/command-module-hangs-indefinitely/24670/4 "2017-06-08T11:13:45Z")

</div>

Hi Sania!

Ok, in that case I would try to repeat this task in different way  
Try to split it up into steps (configure, make, make install) - without with\_items, so each step will have separate ansible task.  
Try to run this, log in into machine and check what is going on… (you can send stdout to file and then tail it …)

Also if you’re afraid that something may hang it’s good idea to use _timeout_ command (man timeout)

Best,  
Karol
