Executing similar task on group of servers with different parameter

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.

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

  1. Directly in your playbook:

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 )