Files
zeekay 241625e7d9 rename: ziti → zt across all paths
- Repo names: ziti-* → zt-*
- Go modules: github.com/hanzozt/ziti → github.com/hanzozt/zt
- Docker images: hanzozt/ziti-* → hanzozt/zt-*
- C/Java/JS symbols: ziti_* → zt_*
- File and directory names updated
2026-02-18 18:34:19 -08:00

43 lines
1.5 KiB
Go

package ztlib_runlevel_0_infrastructure
import (
"fmt"
"github.com/hanzozt/fablab/kernel/libssh"
"github.com/hanzozt/fablab/kernel/model"
"github.com/sirupsen/logrus"
)
type installConsul struct {
hostSpec string
}
func InstallConsul(hostSpec string) model.Stage {
return &installConsul{
hostSpec: hostSpec,
}
}
func (imb *installConsul) Execute(run model.Run) error {
return run.GetModel().ForEachHost(imb.hostSpec, 25, func(host *model.Host) error {
ssh := host.NewSshConfigFactory()
if output, err := libssh.RemoteExec(ssh, "curl --fail --silent --show-error --location https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo dd of=/usr/share/keyrings/hashicorp-archive-keyring.gpg"); err != nil {
return fmt.Errorf("error getting hashicorp gpg key on host [%s] %s (%s)", host.PublicIp, output, err)
}
if output, err := libssh.RemoteExec(ssh, "echo \"deb [arch=amd64 signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main\" | sudo tee -a /etc/apt/sources.list.d/hashicorp.list"); err != nil {
return fmt.Errorf("error adding hashicorp repo to apt on host [%s] %s (%s)", host.PublicIp, output, err)
}
cmd := "sudo apt-get update && sudo apt-get install consul -y"
if output, err := libssh.RemoteExec(ssh, cmd); err != nil {
return fmt.Errorf("error installing Consul on host [%s] %s (%s)", host.PublicIp, output, err)
}
logrus.Infof("%s => %s", host.PublicIp, "installing Consul")
return nil
})
}