On Tue, 1 Dec 2020 11:41:20 -0500 Guy Matz <[email protected]> wrote:
> Hi! Does anyone know if there's a variable set for the target group of a > play? > > For example, for this: > - hosts: *prime* > roles: > - nginx > - postfix > > Does any variable get set to "prime" in a deterministic way? No. There is no such "special variable" https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html There is only variable *group_names* "List of groups the current host is part of" and variable "groups" "A dictionary/map with all the groups in inventory and each group has the list of hosts that belong to it" Ansible doesn't store the structure of inventory groups. Quoting from "How variables are merged" https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#how-variables-are-merged "... This keeps Ansible focused on the Host and Task, so groups don’t really survive outside of inventory and host matching. ..." Do you have any use-case which needs such variable? -- Vladimir Botka -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/20201201191555.795906ff%40gmail.com.
pgpspbryEAf69.pgp
Description: OpenPGP digital signature
