Are Tags from the dark side ???

Hello

I have been reading squilions of articles but I am still unsure if the usage of tags is a good practice. It seems to me that adding tags to tasks quickly leads to a cumbersome situation. How ever a tag on a role might be ok?

I think of having a main yaml like sites.yml which includes all needed playbooks e.g. webservers.yml and dbservers.yml
The playbooks e.g. webservers.yml define the hosts to act on and the roles to run.
The roles should self standing and independent, I think of tagging the role with its own name. eg. javajdk gets tag: javajdk

so I can run
ansible-playbook -i inventory/staging webservers
to do a complet setup or
so I can run ansible-playbook -i inventory/staging webservers -t javajdk
to only setup javajdk on the webservers

.
├── inventories

│ ├── production
│ └── staging

├── roles

│ ├── tomcat
│ └── javajdk

├── site.yml

├── dbservers.yml

└── webservers.yml

What do you think? Did I got it correct? Is there a better approach ?

Thanks a lot :slight_smile:
Michael

Here is a littel edit:
I struggle to find the correct place where I would add the tag for the role. I do not want to tag the role in webservers.yml since this would not be a global definition. But I failed to find the correct place in roles/javajdk - is there any?
Other option: assuming i have many roles included in werbservers.yml - is there an other option to run only one of the roles ?

Here is a littel edit:
I struggle to find the correct place where I would add the tag for the
role. I do not want to tag the role in webservers.yml since this would not
be a global definition. But I failed to find the correct place in
roles/javajdk - is there any?

You would need to tag every task in the role.

Other option: assuming i have many roles included in werbservers.yml - is
there an other option to run only one of the roles ?

Options as on ansible-playbook command line, then the answer is no.
You could use extra vars on the command line and have when on roles the roles.

As a new feature, you could imagine being able to put something like

  tags:
    - javajdk

into .../roles/javajdk/meta/defaults.yml, but I don't think there's
currently a way to tell a role "add this tag to all your tasks", inside
the role itself, other than adding the tag explicitly to all the tasks.

                                      -Josh (jbs@care.com)

(apologies for the automatic corporate disclaimer that follows)

This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.

tasks/main.yml:

- tags: x, y z
  block:
    - rest of tasks
...