# How to run only one role out of a playbook?

**URL:** <https://forum.ansible.com/t/how-to-run-only-one-role-out-of-a-playbook/26096>\
**Category:** Ansible Project\
**Created:** [November 21, 2017, 1:59pm UTC](https://forum.ansible.com/t/how-to-run-only-one-role-out-of-a-playbook/26096 "2017-11-21T13:59:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![akazia.info](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@akazia.info](https://forum.ansible.com/u/akazia.info)\
**Post date:** [November 21, 2017, 1:59pm UTC](https://forum.ansible.com/t/how-to-run-only-one-role-out-of-a-playbook/26096/1 "2017-11-21T13:59:11Z")

</div>

Hello

I have a site.yml which imports several playbooks.

- import\_playbook: webservers.yml

- …

Every playbook “calls” several roles:

- name: apply the webserver configuration  
hosts: webservers

roles:

- javajdk
- tomcat
- apache

Now how can I run lets say only the javajdk role ?

ansible-playbook -i inventory/xx webservers.yml would run all roles… I know that there are tags, but how do I assign them to a role in general?

Thanks a lot  
Michael

---

<div class="post-metadata">

**Author:** ![Mischa\_ter\_Smitten](https://avatars.discourse-cdn.com/v4/letter/m/c0e974/32.png) [@Mischa\_ter\_Smitten](https://forum.ansible.com/u/Mischa_ter_Smitten)\
**Post date:** [November 21, 2017, 7:08pm UTC](https://forum.ansible.com/t/how-to-run-only-one-role-out-of-a-playbook/26096/2 "2017-11-21T19:08:57Z")

</div>

If you tag the roles, you can use ansible-playbook --tags some-tag

---

<div class="post-metadata">

**Author:** ![akazia.info](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@akazia.info](https://forum.ansible.com/u/akazia.info)\
**Post date:** [November 21, 2017, 7:21pm UTC](https://forum.ansible.com/t/how-to-run-only-one-role-out-of-a-playbook/26096/3 "2017-11-21T19:21:31Z")

</div>

Hello thank,

well I can have - role: javajdk  
tags: javajdk

but this tags this role in this ONE palybook. But if I run an other playbook with - role: javajdk there is not tag.  
So either I have to tag it every time or, smater, I would tag the role itself. But I have not found a method to do so

Michael

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [November 21, 2017, 9:10pm UTC](https://forum.ansible.com/t/how-to-run-only-one-role-out-of-a-playbook/26096/4 "2017-11-21T21:10:38Z")

</div>

just reference the role directly, its much simpler than calling other  
playbooks to just use one of their roles
