Ansible: Is the any chance of maintain same tag same role but diffrent host name in main yml file by putting any when condition from tasks inside role.

I have tried to maintain my main yml file like below

Hi,

when: inventory_hostname in groups['small_group']
Or