It does work for me: I created an ansible.cfg
file:
[defaults]
task_timeout=2
next to a test playbook:
- hosts: localhost
gather_facts: false
tasks:
- ansible.builtin.command: /bin/sh -c 'sleep 10'
When running the playbook, I get:
[ERROR]: Task failed: Action failed: The ansible.builtin.command action failed to execute in the expected time frame (2) and was terminated