Can playbook tag input be placed in group_var?

41 views
Skip to first unread message

Gerry Maddock

unread,
Jul 23, 2020, 1:37:38 PM7/23/20
to Ansible Project
If I'm running a playbook that has tags, can I place the tag information be placed in the group_vars?  That way if I run a playbook against against an ansible group with children, the children could have different tags for use in the playbook?


Vladimir Botka

unread,
Jul 23, 2020, 3:35:14 PM7/23/20
to Gerry Maddock, ansible...@googlegroups.com
On Thu, 23 Jul 2020 10:37:38 -0700 (PDT)
Gerry Maddock <madd...@gmail.com> wrote:

> can I place the tag information be placed in the group_vars?

No. It's not possible. Quoting from "Tags"
https://docs.ansible.com/ansible/latest/user_guide/playbooks_tags.html#tags

"You can see which tasks will be executed with --tags or --skip-tags by
combining it with --list-tasks:

ansible-playbook example.yml --tags "configuration,packages" --list-tasks

The tags are evaluated when a playbook starts. Otherwise the control flow
could be changed on the fly by such variables. Tags can be set

* on the command line "--tags, --skip-tags"
* in configuration settings in tags section "run, skip"
* in environment "ANSIBLE_RUN_TAGS, ANSIBLE_SKIP_TAGS"

See
https://docs.ansible.com/ansible/latest/reference_appendices/config.html#tags-run
https://docs.ansible.com/ansible/latest/reference_appendices/config.html#tags-skip

Next option to consolidate tags is the concept of Ansible runner's project
https://ansible-runner.readthedocs.io/en/latest/intro.html#env-cmdline


--
Vladimir Botka

Jean-Yves LENHOF

unread,
Jul 23, 2020, 3:36:26 PM7/23/20
to ansible...@googlegroups.com

Hi,

I think you should be asking what you want to do more clearly (Perhaps with a little playbook to be completed) instead of trying some obscured things

Regards,

JYL


Le 23/07/2020 à 19:37, Gerry Maddock a écrit :
If I'm running a playbook that has tags, can I place the tag information be placed in the group_vars?  That way if I run a playbook against against an ansible group with children, the children could have different tags for use in the playbook?


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/8dfab321-2bf5-41c2-9a6b-8fa7e315dd48o%40googlegroups.com.

Vladimir Botka

unread,
Jul 23, 2020, 3:57:29 PM7/23/20
to Jean-Yves LENHOF, ansible...@googlegroups.com
On Thu, 23 Jul 2020 21:36:08 +0200
Jean-Yves LENHOF <jean...@lenhof.eu.org> wrote:

> I think you should be asking what you want to do more clearly (Perhaps
> with a little playbook to be completed) instead of trying some obscured
> things

It's not possible on the playbooks' level actually. Any attempt will look
obscure.

Still the use-case is valid: "Set the tags for an inventory group". This can
be done on top of a playbook. In a script, AWX, Ansible runner, etc.

--
Vladimir Botka

Gerry Maddock

unread,
Jul 23, 2020, 4:58:13 PM7/23/20
to ansible...@googlegroups.com, Jean-Yves LENHOF
Thanks Vladimir

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages