# Roles with tags not respecting the tag, Instead playing all the tast defined

**URL:** <https://forum.ansible.com/t/roles-with-tags-not-respecting-the-tag-instead-playing-all-the-tast-defined/17919>\
**Category:** Ansible Project\
**Created:** [April 7, 2015, 6:53pm UTC](https://forum.ansible.com/t/roles-with-tags-not-respecting-the-tag-instead-playing-all-the-tast-defined/17919 "2015-04-07T18:53:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vijay\_Mohan](https://avatars.discourse-cdn.com/v4/letter/v/ee7513/32.png) [@Vijay\_Mohan](https://forum.ansible.com/u/Vijay_Mohan)\
**Post date:** [April 7, 2015, 6:53pm UTC](https://forum.ansible.com/t/roles-with-tags-not-respecting-the-tag-instead-playing-all-the-tast-defined/17919/1 "2015-04-07T18:53:54Z")

</div>

```auto
Here is my play book:

```

```auto
- name: Install MySQL with replication
  hosts: mysql-master:mysql-slave
  user: root
  sudo: false
  roles:
    - common
    - admin-users
    - generic-directories
    - { role: iptables, tags: ['mysql-iptables'] }
    - mysql

```

```auto

```

```auto
I have ip tables tasks for different ports, I want to run the task depending on the group of servers. I have tagged the iptables task based on the group. 

```

```auto
When i ran the play book instead of playing the tagged task, its run through all the tasks defined in iptables role.

```

```auto
Please let me know if am doing anything wrong here.

```

---

<div class="post-metadata">

**Author:** ![Timothy\_Gerla](https://avatars.discourse-cdn.com/v4/letter/t/977dab/32.png) [@Timothy\_Gerla](https://forum.ansible.com/u/Timothy_Gerla)\
**Post date:** [April 7, 2015, 7:11pm UTC](https://forum.ansible.com/t/roles-with-tags-not-respecting-the-tag-instead-playing-all-the-tast-defined/17919/2 "2015-04-07T19:11:48Z")

</div>

When you tag a role, you’re saying “all of the tasks in this role are x”, not “run only the tasks in that role already tagged x”. If you find yourself trying to run subsets of tasks in a role, you might want to consider breaking down your role into separate roles. A role isn’t really meant to be cut apart and have parts run separately–those would be separate roles.

-Tim
