Asynchronous ad hoc tasks
You can execute long-running operations in the background withad hoc tasks. For example, to executelong_running_operationasynchronously in the background, with a timeout (-B) of 3600 seconds, and without polling (-P):
To check on the job status later, use theasync_statusmodule, passing it the job ID that was returned when you ran the original job in the background:
Ansible can also check on the status of your long-running job automatically with polling. In most cases, Ansible will keep the connection to your remote node open between polls. To run for 30 minutes and poll for status every 60 seconds:
Poll mode is smart so all jobs will be started before polling begins on any machine. Be sure to use a high enough--forksvalue if you want to get all of your jobs started very quickly. After the time limit (in seconds) runs out (-B), the process on the remote nodes will be terminated.
Asynchronous mode is best suited to long-running shell commands or software upgrades. Running the copy module asynchronously, for example, does not do a background file transfer.