Exclude hosts from Constructed Inventory or overwrite inventory project variables inside AWX

Is there a way to exclude hosts from a Constructed Inventory that exists in the upstream based on some criteria?

I’m reading the documentation on the docs.ansible.com site and it doesn’t look like a “filter” option is included, but I’m not sure if there’s an intended way to do this.

Context - One of my upstream sources is the Nutanix inventory plugin. Because it’s not supported in AWX it exists in its own project. I then source the project into the source list for an inventory, but any filtering seems to have to be done at the project level - I tried adding filters at the source level in AWX, but they didn’t seem to take.

I can add the filters at the project level, but then I’d have to make/maintain multiple distinct projects for each host list which seems suboptimal.

I’d like to have one project and one inventory that contains the entirety of our Nutanix hosts and then split them out in our downstream constructed inventories - say one for Windows and one for Linux/Unix.

Anyone know if this is possible?

Inventories have not supported way to subtract host from inventory, because this is definitional, hosts exist or they don’t. You CAN subtract hosts from play selection as that is choosing what to target.

Hi Brian - thanks for the reply. There are a number of inventory plugins that do support host exclusion or filtering when ingesting from some upstream source (VMWare and Nutanix are examples), so I guess I was wondering if there was a way to do it with the constructed inventory plugin in order to build specific, targeted constructed inventories for downstream projects to leverage without them having to tailor all of their playbooks to deal with a mega-inventory.

I’m assuming by your reply that functionality hasn’t been considered or isn’t possible with the constructed inventory plugin (or has been considered and rejected). That’s unfortunate. It looks like I’ll have to go the “maintain multiple inventory projects with different filters” route for what I’m trying to accomplish.

Thanks again for your reply!

Those plugins generate inventory from an external source, they filter that source, there is no facility for plugins to remove hosts from already existing inventory, constructed operates on existing inventory.

We use a similar scheme: a handful of larger inventories synced with dynamic plugins (Azure, AWS, etc…) and multiple constructed inventories for filters. The job templates mostly point to the constructed inventories. We heavily use workflows so we build in inventory syncs to get the most up-to-date data at runtime prior to the job templates running.

I’d love to hear more about this setup, as it’s what I’m trying to do. How are you filtering the hosts using constructed inventory? I basically want to build a constructed inventory that’s a smaller subset of the larger inventory and i’m unclear how to do that.