-
-
Notifications
You must be signed in to change notification settings - Fork 355
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
Replicate most of the ansible style host matching logic #753
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks ok when used in testinfra_hosts
on my setup. Should apply the change to easily reduce the minimum working python3 version (tested on 3.8)
else: | ||
positive.update(expand_pattern(requirement, inventory)) | ||
|
||
result = positive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment about something that I don't see as worth changing right now as there hasn't been any response on this yet, and a significant improvement is much better than nothing.
I suspect a perfect copy of the logic from ansible would use something like this here:
result = positive | |
if positive: | |
result = positive | |
else: | |
result = expand_pattern('all') |
Then you imitate behaviour like !right
which is equivalent to all:!right
, but this would also be best with additions to manual testing and adding of tests to this codebase for the confirmed functionality.
Given that adding all:
to the start of a host pattern/query is equivalent, it's a fine enough workaround. If this change gets merged/released, I'll follow up with this change.
I'm happy with the improvements on here, so have un-drafted the PR |
What do you think about renaming |
This expands on the ansible pattern matching so you can use multiple parts, intersection, negation, and regex patterns, on top of the already implemented globbing.
I'd like to backport this change into an 8.2 release if you'll take it.