Command module hangs indefinitely

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

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

Hi Karol,

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

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