# How can I require caller is using tag directives, where tags are actively defined (not inherited)?

**URL:** <https://forum.ansible.com/t/how-can-i-require-caller-is-using-tag-directives-where-tags-are-actively-defined-not-inherited/13913>\
**Category:** Ansible Project\
**Created:** [November 15, 2013, 8:21am UTC](https://forum.ansible.com/t/how-can-i-require-caller-is-using-tag-directives-where-tags-are-actively-defined-not-inherited/13913 "2013-11-15T08:21:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![josh2](https://avatars.discourse-cdn.com/v4/letter/j/4491bb/32.png) [@josh2](https://forum.ansible.com/u/josh2)\
**Post date:** [November 15, 2013, 8:21am UTC](https://forum.ansible.com/t/how-can-i-require-caller-is-using-tag-directives-where-tags-are-actively-defined-not-inherited/13913/1 "2013-11-15T08:21:20Z")

</div>

Hi all,

I posted the following in IRC to no avail. Please let me know if this is possible and/or desired.

[02:39] hello.. odd question, i suppose, but: suppose i want to disable the default behavior of running all tags in a given yml playbook, instead requiring the playbook call to include the tags requesting execution in a deterministic order… can this be done? perhaps, via an ansible.cfg switch?  
[02:40] reason being, i want to have a book of plays.yml which include tag actions such as install and uninstall, yet i don’t want them both to run on accident…

The desired effect is to always crash the ansible-playbook command (or perhaps elsewhere) when tag(s) are not specified but are required per Ansible configuration, without breaking out into a new role. I suppose I can do something with conditionals in each of the playbooks, but this seems like it would be a ansible.cfg type of thing.

How about an option in ansible.cfg called:

require\_caller\_tags: True

hmm.. in pseudo code:

if require\_caller\_tags=True in ansible.cfg (or equiv)

if caller is “ansible-playbook” or “role” directive:

if target playbook contains “- tags” line definitions

# (which are functionally different than inherited tags)

if caller did not specify “tags” directive(s)

error

endif

endif

endif

endif

It’s probably better to just split into separate roles for drastically different tags. Please let me know your thoughts. This could well be majorly off the wall, given it’s 3:18 AM. 🙂

Thanks,  
Joshua

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [November 15, 2013, 2:34pm UTC](https://forum.ansible.com/t/how-can-i-require-caller-is-using-tag-directives-where-tags-are-actively-defined-not-inherited/13913/2 "2013-11-15T14:34:39Z")

</div>

I’m ok with making the tags used accessible as a variable like ansible\_tags\_used, something you might want to attempt a PR for?

You could use “when” and the “fail” module but I do not think we want to bloat the language just for this.

– Michael
