# Run playbook against multiple hosts with different variables

**URL:** <https://forum.ansible.com/t/run-playbook-against-multiple-hosts-with-different-variables/36392>\
**Category:** Ansible Project\
**Created:** [March 2, 2022, 3:34pm UTC](https://forum.ansible.com/t/run-playbook-against-multiple-hosts-with-different-variables/36392 "2022-03-02T15:34:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nitrous](https://avatars.discourse-cdn.com/v4/letter/n/dfb087/32.png) [@Nitrous](https://forum.ansible.com/u/Nitrous)\
**Post date:** [March 2, 2022, 3:34pm UTC](https://forum.ansible.com/t/run-playbook-against-multiple-hosts-with-different-variables/36392/1 "2022-03-02T15:34:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dan\_linder](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dan_linder/32/3833_2.png) [@dan\_linder](https://forum.ansible.com/u/dan_linder)\
**Post date:** [March 5, 2022, 5:02am UTC](https://forum.ansible.com/t/run-playbook-against-multiple-hosts-with-different-variables/36392/2 "2022-03-05T05:02:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Nitrous](https://avatars.discourse-cdn.com/v4/letter/n/dfb087/32.png) [@Nitrous](https://forum.ansible.com/u/Nitrous)\
**Post date:** [March 6, 2022, 1:49am UTC](https://forum.ansible.com/t/run-playbook-against-multiple-hosts-with-different-variables/36392/3 "2022-03-06T01:49:29Z")

</div>

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

Foe example:

[onprem]  
server01  
server02
