Ansible roles to configure different multiple wordpress server

Hi Team!

I am having a big doubt while using Ansible to deploy my wordpress servers.

I am using the wp-cli utility to install wordpress, so I want to use ansible roles in order to execute each role to each server with the modifications needed.

For example I have three different server names: dev.akme.eus, test.akme.eus and www.akme.eus, Ok, that´s quite easy to do using vars folder in ansible roles structure. But at the time to define the hosts to execute, I don’t understand how can I define each host to use different vars, Could I define variables in hosts field in a role? As I have seen, role playbooks don’t use hosts field.

I am a little bit lost with this topic.

Thanks for support!

If you need host specific vars I recommend you do this in
host_vars/<hostname>.yml adjacent to inventory or play and not in
role, just have the roles use sane defaults or require these variables
be present (assert/fail tasks).