How to set timeout value for a task using shell module?

Hi Ansible Experts,
We are running tasks using shell module. Sometime these tasks are pending due to backend application server slow response. Is there anyway to set timeout for these tasks to exit after certain time period?

Regards
Saravanan

Have u explored async mode ??

Assuming the target machine is running a modern Linux version, you can
run the "timeout" command in your shell.

Like:

- shell: timeout -s 9 10 /usr/bin/command that does something

That will send a "kill -9" to the command if it doesn't finish in 10 seconds.

Thank you Steve.