# question about tags

**URL:** <https://forum.ansible.com/t/question-about-tags/35521>\
**Category:** Ansible Project\
**Tags:** kubernetes\
**Created:** [July 19, 2021, 7:43pm UTC](https://forum.ansible.com/t/question-about-tags/35521 "2021-07-19T19:43:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcpetro](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@jcpetro](https://forum.ansible.com/u/jcpetro)\
**Post date:** [July 19, 2021, 7:43pm UTC](https://forum.ansible.com/t/question-about-tags/35521/1 "2021-07-19T19:43:56Z")

</div>

I have a bit of a problem, and was wondering if anyone has ever done something like this. I have a playbook I am working on, where it updates firewalld rules for some kubernetes clusters we have. Rather than have a playbook per cluster, we elected to use tags, one for prod, one for nonprod, and one for beta.

What I am trying to do, is have task, that if it isn’t one of the three mentioned tags ( Prod, Non-Prod, Beta) then it executes, basically outputting a debug message that the only accepted tags are those three. Is there a way to say something like “If tags !=[Prod,Non-Prod,Beta] then output text”?

I was fairly sure that at some point I saw that there was a way to do that, and I can’t seem to find the example anymore so any help anyone can offer wold be greatly appreciated.

–John

---

<div class="post-metadata">

**Author:** ![Doug\_Hunley](https://avatars.discourse-cdn.com/v4/letter/d/dbc845/32.png) [@Doug\_Hunley](https://forum.ansible.com/u/Doug_Hunley)\
**Post date:** [July 19, 2021, 7:48pm UTC](https://forum.ansible.com/t/question-about-tags/35521/2 "2021-07-19T19:48:03Z")

</div>

You could inspect ansible\_run\_tags and see if those three tags are not in it.

---

<div class="post-metadata">

**Author:** ![jcpetro](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@jcpetro](https://forum.ansible.com/u/jcpetro)\
**Post date:** [July 19, 2021, 7:56pm UTC](https://forum.ansible.com/t/question-about-tags/35521/3 "2021-07-19T19:56:19Z")

</div>

oh, that is cool. I didn’t know about that one. Thanks, I will check it out.

–John

---

<div class="post-metadata">

**Author:** ![Doug\_Hunley](https://avatars.discourse-cdn.com/v4/letter/d/dbc845/32.png) [@Doug\_Hunley](https://forum.ansible.com/u/Doug_Hunley)\
**Post date:** [July 19, 2021, 7:59pm UTC](https://forum.ansible.com/t/question-about-tags/35521/4 "2021-07-19T19:59:21Z")

</div>

I find [https://docs.ansible.com/ansible/2.8/reference\_appendices/special\_variables.html](https://docs.ansible.com/ansible/2.8/reference_appendices/special_variables.html) to be a gold mine for these kinds of things. Just match it with whatever version of Ansible you’re supporting.
