group_by and group vars

I use group_by to set up some groups in a play, but it looks like this doesn’t automatically load anything i have in group_vars for those new groups. I suspect group_vars are getting picked up only at the beginning of a play.

If you know the set of groups you’re creating with group_by, you can add an include_vars just after the grouping, which is how i’m working with things for now. How are other folks dealing with this? I was at first thinking it might be nice for group_by to implicitly load group_vars when it sets up groups, but then realized this could break variable precedence. Is it a valid feature request, maybe one that could be configurable, or should I look to work around things (via include_vars and/or by making sure anything that needs group_vars exists in my inventory as opposed to trying to set it up in group_by)?

thanks,
matt

“but it looks like this doesn’t automatically load anything i have in group_vars for those new groups”

When you say “new groups”, do you mean the group is not defined in inventory or is defined and does not have hosts?

In either case, I would like this would work, yes.

This seems like (if reproducible on devel) there should be a ticket opened.

I don’t think it would break precedence and could be done in a reasonably sane way, but I haven’t really dug in yet.

Hadn’t considered defining the group without hosts in inventory, but tried that and it doesn’t work that way either. Had been trying on 1.4.3, but just tried as well on devel and it shows the same behavior. I’ve submitted issue #5499.

thanks!
matt

Thanks, there was a report about something about dynamic hosts and host_vars (uncommon) recently so I think the fix is likely generic.

It’s keeping track of whether we’ve scanned group_vars or host_vars when adding a new group or host, and then adding them at that time, etc, or something related.

I’m marking both of these for the priority queue (note: the priority queue is ~30 tickets).

thanks! i’ll keep an eye on the issue and test it out when it’s resolved.

matt