Best practice for roles with per item configuration

I am trying to find the best way to write roles which have a per item configurations. By that I mean something like nginx or uwsgi where there are multiple sites or applications.

For example my current nginx role has a nginx_sites variable which is a dictionary of multiple site configurations:

`
nginx_sites:
proj1:

  • root /var/www
  • listen 80
  • location: /
    options:

Are there any examples for a configuration like this?

I can’t find good examples of modular, reusable roles which can be used in conjunction with other roles.

Easiest way would be to have a role like “foo_site” and include it more than once:

  • hosts: webservers:
    roles:
  • { name: foo_site, a: 1, b: 2 }
  • { name: bar_site, c: 2, d: 3 }

etc