Replicate most of the ansible style host matching logic#753
Replicate most of the ansible style host matching logic#753Code0x58 wants to merge 5 commits intopytest-dev:mainfrom
Conversation
Code0x58
left a comment
There was a problem hiding this comment.
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.
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.