Selectively execute tasks in an ansible role based on tags

Folks, need some help on this.
I have an existing ansible role which includes some tasks. Each task has a tag, some of them are tagged as "tag1’ and the others are tagged as “tag2”.
I want to include this role from another role and execute the tasks only tagged as “tag1”.

Note: I’m running the template through AAP 2.4 web interface and I don’t have access to the ansible command line.

How to achieve this?

There is a field called Job Tags for Job Templates (playbooks) in AAP which I belive does what you are asking.

1 Like

Tag selection cannot be done ‘in play’, only when calling it, I recommend for ‘in play selection’ to use different task files and the tasks_from parameter from include_role/import_role.

I’d go a step farther than that, and say generally the simpler you can keep your tags the better. Or rather, how you use tags in a given project. If you can clearly say, “Within the project, we use tags in this one way” then you might not go nuts. But start mixing different tag usage techniques at your own risk.

Also, I agree with @bcoca 's prior comment; that’s the way to do things, generally.

However, In this (one, special) case, assuming you aren’t already using tags in other ways in the project, you could consider using --skip-tags=tag2 when you only want to run only the tag1 tasks, and --skip-tags=tag1 when you only want to run the tag2 tasks. If you do this, consider it a temporary measure while you work out more general tagging techniques.