opt: expand short hostnames in -x when PDSH_DEFAULT_DOMAIN is set#181
opt: expand short hostnames in -x when PDSH_DEFAULT_DOMAIN is set#181BiloxiGeek wants to merge 1 commit intochaos:masterfrom
Conversation
When a netgroup (-g) returns FQDNs but exclusions (-x) are specified as short hostnames, the delete silently fails because the names don't match. If PDSH_DEFAULT_DOMAIN is set, append the domain to any short hostname (no '.') in the exclusion list before attempting hostlist_delete, so short hostnames correctly match FQDNs in the working collection.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #181 +/- ##
==========================================
- Coverage 72.57% 72.49% -0.09%
==========================================
Files 25 25
Lines 4088 4097 +9
==========================================
+ Hits 2967 2970 +3
- Misses 1121 1127 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
This seems pretty reasonable. Note that If Also, tests for this work should be added under tests/ if you don't mind. Thanks! |
|
Actually I hadn't known -x could do regex, that might be a better solution since it's already cooked in. I must have missed that when I was first learning how to use pdsh and never thought to revisit the man page about it. I'd say you can reject this as a fix for a non-existent problem. The idea I came up with still has merits though in that the regex is great for hostname matching but the default domain environment gets rid of the regex string for the more overall domain name matching. If you want to roll this into the code independently of this PR please do so but I can deal with the regex way for now. Adding the default domain to hosts in -w would make sense if DNS doesn't resolve the short name. All the systems I deal with have a good search domain set in resolve.conf so using short hostnames in -w hasn't been a problem. Maybe change the -x so it will do a direct match to whatever hostnames are already in -w or from the group in -g and if there's no match from those then try adding the default domain. Basically let -x use dns and the list already populated by -w or -g. |
When using -g to target a netgroup that returns FQDNs, exclusions specified with short hostnames via -x silently fail because the names don't match entries in the working collection.
This patch checks for a
PDSH_DEFAULT_DOMAINenvironment variable. If set, any short hostname (containing no '.') passed to-xis also tried as a FQDN (hostname.domain) against the working collection, so exclusions work correctly in mixed short/FQDN environments.Also adds documentation for
PDSH_DEFAULT_DOMAINto the man page.