# Executing similar task on group of servers with different parameter

**URL:** <https://forum.ansible.com/t/executing-similar-task-on-group-of-servers-with-different-parameter/22016>\
**Category:** Ansible Developer\
**Created:** [July 14, 2016, 11:28am UTC](https://forum.ansible.com/t/executing-similar-task-on-group-of-servers-with-different-parameter/22016 "2016-07-14T11:28:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gurumurti\_Maharana](https://avatars.discourse-cdn.com/v4/letter/g/a183cd/32.png) [@Gurumurti\_Maharana](https://forum.ansible.com/u/Gurumurti_Maharana)\
**Post date:** [July 14, 2016, 11:28am UTC](https://forum.ansible.com/t/executing-similar-task-on-group-of-servers-with-different-parameter/22016/1 "2016-07-14T11:28:27Z")

</div>

Hi All ,

I need to execute same task parallelly of multiple hosts with different arguments based on host machine.  
for example:  
I want to install specific webservice service with id web1 , web2 web3 etc.

I have created a group called webserver and added 3 hosts ( number if host is not fixed ) and I want to install webservices on these servers.

in my play book.

host : webserver  
task  
role ;  
{ webservice , ID = web1 } ID will be different for diffrent host ( ID=web1 for first host , ID = web2 for second host, ID = web3 for third host )

Can you please suggest a optimised way to implement this.

---

<div class="post-metadata">

**Author:** ![Destry\_Jaimes](https://avatars.discourse-cdn.com/v4/letter/d/bc79bd/32.png) [@Destry\_Jaimes](https://forum.ansible.com/u/Destry_Jaimes)\
**Post date:** [July 14, 2016, 12:23pm UTC](https://forum.ansible.com/t/executing-similar-task-on-group-of-servers-with-different-parameter/22016/2 "2016-07-14T12:23:00Z")

</div>

There are several ways you can do this - here’s a few simple examples:

1. Directly in your playbook:

---

<div class="post-metadata">

**Author:** ![Gurumurti\_Maharana](https://avatars.discourse-cdn.com/v4/letter/g/a183cd/32.png) [@Gurumurti\_Maharana](https://forum.ansible.com/u/Gurumurti_Maharana)\
**Post date:** [July 14, 2016, 2:18pm UTC](https://forum.ansible.com/t/executing-similar-task-on-group-of-servers-with-different-parameter/22016/3 "2016-07-14T14:18:54Z")

</div>

Thanks Calamity ,

I am using Ansible tower to configure inventory.  
In that I am creating groups and each groups will have a list of hosts. ( Number of hosts are not known )  
I want to deploy the services on various hosts with which are there in the group with different id without passing it as a extra variable.

can we achieve this ? can we have some logic in playbook that will generate or fetch IDs from array ?

IDS = { web1, web2 , web3 )
