# Ansible role help for executing tags

**URL:** <https://forum.ansible.com/t/ansible-role-help-for-executing-tags/39268>\
**Category:** Get Help\
**Tags:** role\
**Created:** [December 20, 2024, 2:25pm UTC](https://forum.ansible.com/t/ansible-role-help-for-executing-tags/39268 "2024-12-20T14:25:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![USA\_Linux\_UAE](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/usa_linux_uae/32/4436_2.png) [@USA\_Linux\_UAE](https://forum.ansible.com/u/USA_Linux_UAE)\
**Post date:** [December 20, 2024, 2:25pm UTC](https://forum.ansible.com/t/ansible-role-help-for-executing-tags/39268/1 "2024-12-20T14:25:32Z")

</div>

Hello  
Newbie , trying to understand how a single task in role can be executed ?  
Is it possible in tasks/main.yml of roles to use ansible.tags and only execute ansible-playbook \<role.yml\> -i --tasks= \<task.name\> ?

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [December 20, 2024, 2:42pm UTC](https://forum.ansible.com/t/ansible-role-help-for-executing-tags/39268/2 "2024-12-20T14:42:45Z")

</div>

> [@USA\_Linux\_UAE](#):
>
> ansible-playbook \<role.yml\> -i --tasks= \<task.name\>

No, not exactly. `--tasks` is not an option on `ansible-playbook`. (And `-i` will want a parameter, but ignoring that…)

However, you can _tag_ a task (or a play if you have multiple plays in your playbook), and then run only the task(s)/play(s) with that tag with

```
ansible-playbook ... --tags=mytag

```

See the [tags docs](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_tags.html) for lots of examples.

[EDIT: Forget what I said about tags on plays. It does more than just tag a play; it also implicitly tags all the tasks in that play (and probably statically loaded with it). Stick with the tasks bit at first.]
