# Specifying roles dynamically at runtime for playbooks

**URL:** <https://forum.ansible.com/t/specifying-roles-dynamically-at-runtime-for-playbooks/16314>\
**Category:** Ansible Project\
**Created:** [September 23, 2014, 11:29pm UTC](https://forum.ansible.com/t/specifying-roles-dynamically-at-runtime-for-playbooks/16314 "2014-09-23T23:29:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sankalp\_Khare](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@Sankalp\_Khare](https://forum.ansible.com/u/Sankalp_Khare)\
**Post date:** [September 23, 2014, 11:29pm UTC](https://forum.ansible.com/t/specifying-roles-dynamically-at-runtime-for-playbooks/16314/1 "2014-09-23T23:29:34Z")

</div>

Hi,

I often come across the situation where I need to apply some roles X,Y,Z on a bunch of machines. How do I do that without having to edit the list of roles in a playbook? In other words, could there be something of the type :

$ ansible-playbook -i role-applier.yml --extra-vars ‘roles=[“X”,“Y”,“Z”]’

Thanks,  
Sankalp

---

<div class="post-metadata">

**Author:** ![willthames](https://avatars.discourse-cdn.com/v4/letter/w/8dc957/32.png) [@willthames](https://forum.ansible.com/u/willthames)\
**Post date:** [September 24, 2014, 1:08am UTC](https://forum.ansible.com/t/specifying-roles-dynamically-at-runtime-for-playbooks/16314/2 "2014-09-24T01:08:00Z")

</div>

Have a look at tags. Tag the role includes in the playbook, and then just pass the appropriate tags to ansible-playbook

[http://docs.ansible.com/playbooks\_roles.html#id6](http://docs.ansible.com/playbooks_roles.html#id6)

Will
