My playbook hangs during a task.

I have written a playbook that checks for accessible hosts, then copies a script to those hosts, runs the script, copies output to file and then looks for that file and copies it back to the local machine. I ran this playbook through a couple of linters and even ran it using the --syntax-check flag and everything checks out fine. When I run the playbook against a small list of hosts, it hangs on the task “Copy Files”. Not sure what the problem is and am hoping a fresh set of eyes on this will point out something I missed. I am running this on an Oracle Linux 7 server and the hosts are all Oracle Linux 7.

`

I have written a playbook that checks for accessible hosts, then copies a script to those hosts, runs the script, copies
output to file and then looks for that file and copies it back to the local machine. I ran this playbook through a
couple of linters and even ran it using the --syntax-check flag and everything checks out fine. When I run the playbook
against a small list of hosts, it hangs on the task "Copy Files". Not sure what the problem is and am hoping a fresh
set of eyes on this will point out something I missed. I am running this on an Oracle Linux 7 server and the hosts are
all Oracle Linux 7.

First step would be to verify whether the list of hosts in reachable group is accurate (use debug to get a list of the
hosts in this group).

Second step would be to login into the host and find out what causes the hanging.

Regards
         Racke

We faced the same problem in our production. So if the node is slow//sluggish or goes unresponsive while playbook is running, Ansible will not leave the connection or in other words will keep waiting for output from the node(s). Well, in the case, playbooks seems to be hang.

Try to use async poll in the task:

https://docs.ansible.com/ansible/latest/user_guide/playbooks_async.html