ansible-playbook hangs during execution

I have a playbook (site.yml) which includes a bunch of other playbooks. Each of these individual playbooks includes one or more roles. I’ve had problems with site.yml hanging at a specific point during execution, so I ran the individual playbook in which it’s hanging. It still hangs at the same point, which is an apt task to install git. I commented this task out, and ansible-playbook progresses to the next task which is also an apt task, where it hangs again. To me it appears to be an issue with apt task execution on one or more hosts.

I tried to use ANSIBLE_KEEP_REMOTE_FILES=1 and -vvv to locate the script where it’s hanging, but the problem is that when it hangs it has only output the status of the run on the previous host, and when I ctrl-c it to quit out of the playbook execution it just outputs the full list of hosts in no particular order, so I don’t know which host it’s hanging on.

Does anyone have any suggestions as to how I can troubleshoot this issue? It’s a real problem for me as I can’t install a bunch of packages that I need.

Perhaps using -l to limit the playbook run to one host at a time would at least help you isolate the problem? I think -l takes group names and patterns if you have lots of hosts.

-vvvvv might give you a clue what is going on too.

Sounds like a solid plan, I’ll give it a go. Thanks!

Just an update, I used this method and was able to isolate the host that was causing the issue. It turned out to be an issue with my AWS VPC setup where the host didn’t have a path to the internet and apt was hanging while trying to install packages.