# hosts per role?

**URL:** <https://forum.ansible.com/t/hosts-per-role/20000>\
**Category:** Ansible Project\
**Created:** [December 14, 2015, 1:36pm UTC](https://forum.ansible.com/t/hosts-per-role/20000 "2015-12-14T13:36:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![silverdr](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@silverdr](https://forum.ansible.com/u/silverdr)\
**Post date:** [December 14, 2015, 1:36pm UTC](https://forum.ansible.com/t/hosts-per-role/20000/1 "2015-12-14T13:36:34Z")

</div>

We can do something like:

- hosts: group1  
&nbsp;&nbsp;roles:  
&nbsp;&nbsp;&nbsp;&nbsp;- role1

- hosts: group1:group2  
&nbsp;&nbsp;roles:  
&nbsp;&nbsp;&nbsp;&nbsp;- role2

- hosts: group2  
&nbsp;&nbsp;roles:  
&nbsp;&nbsp;&nbsp;&nbsp;- role3

etc, in a playbook. Would it be somehow possible to assign hosts "per role"? Something like:

- hosts: group1  
&nbsp;&nbsp;roles:  
&nbsp;&nbsp;&nbsp;&nbsp;- { role1, hosts: group3 }  
&nbsp;&nbsp;&nbsp;&nbsp;- { role2 }  
&nbsp;&nbsp;&nbsp;&nbsp;- { role3 }  
&nbsp;&nbsp;&nbsp;&nbsp;- { role4, hosts: group4 }

? The above doesn't seem to work 😉

---

<div class="post-metadata">

**Author:** ![Hugh\_Ma](https://avatars.discourse-cdn.com/v4/letter/h/5f8ce5/32.png) [@Hugh\_Ma](https://forum.ansible.com/u/Hugh_Ma)\
**Post date:** [December 14, 2015, 8:21pm UTC](https://forum.ansible.com/t/hosts-per-role/20000/2 "2015-12-14T20:21:29Z")

</div>

I’m not sure I understand what it is your trying to do here…

If you are trying to have some hosts execute another group’s role, you can use **includes**.  
Otherwise, if you can explain why you are nesting **group3/4** under **roles** when you have **group1** set as **hosts**.
