How to import host/group specific files into roles

Hello Team,

I am using role to install the kafka. I need help in using environment specific files from roles directory to the ansible code and eventually deployed onto the servers.

For example we have some files which are changing as per enviornment.
dev we have separate keystores and truststore
prod we have separate keystores and truststore
Now how can we use same role and variabalize to pick the env specific or group sepecific keystore/truststore or any other files??
I would like to have those files in ansible roles permanently. It should pick from any directory under roles , ideally inventory or files.

you can use the vars_from: '{{myenv}}.yml' of incluide_role/import_role to specify the source, assuming the myenv variable is dev/prod/qa/staging.

Hello Brian, Thanks a lot. That can work but we are looking for more elegant solution something we can store all those keystores as per inventory group name or host names with proper directory structure. Like i wish to place all dev group specific files inside inventory/dev/dev*.jks inventory/prod/prod.jks and then i want to use them in role playbook. Can this be done??

create a group per inventory that matches the {{inventory_file}}, then put the per env info in group_vars/<inventory_file>.yml