Documentation
¶
Overview ¶
Package hostsetup does the host-side chores VirtoMir used to leave to the admin: installing the packages a feature needs (restic, FRR, iPXE + dnsmasq, cephadm + podman), turning on the IOMMU on the kernel command line for PCI passthrough, loading a software watchdog for HA, and the root SSH key ZFS replication sends with. Every command goes through a Runner and every file through Root, so all of it is tested without touching the host.
Index ¶
- Variables
- type Exec
- type Feature
- type IOMMUResult
- type Runner
- type Setup
- func (s *Setup) Authorize(key string) error
- func (s *Setup) CopyKey(ctx context.Context, host, password, key string) error
- func (s *Setup) EnableIOMMU(ctx context.Context) (IOMMUResult, error)
- func (s *Setup) EnableWatchdog(ctx context.Context) error
- func (s *Setup) HasWatchdog() bool
- func (s *Setup) Install(ctx context.Context, feature string, report func(string)) error
- func (s *Setup) Installed(feature string) bool
- func (s *Setup) PublicKey(ctx context.Context, comment string) (string, error)
Constants ¶
This section is empty.
Variables ¶
var ErrInvalid = errors.New("invalid")
ErrInvalid marks a request VirtoMir refuses (unknown feature, malformed key).
var ErrPassword = errors.New("password not accepted")
ErrPassword marks a password the target did not accept.
var ErrUnsupported = errors.New("unsupported")
ErrUnsupported marks a host VirtoMir cannot change by itself (no apt or dnf, an unknown boot loader); the message says what to do instead.
var Features = map[string]Feature{ "offsite": {Title: "Off-site copies (restic)", Apt: []string{"restic"}, Dnf: []string{"restic"}, Commands: []string{"restic"}}, "physnet": {Title: "BGP / EVPN routing (FRR)", Apt: []string{"frr"}, Dnf: []string{"frr"}, Commands: []string{"vtysh"}}, "baremetal": {Title: "Network installs (dnsmasq + iPXE)", Apt: []string{"dnsmasq", "ipxe"}, Dnf: []string{"dnsmasq", "ipxe-bootimgs-x86"}, Commands: []string{"dnsmasq"}, AnyFile: []string{"/usr/lib/ipxe/undionly.kpxe", "/usr/share/ipxe/undionly.kpxe"}}, "ceph": {Title: "Ceph (cephadm + podman)", Apt: []string{"cephadm", "podman"}, Dnf: []string{"cephadm", "podman"}, Commands: []string{"cephadm", "podman"}}, }
Features VirtoMir installs by itself. The names are the API's.
Functions ¶
This section is empty.
Types ¶
type Feature ¶
type Feature struct {
// Title names it for the user.
Title string
Apt []string
Dnf []string
// Commands are what must be on PATH afterwards (and tell whether it is installed).
Commands []string
// AnyFile: one of these must exist as well (files a package ships outside PATH; the
// places differ between Debian and Fedora).
AnyFile []string
}
Feature is something VirtoMir can set up by installing packages.
type IOMMUResult ¶
type IOMMUResult struct {
// Params were added to the kernel command line (empty: they were there already).
Params []string `json:"params"`
// Method is how: grubby, grub (with its config file) or kernel-cmdline; active when the
// IOMMU was already on and nothing was changed.
Method string `json:"method"`
// RebootNeeded is true until the host has started with the new command line.
RebootNeeded bool `json:"rebootNeeded"`
// Backup is the copy of the file VirtoMir changed, to undo it by hand.
Backup string `json:"backup,omitempty"`
}
IOMMUResult says what EnableIOMMU did.
type Setup ¶
type Setup struct {
Run Runner
// Look finds a command on PATH (exec.LookPath on a real host).
Look func(string) (string, error)
// Root is where the host's files are ("" = /).
Root string
}
Setup does the chores on one host.
func (*Setup) Authorize ¶
Authorize lets the holder of key sign in as root (appends it to authorized_keys once).
func (*Setup) CopyKey ¶
CopyKey signs in to host as root with password, once, and adds key to root's authorized_keys there (what ssh-copy-id does). The password is used for this one sign-in and kept nowhere. A host whose SSH identity is already in root's known_hosts must still present it: a changed one is refused.
func (*Setup) EnableIOMMU ¶
func (s *Setup) EnableIOMMU(ctx context.Context) (IOMMUResult, error)
EnableIOMMU adds the IOMMU parameters to the kernel command line of every installed kernel, keeping a backup of the file it edits. The firmware switch (VT-d / AMD-Vi) cannot be set from Linux; the result says a reboot is needed.
func (*Setup) EnableWatchdog ¶
EnableWatchdog loads the kernel's software watchdog (softdog) when the host has no hardware one, and keeps it loaded across reboots.
func (*Setup) HasWatchdog ¶
HasWatchdog tells whether /dev/watchdog exists.
func (*Setup) Install ¶
Install installs the feature's packages with the host's package manager, then does what the feature needs beyond the package (FRR: the BGP daemon on and running). report tells the user which step runs.