Can I run plays in parallel?

I have 10 files with a play each. In total these plays provision 4 hosts. I have written a function in bash that takes as an argument the host I want to provision and calls ansible with all 10 playbooks and a -l(limit) parameter for only the host I provided. I can pass multiple hosts too.

So, when I pass 3 hosts, ansible starts running and it goes through each play one by one. This means that a host may have to unnecessarily wait for previous plays to finish before it is the turn of one of its play.

Is there a way to say to ansible to run all plays in parallel? I could find workaround in bash, but I would like to know if this is possible in ansible.

It's not possible in Ansible, so you would need to run multiple ansible-playbook in bash.

you can run multiple plays in one playbook. For example:

hosts: localhost
roles:

  • create_vm

hosts: vm_created
roles:

  • configure_vm

this also assumes you are using add_host in the first play.

Nick is asking for play in parallel, this will still be serial.

Right. Just mentioning an option.