diff --git a/config/cluster/host.go b/config/cluster/host.go index a77e156a1..ba0c7d673 100644 --- a/config/cluster/host.go +++ b/config/cluster/host.go @@ -379,6 +379,22 @@ func (h *Host) NeedIPTables() bool { return !h.Configurer.CommandExist(h, "iptables") } +// NeedInetUtils returns true when the inetutils package is needed on the host to run `hostname`. +// Placing this check here is kind of meh because this package probably only exists on arch. +func (h *Host) NeedInetUtils() bool { + // Windows does not need inetutils + if h.Configurer.Kind() == "windows" { + return false + } + + // Only arch has/needs this package. + if h.OSVersion.IDLike != "arch" { + return false + } + + return !h.Configurer.CommandExist(h, "hostname") +} + // WaitKubeAPIReady blocks until the local kube api responds to /version func (h *Host) WaitKubeAPIReady() error { // If the anon-auth is disabled on kube api the version endpoint will give 401 diff --git a/configurer/linux/archlinux.go b/configurer/linux/archlinux.go new file mode 100644 index 000000000..8522128fd --- /dev/null +++ b/configurer/linux/archlinux.go @@ -0,0 +1,25 @@ +package linux + +import ( + "github.com/k0sproject/k0sctl/configurer" + "github.com/k0sproject/rig" + "github.com/k0sproject/rig/os/linux" + "github.com/k0sproject/rig/os/registry" +) + +// ArchlinuxARM provides OS support for ArchlinuxARM systems +type ArchlinuxARM struct { + linux.ArchlinuxARM + configurer.Linux +} + +func init() { + registry.RegisterOSModule( + func(os rig.OSVersion) bool { + return os.IDLike == "arch" + }, + func() interface{} { + return &ArchlinuxARM{} + }, + ) +} diff --git a/phase/prepare_hosts.go b/phase/prepare_hosts.go index e88dd2e6c..e6cfb5db6 100644 --- a/phase/prepare_hosts.go +++ b/phase/prepare_hosts.go @@ -51,6 +51,10 @@ func (p *PrepareHosts) prepareHost(h *cluster.Host) error { pkgs = append(pkgs, "iptables") } + if h.NeedInetUtils() { + pkgs = append(pkgs, "inetutils") + } + if len(pkgs) > 0 { log.Infof("%s: installing packages (%s)", h, strings.Join(pkgs, ", ")) if err := h.Configurer.InstallPackage(h, pkgs...); err != nil {