Skip to content
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 Inventory - Searching on host variables using a regex returns wrong results #14983

Closed
6 of 11 tasks
mrik974 opened this issue Mar 12, 2024 · 2 comments
Closed
6 of 11 tasks

Comments

@mrik974
Copy link

mrik974 commented Mar 12, 2024

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that AWX is open source software provided for free and that I might not receive a timely response.
  • I am NOT reporting a (potential) security vulnerability. (These should be emailed to security@ansible.com instead.)

Bug Summary

All my hosts in my inventory have this variable hds (french acronym for health data hosting service). Its value is either true or false.
I have to create two smart inventories, one listing all hds: true hosts and one listing the hds: false ones.

This is the weird part. When I use host.variables__regex=^.*hds.*true.*$ I, as I expect, get all the hds hosts. But...
When I use host.variables__regex=^.*hds.*false.*$ I don't get the non hds hosts. Instead I get the full list of hosts available in my inventory.
My workaround at the moment is to use host.not__variables__regex=^.*hds.*true.*$. But I thought it would be a good bug to report.

AWX version

22.1.0

Select the relevant components

  • UI
  • UI (tech preview)
  • API
  • Docs
  • Collection
  • CLI
  • Other

Installation method

minikube

Modifications

no

Ansible version

No response

Operating system

No response

Web browser

No response

Steps to reproduce

Have a list of hosts, all with a variable hds set to true or false (boolean, not strings)
Create a smart inventory and try to filter the hds: false with this filter : host.variables__regex=^.*hds.*false.*$

Expected results

The hosts should only have the hosts set withhds: false

Actual results

All hosts are listed, like if no filter was set, even the ones with hds: true.

Additional information

The other way around (host.variables__regex=^.*hds.*true.*$) works as expected

@jessicamack
Copy link
Member

Hello @mrik974 you can find more assistance for this issue on the forum https://forum.ansible.com/tag/awx.

Smart inventory has a different language than the regex filter you're using.

Your regex filter will match a lot more than you think. Please include the full host vars that you're using in your post to the forum.

@mrik974
Copy link
Author

mrik974 commented Mar 14, 2024

Thanks for your answer. I clearly assumed the regex engine here and was in the wrong. I'm closing this.

@mrik974 mrik974 closed this as completed Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants