Improve case matching - strip domain part for -f/file read #164
Labels
No labels
bugfix
cleanup
discussion
documentation
doing
done
feature
improvement
packaging
Stale
testing
TODO
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ungleich-public/cdist#164
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Created by: xorpierre
quote nico "Steven and I actually discussed having a second variable that only contains the hostname (i.e. with domain part stripped) so that matching is easier"
Issue I had:
host file with
a.bla.com
b.bla.com
case matching in manifest was only for a|b)
so matches failed when using cdist -f hostlist
Created by: darko-poljak
@xorpierre @telmich Merged PR https://github.com/ungleich/cdist/pull/472.
Closing this issue.
Created by: darko-poljak
Sorry for close/reopen, wrong types/clicks.
@xorpierre Even better, you can use patterns in your case.
For host file with:
a.bla.com
b.bla.com
use case matching in manifest:
a*|b*)Created by: darko-poljak
@telmich, @xorpierre I created pull request for this issue:
https://github.com/ungleich/cdist/pull/472
@xorpierre I don't know if this would solve your issue with stripped
domain part. Derived hostname lookup can contain fqdn or something like:
$ host chat.ungleich.chchat.ungleich.ch has address 78.47.116.245$ host 78.47.116.245245.116.47.78.in-addr.arpa domain name pointer static.245.116.47.78.clients.your-server.de.If there is need in the script to use only first part of domain name (fqdn) until
the first dot then this can be done using:
target_name="${__target_host%%.*}"and then you can construct your case statement using that variable.
Created by: darko-poljak
@telmich yes, on holidays with only mobile network, no wifi. It was raining :( so I took a look with my smartphone...
Created by: telmich
@darko-poljak aren't you on holidays without Internet? :-)
That suggestion sounds good to me, so we have
__target_host - as is, command line, literally
__target_hostname - socket.gethostname, derived from __target_host
__target_fqdn - socket.getfqdn, derived from __target_host
in the end. We need to clearly document that __target_host is the primary variable and the content that the user passed in and that the others are just derived. I suggest to also include references to the python methods you mentioned.
Created by: darko-poljak
Actually hostname (as returned from socket.gethostname), fqdn (returned from socket.getfqdn) and target host (exact value specified at cmd line or hostfile). @asteven , @telmich what do you think?
Created by: darko-poljak
Why not have hostname, domain name, fqdn and target host (value specified at cmd line/hostfile as is) and user can then use whichever best fits his/her needs?
Created by: xorpierre
Alternative: make it work that I dont have to use the FQDN in the file. Even with search domain.tld in resolv.conf that doesnt work with cdist. Works fine with ssh&co
Created by: telmich
@asteven do you remember if we had good arguments to not provide this variable (besides finding an appropriate name)?
I think we discussed that it can easily be matched with ${__target_host%%.*} (which is true), however I think that "Parameter Expansion" (as bash calls it) is actually rather hard to read, even though easily applicable.
I vote for adding __new_good_name_that_does_not_confuse_the_user, which contains only the hostname, as it might also be a good best practise for people to match on the hostname by default and use __target_host only when they need to distinguish two systems with the same hostname.
Comments? Ideas?
Pinging @dheule, too - you might have encountered this before, too