Ansible task timeout max length

Question:

I execute a shell: docker ps ... task in some of my playbooks. This normally works but sometimes the docker daemon hangs and docker ps does not return for ~2 hours.

How can I configure Ansible to timeout in a reasonable amount of time if docker ps does not return?

Answer:

There is no timeout-for-a-task-functionality implemented in Ansible.

You can try a workaround using asynchronous call, but for this case (clearly a kind of a bug) relying on the system might be easier and more appropriate.

See the GNU timeout command (if you run Docker, chances are the command is present on your OS):

Leave a Reply