Docker and Ansible: running specific tasks on a dynamically defined host list

Hello,

I am running docker swarm with Ansible, my playbook deploys a docker image on specific node using swarm, post that deployment I want to execute certain Ansible tasks on the host where the image is deployed (still running from the same playbook role), as I am using consul as my backend I am able to retrieve the host(s) where the image is deployed and used “add_host” to create a host group.

I don’t know how to trigger the tasks via “include” on that hosts. Any thoughts how to achieve that ?

Below are the references of the main.yml of the role and the include file.

Regards,
Kamesh

main.yml

`