Ask HN: Is there a hostname manager utility?
Are there any tools out there that are similar to what I'm describing?
Are there any tools out there that are similar to what I'm describing?
For metadata search, use regular text search in editor.. A prefix to avoid false positives comes handy, for example "s:aws" instead of "aws". You can also have nested structs to group your hosts widely.
For querying, tiny scripts in your favorite language.. the idea is to have many one-off scripts which do exactly what you need, instead of having one super-script that does it all. Here is an example of one of my scripts, which looks up IP based on human-readable name. (I could probably do it in one line of "yq" as well)
#!/usr/bin/python3 -B
# given a "name" in arguments, return corresponding IP
import yaml, os, sys
s = yaml.safe_load(open(os.path.expanduser("~/data/hostnames.yaml")))
match = [info["ip"] for group in s.values() for name, info in group.items() if name in sys.argv[1:]]
if len(match) != 1: sys.exit("name not found")
print(match[0])
Yours would be different based on your requirements.The tricky part is sometimes you need a printable report -- for this I export to csv and then open in editor. Not perfect, but works.
$ cat ~/.ssh/config
Host myserver
HostName 10.10.10.10
User ken
$ ssh myserver