Documentation
¶
Overview ¶
Package os is for running commands on a remote host
Index ¶
- Constants
- func RegisterOSModule(match func(*rigos.Release) bool, builder func() any)
- func ResolveOSModule(release *rigos.Release) (func() any, bool)
- type Configurer
- type Host
- type HostValidator
- type Linux
- func (l *Linux) ApplySysctl(h Host, _ string) error
- func (l *Linux) CTLLockFilePath(h Host) string
- func (l *Linux) Dir(p string) string
- func (l *Linux) GetDistroService(key string) (string, error)
- func (l *Linux) Hostname(h Host) string
- func (l *Linux) Kind() string
- func (l *Linux) LongHostname(h Host) string
- func (l *Linux) OSKind() string
- func (l *Linux) PreferredFirewall() string
- func (l *Linux) PrivateAddress(h Host, iface, publicip string) (string, error)
- func (l *Linux) PrivateInterface(h Host) (string, error)
- func (l *Linux) SetPath(key, value string)
- func (l *Linux) UpdateEnvironment(h Host, env map[string]string) error
Constants ¶
const ( // BinaryPath key for the binary path for the distro engine BinaryPath = "BinaryPath" // ConfigPath key for the config directory for the distro engine ConfigPath = "ConfigPath" // JoinTokenPath key for the join token for the cluster JoinTokenPath = "JoinTokenPath" // DataDirDefaultPath key for the data directory for the distro engine DataDirDefaultPath = "DataDirDefaultPath" )
const ( // FirewallFirewalld is the firewall front end shipped by Enterprise Linux and SUSE. FirewallFirewalld = "firewalld" // FirewallUFW is the firewall front end shipped by Debian and Ubuntu. FirewallUFW = "ufw" )
Variables ¶
This section is empty.
Functions ¶
func RegisterOSModule ¶
RegisterOSModule registers an OS support module. Modules are matched in most-recently-registered-first order, mirroring the behavior of the (now removed in rig v2) github.com/k0sproject/rig/os/registry package that this replaces.
Types ¶
type Configurer ¶
type Configurer interface {
// ApplySysctl loads the sysctl settings in the file at the given path into the running
// kernel. The path is passed rather than assumed because not every OS can apply the whole
// of /etc/sysctl.d in one command.
ApplySysctl(Host, string) error
// PreferredFirewall names the firewall front end this distribution ships, e.g. firewalld on
// Enterprise Linux and ufw on Debian. It returns an empty string when the distribution has no
// front end of its own.
PreferredFirewall() string
// Kind returns the general OS family identifier (e.g. "linux")
Kind() string
// OSKind returns the identifier for Linux hosts
OSKind() string
// Dir returns the directory part of a path
Dir(string) string
// GetDistroService returns the name of the service for the current distro.
// common key values are, "controller" and "agent"
GetDistroService(string) (string, error)
// SetPath adds a key value to the paths string map.
SetPath(string, string)
// UpdateEnvironment updates the hosts's environment variables
UpdateEnvironment(Host, map[string]string) error
// Hostname resolves the short hostname
Hostname(Host) string
// LongHostname resolves the FQDN (long) hostname
LongHostname(Host) string
// InstallPackage installs packages
InstallPackage(Host, ...string) error
// UninstallPackage uninstalls packages
UninstallPackage(Host, ...string) error
// CTLLockFilePath returns a path to a lock file
CTLLockFilePath(Host) string
// PrivateInterface tries to find a private network interface
PrivateInterface(Host) (string, error)
// PrivateAddress resolves internal ip from private interface
PrivateAddress(Host, string, string) (string, error)
}
Configurer defines the per-host operations required for managing a host. Most filesystem, service, and OS-detection operations are handled directly via the rig v2 Host interface (FS(), Sudo(), OS()) rather than through this interface -- Configurer only carries what is genuinely distro-specific.
type Host ¶
type Host interface {
cmd.SimpleRunner
// Sudo returns a memoized clone of the client whose runner wraps every
// command with the detected privilege escalation mechanism.
Sudo() *rig.Client
// FS returns a filesystem interface for accessing files on the host.
FS() remotefs.FS
}
Host is the interface that Configurer methods use to interact with a remote host. It is satisfied by *rig.Client, and therefore by any type that embeds rig.ClientWithConfig (such as cluster.ZarfHost), since those methods are promoted.
type HostValidator ¶
HostValidator allows a Configurer to implement host-specific validation logic.
type Linux ¶
type Linux struct {
// contains filtered or unexported fields
}
Linux is a base module for various linux OS support packages
func (*Linux) ApplySysctl ¶
ApplySysctl loads every sysctl file the OS reads at boot, which includes the file at path. Applying them all rather than only that file keeps a setting cargoship overrides from being re-applied at its old value by a file later in the load order, and matches what the host does on its next boot.
func (*Linux) CTLLockFilePath ¶
CTLLockFilePath returns a path to a lock file
func (*Linux) GetDistroService ¶
GetDistroService returns the name of the service for the current distro. common key values are, "controller" and "agent"
func (*Linux) LongHostname ¶
LongHostname resolves the FQDN (long) hostname
func (*Linux) PreferredFirewall ¶
PreferredFirewall reports that the distribution ships no firewall front end of its own. An OS module for a distribution that ships one overrides this. The method is declared on each leaf OS module rather than on a shared base such as EnterpriseLinux, because those modules embed both their base and this one at the same depth, which would leave the promoted method ambiguous.
func (*Linux) PrivateAddress ¶
PrivateAddress resolves internal ip from private interface
func (*Linux) PrivateInterface ¶
PrivateInterface tries to find a private network interface
Directories
¶
| Path | Synopsis |
|---|---|
|
Package linux is implementing the interface github.com/colonel-byte/cargoship/types/os.Configurer for Linux based hosts
|
Package linux is implementing the interface github.com/colonel-byte/cargoship/types/os.Configurer for Linux based hosts |
|
enterpriselinux
Package enterpriselinux is implementing the interface github.com/colonel-byte/cargoship/types/os.Configurer for Enterprise Linux hosts
|
Package enterpriselinux is implementing the interface github.com/colonel-byte/cargoship/types/os.Configurer for Enterprise Linux hosts |