Run playbook against multiple hosts with different variables

So, we build alot of servers with different specs, and our YAML file variables for the build specs differ (like different CPU/RAM/HDD etc) , but the playbooks remain the same.

Currently, to run multiple builds concurrently, I have to open new ssh session to the Ansible server everytime and run the builds for each server using:

So first ssh session will run the build for the firsr server like this:
ansible-playbook playbooks/newonpremserver.yml -e “hostname=server01” -vvvv

Second ssh session will run the build for the second server like this:
ansible-playbook playbooks/newonpremserver.yml -e “hostname=server02” -vvvv

and so on…

Please suggest a better way to run builds concurrently.

Do you have an inventory file setup that has “server01” and “server02” setup in group(s)? For instance, instead of running the two examples above, setup an inventory file with both servers listed:

inventory.ini

server01
server02

Then run your playbook like this:

ansible-playbook playbooks/newonpremserver.yml -i inventory.ini -vvvv

Your playbook will run on both 01 and 02 at the same time. If you have “server01” through “server99”, then just add them to the inventory file and the playbook will run on all of them in parallel.

Yes, I have hosts (servers) added to my host file as a group (is that the inventory file)?

Foe example:

[onprem]
server01
server02