There is a timeout you can set for which the async engine will
automatically kill the job if it runs longer than that. There is,
however, no way to stop an async job on demand. Once started, they
presently complete.
It would require the following changes to support on demand slaying:
(A) In the file that is to be polled by async_status and is set up by
async_wrapper, record the pid of the innermost forked kid (presumably
as a simple "pid" variable in the JSON file)
(B) Teach async_status a "terminate=yes|no" option that kills the pid
set in the job status file from (A). If pid was in the JSON file it
would kill the process, otherwise, it would return an error that the
pid was not
yet recorded. If the status of the job was not marked as running it
would not try to kill anything.
Patches, provided they stay concise, would be accepted, and probably
are not that difficult to add.
(Given that terminating a module midstream is not something we
generally want to encourage, this should not be wired up to
/usr/bin/ansible or /usr/bin/ansible-playbook as an Interrupt Handler,
as tempting as that might be -- once a playbook launches a module, I
want it to complete)