-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Smart inventories don't contain groups #1999
Comments
Smart inventories don't have groups by design; this would be a large change to how they're constructed on the backend. |
@wenottingham so what are Smart Inventories needed for? |
Fixes URL used for root groups for pagination purposes
We are making some changes to the inventory script generation for job slicing, and I think this is a good opportunity to implement this request as well. The particular solution I have in mind I have discussed with @wwitzel3, and it comes down to a customized version of this query: awx/awx/main/models/inventory.py Line 248 in 5910b8c
Specifically designed for smart inventories, so we don't filter on inventory, but instead This assumes that a particular implementation is being requested, and I am somewhat unclear on that. Our patch would be designed to returned host-group memberships from source inventories, it would not be allowing users to group hosts inside of the smart inventory. The issue wording seems to reflect this design, but I don't know that everyone agrees on it. Also, consider that this patch will have a known limitation. In the case that 2 source inventories had a group of the same name, it would be treated as the same group for the purposes of the smart inventory (very important detail). However, annotating the group-group relationships would be borderline madness. You simply can't delineate which group is which, prevent cycles, etc. For these reasons, I think we should omit group-group (child-parent) relationships in this patch. @wenottingham does this design & stated limitation sound good to you? |
So it would be a flat hierarchy? How performant would this be? |
Performance is the main technical issue to be addressed, we already know pretty well what the code change would be. There are some existing large inventory examples that we will need to test with this (and be sure that groups are involved). |
Any progress on this change? This is huge issue for us, causing us to need to maintain a number of different manually created inventories to get around the lack of groups in smart inventories. We'd be willing to take a reasonable performance hit to get the feature working. |
It's not just performance, there are also questions of semantics. Having a host/playbook behave differently in a smart inventory because it's now getting a different copy of group vars (as mentioned above) would likely be surprising, and there's no good workaround. |
Hi, and if instead of the group name, we use the group id ? With groups:N insteand of groups.name:group_name Moreover, in our case, we only want a global inventory from our vmware infrastructure with tagged vm. And smart inventory were supposer to get all inventory needed for us. But without group_vars or group available, like some already said here, it's not really usable... :/ |
Doesn't help - an inventory is manifested as json, with groups containing hosts. You'll still end up with multiple 'groups' with the same name. |
Would be really nice to have group info concatenated into a smart inventory when merging regular inventories. |
I think this applies to hosts as well. bcoz if the host is present in multiple inventories, it still pulls that host to smart inventory, and still manages to avoid duplicates. Shouldn't we be able to apply similar logic for groups? |
I think, without having possibility to group hosts and use group_vars, smart inventory doesnt makes sense to most of our production scenarios. |
This feature is important one. Give a priority. This will help in rolling out the new version code in production environment in controlled phase. |
Same feature request here |
This is an important feature for us as well. |
Need to build ugly workarounds due to this. |
I was testing new dynamic inventories and was about to combine them in a smart inventory, however without groups they are useless to use for the moment :( |
Has there been any agreement or movement on this issue? |
I will echo others. Without at least group membership, smart inventories are not useful. Fundamental to the use of smart inventories is the idea that a single dynamic inventory can be broken down into smaller smart inventories for smaller subsets of work. I will admit my frustration comes from the fact it is IMPLIED that group membership and group_vars are included in smart inventories. https://docs.ansible.com/ansible-tower/latest/html/userguide/inventories.html#smart-inventories. If it was updated to EXPLICITLY tell users it DOES NOT include group membership or group_vars, it wouldn't fix the issue, but may lessen my frustration in thinking I did something wrong or there is a way to enable it. |
I just found out it is not possible to have more then one group in regular inventorys and using source. awx 17.0.1. |
Staggering that this is still an issue - this really seems like a core feature request and has been requested since 2018. |
I am honestly blown away that this would have been by design. I agree with the comments above — how is this "feature" helpful if it doesn't support a key piece of ansible inventories? |
I have wrote an API script to create regular inventories etc. But it is not the best way since i cant drop the inventory afterwords. |
Watch this space, something is coming :) |
We're working on this here: #13448 |
Thanks for the feedback; I’m looking forward to this feature.
In the meantime, with a modified EE, would there be anything preventing us from using constructed inventories “under the covers”?
|
^ that would be challenging, because we run each inventory source through |
Got it. okay, I’ll wait for the release.
|
As group vars support on smart inventories has not yet been implemented, I was wondering if we could achieve a similar result by having multiple dynamic inventories (the non-smart ones 😄 - the ones that actually work with group vars) and each one having a single inventory source applying a host filter/group filter. However I couldn't find anywhere an example of the syntax to be used on inventory source host filter.
Example, that does not work:
|
@fivetran-joliveira reading that tooltip makes me believe that this does exactly what it says. "matching host names" to your provided regex. For example: webserver.* Was digging around in the source code a bit. And I have absolutely no clue if that is actually where this gets applied, but it at least looks like that for me: awx/awx/main/utils/mem_inventory.py Line 143 in 1411d11
From what you've described you are planning to do, I think you could just use the 'groups' parameter, which all inventory plugins should share. hope that clears some things up. (.. and doesn't spread misinformation.... ?) |
Hey @BigPii thanks for your message! So let's say I have my hosted grouped into Here is the syntax that I tried, and didn't work for regular inventories (although this syntax works for smart inventories):
Could anyone point me out to any documentation describing the valid syntax to be used in regular inventory host filter? |
I was hoping to understand the valid patterns accepted on inventory host filters by looking at their unit tests, but it seems there is no code coverage for host filter related mehods: https://github.com/ansible/awx/blob/devel/awx/main/tests/unit/utils/test_mem_inventory.py |
Hi @fivetran-joliveira |
I'm going to close out this issue as we have no intention of doing this in smart inventories. In fact it can't be done and that's the reason we're developing the new constructed inventory feature (see comments above). |
I see it's closed, but it's unclear without any resolution tag: is done/wontfix/moved? Yes, I've read you're working on something you call "constructed inventories". But I can't find anything about it in the docs.
|
ISSUE TYPE
COMPONENT NAME
SUMMARY
Smart inventory contains now only hosts, but not their groups. This creates problems for roles that use group names.
ENVIRONMENT
STEPS TO REPRODUCE
EXPECTED RESULTS
I expected to see groups Gtop, Gsub1, Gsub2 and so on: all the groups from Inv the filtered hosts in the Smrt are members of.
ACTUAL RESULTS
Only hosts are in the Smrt.
The text was updated successfully, but these errors were encountered: