feat: NetBox insights, host tools and configurable TUI
Test / test (pull_request) Successful in 4m15s

- info/open/whois: NetBox details (site, nested locations, rack units,
  role, platform, tenant, IPs per interface), web page, reverse IP lookup
- cache status, site, role, platform, tenant, location chain and rack;
  ask before connecting to hosts in ssh.warn_status (--force skips)
- ssh rules and command restrictions match site/role/platform/tenant/status
- tui.columns selects what the TUI shows; optional TCP reachability column;
  detail view (Ctrl+L), NetBox page (Ctrl+G), status/location filters
- resolver.fallback tries other strategies' addresses when unreachable
- copy-id, known-hosts reset and address-change notices
- export ansible (YAML/INI) and export ssh-config
- token: keyring stores NetBox tokens in the system keyring
- fix stale menu number in testenv configure test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-18 12:33:59 +01:00
1 parent e5bde9c61f
commit 1660bb3098
39 files changed
+4868 -96

No files matched your search

+68 -1
View File
@@ -94,6 +94,57 @@ type SSHMatch struct {
Instance string `mapstructure:"instance"`
Kind string `mapstructure:"kind"`
Name string `mapstructure:"name"` // shell-style glob, e.g. "*.dmz.example.com"
// Site, Role, Platform and Tenant match the NetBox name or slug.
Site string `mapstructure:"site"`
Role string `mapstructure:"role"`
Platform string `mapstructure:"platform"`
Tenant string `mapstructure:"tenant"`
// Status matches the NetBox status value, e.g. active or offline.
Status string `mapstructure:"status"`
}
// Ref is a NetBox object referenced by a host, such as its site or platform.
type Ref struct {
Name string `json:"name,omitempty"`
Slug string `json:"slug,omitempty"`
}
// Matches compares want with the name or slug, ignoring case.
func (r Ref) Matches(want string) bool {
return want != "" && (strings.EqualFold(r.Name, want) || strings.EqualFold(r.Slug, want) || strings.EqualFold(tagSlug(r.Name), want))
}
// Key returns the slug, or the name when NetBox sent no slug.
func (r Ref) Key() string {
if r.Slug != "" {
return r.Slug
}
return r.Name
}
// LocationPath renders a host's place as "site › location › … › rack › U20",
// leaving out levels that are not set.
func LocationPath(site Ref, locations []Ref, rack, position string) string {
var parts []string
if site.Name != "" {
parts = append(parts, site.Name)
} else if site.Slug != "" {
parts = append(parts, site.Slug)
}
for _, location := range locations {
if location.Name != "" {
parts = append(parts, location.Name)
} else if location.Slug != "" {
parts = append(parts, location.Slug)
}
}
if rack != "" {
parts = append(parts, rack)
}
if position != "" {
parts = append(parts, "U"+position)
}
return strings.Join(parts, " › ")
}
// SSHHost identifies the resolved host that SSH options are computed for.
@@ -102,6 +153,11 @@ type SSHHost struct {
Name string // NetBox name without the instance prefix
Kind string
Tags []string
Status string
Site Ref
Role Ref
Platform Ref
Tenant Ref
}
var sshOptionKey = regexp.MustCompile(`^[A-Za-z][A-Za-z0-9]*$`)
@@ -138,7 +194,7 @@ func (r SSHRule) Validate(scope string) error {
// Validate requires at least one selector and a well-formed name pattern.
func (m SSHMatch) Validate(scope string) error {
if m == (SSHMatch{}) {
return fmt.Errorf("%s: match must set at least one of tag, instance, kind, name", scope)
return fmt.Errorf("%s: match must set at least one of tag, instance, kind, name, site, role, platform, tenant, status", scope)
}
if _, err := path.Match(m.Name, ""); err != nil {
return fmt.Errorf("%s: invalid name pattern %q", scope, m.Name)
@@ -264,6 +320,17 @@ func (m SSHMatch) matches(host SSHHost) bool {
return false
}
}
for _, ref := range []struct {
want string
have Ref
}{{m.Site, host.Site}, {m.Role, host.Role}, {m.Platform, host.Platform}, {m.Tenant, host.Tenant}} {
if ref.want != "" && !ref.have.Matches(ref.want) {
return false
}
}
if m.Status != "" && !strings.EqualFold(m.Status, host.Status) {
return false
}
if m.Tag != "" {
found := false
for _, tag := range host.Tags {