# Best practice for roles with per item configuration

**URL:** <https://forum.ansible.com/t/best-practice-for-roles-with-per-item-configuration/16416>\
**Category:** Ansible Project\
**Created:** [October 3, 2014, 2:40pm UTC](https://forum.ansible.com/t/best-practice-for-roles-with-per-item-configuration/16416 "2014-10-03T14:40:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andre](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@Andre](https://forum.ansible.com/u/Andre)\
**Post date:** [October 3, 2014, 2:40pm UTC](https://forum.ansible.com/t/best-practice-for-roles-with-per-item-configuration/16416/1 "2014-10-03T14:40:57Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![Andre](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@Andre](https://forum.ansible.com/u/Andre)\
**Post date:** [October 10, 2014, 4:17pm UTC](https://forum.ansible.com/t/best-practice-for-roles-with-per-item-configuration/16416/2 "2014-10-10T16:17:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [October 13, 2014, 8:54pm UTC](https://forum.ansible.com/t/best-practice-for-roles-with-per-item-configuration/16416/3 "2014-10-13T20:54:33Z")

</div>

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
