'Run each task once on the first available host asynchronously in Ansible

I am new to Ansible and have gotten the idea of how Anisble works in a common case, like I have various hosts and I need to perform some tasks on each host.

But what if I need to run each task once on the first available host asynchronously?

My case is building an application for 4 platforms and I have 2 or more hosts to contribute.

I would like to have something like:

 1. Host A builds Android
 2. Host B builds iOS

--- waiting for any host to complete its task

 3. Host A builds OSX

--- waiting for any host to complete its task

 4. Host A builds Windows (if building iOS on Host B takes ages to complete)

Apparently strategy: free and run_once is not working together and clearly I misunderstood them.

Any ideas or solutions?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source