fix: use correct meganode.wallarm.com installer URL
- Updated from deprecated repo.wallarm.com to meganode.wallarm.com/6.12/ - Installer URL: wallarm-6.12.7.x86_64-glibc.sh - Override with WALLARM_INSTALLER_URL env var - Pipes token+region via stdin to skip interactive prompts - Preflight checks meganode.wallarm.com reachability
This commit is contained in:
parent
d0ad1c5243
commit
b1c596ccf2
2 changed files with 22 additions and 22 deletions
|
|
@ -12,17 +12,23 @@ import (
|
||||||
"git.sechpoint.app/customer-engineering/wallarm/internal/state"
|
"git.sechpoint.app/customer-engineering/wallarm/internal/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Constants matching the bash script
|
// Constants
|
||||||
const (
|
const (
|
||||||
BaseDir = "/opt/wallarm"
|
BaseDir = "/opt/wallarm"
|
||||||
NodesDir = BaseDir + "/nodes"
|
NodesDir = BaseDir + "/nodes"
|
||||||
SystemdTemplate = "/etc/systemd/system/wallarm-node@.service"
|
SystemdTemplate = "/etc/systemd/system/wallarm-node@.service"
|
||||||
InstallerBaseURL = "https://repo.wallarm.com/linux/wallarm-native-node/latest/all-in-one"
|
|
||||||
InstallerArch = "x86_64"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// InstallerURL returns the all-in-one installer URL.
|
// installerURL returns the correct native node installer for the current architecture.
|
||||||
var InstallerURL = fmt.Sprintf("%s/wallarm-native-node-aio-%s-latest.sh", InstallerBaseURL, InstallerArch)
|
// Override with WALLARM_INSTALLER_URL env var to pin a specific version.
|
||||||
|
func installerURL() string {
|
||||||
|
if u := os.Getenv("WALLARM_INSTALLER_URL"); u != "" {
|
||||||
|
return u
|
||||||
|
}
|
||||||
|
arch := "x86_64"
|
||||||
|
suffix := "glibc"
|
||||||
|
return fmt.Sprintf("https://meganode.wallarm.com/6.12/wallarm-6.12.7.%s-%s.sh", arch, suffix)
|
||||||
|
}
|
||||||
|
|
||||||
// InstallNode deploys a single native Wallarm node.
|
// InstallNode deploys a single native Wallarm node.
|
||||||
// node: node metadata, apiToken: Wallarm API token, apiHost: cloud API host, labels: optional node labels.
|
// node: node metadata, apiToken: Wallarm API token, apiHost: cloud API host, labels: optional node labels.
|
||||||
|
|
@ -59,13 +65,10 @@ connector:
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Download installer if missing
|
// 3. Download installer if missing
|
||||||
installerURL := InstallerURL
|
url := installerURL()
|
||||||
if u := os.Getenv("WALLARM_INSTALLER_URL"); u != "" {
|
|
||||||
installerURL = u
|
|
||||||
}
|
|
||||||
if _, err := os.Stat(installerPath); os.IsNotExist(err) {
|
if _, err := os.Stat(installerPath); os.IsNotExist(err) {
|
||||||
fmt.Printf("[%s] Downloading installer...\n", node.Name)
|
fmt.Printf("[%s] Downloading installer from meganode.wallarm.com...\n", node.Name)
|
||||||
cmd := exec.Command("curl", "-fsSL", "-o", installerPath, installerURL)
|
cmd := exec.Command("curl", "-fsSL", "-o", installerPath, url)
|
||||||
if out, err := cmd.CombinedOutput(); err != nil {
|
if out, err := cmd.CombinedOutput(); err != nil {
|
||||||
return fmt.Errorf("download installer: %w\n%s", err, string(out))
|
return fmt.Errorf("download installer: %w\n%s", err, string(out))
|
||||||
}
|
}
|
||||||
|
|
@ -85,20 +88,17 @@ WALLARM_CONFIG_PATH=%s
|
||||||
return fmt.Errorf("write env: %w", err)
|
return fmt.Errorf("write env: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. Run the all-in-one installer
|
// 5. Run the meganode installer (piped token + region to avoid interactive prompts)
|
||||||
fmt.Printf("[%s] Running Wallarm installer...\n", node.Name)
|
fmt.Printf("[%s] Running Wallarm installer...\n", node.Name)
|
||||||
installCmd := exec.Command(installerPath, "install",
|
installCmd := exec.Command(installerPath)
|
||||||
"--", "--config-dir", filepath.Join(workDir, "etc"),
|
|
||||||
"--", "--log-dir", filepath.Join(workDir, "var", "log"),
|
|
||||||
"--", "--pid-dir", filepath.Join(workDir, "var", "run"),
|
|
||||||
)
|
|
||||||
installCmd.Dir = workDir
|
installCmd.Dir = workDir
|
||||||
installCmd.Env = append(os.Environ(),
|
installCmd.Env = append(os.Environ(),
|
||||||
"WALLARM_API_TOKEN="+apiToken,
|
"WALLARM_API_TOKEN="+apiToken,
|
||||||
"WALLARM_API_HOST="+apiHost,
|
"WALLARM_API_HOST="+apiHost,
|
||||||
"WALLARM_LABELS="+labels,
|
"WALLARM_LABELS="+labels,
|
||||||
"WALLARM_CONFIG_PATH="+configPath,
|
|
||||||
)
|
)
|
||||||
|
// Pipe token and region as stdin to skip interactive prompts
|
||||||
|
installCmd.Stdin = strings.NewReader(apiToken + "\n" + apiHost + "\n")
|
||||||
|
|
||||||
logFile, err := os.Create(filepath.Join(workDir, "install.log"))
|
logFile, err := os.Create(filepath.Join(workDir, "install.log"))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ func Run() Result {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. Installer reachability
|
// 6. Installer reachability
|
||||||
installerOk := shared.HTTPHead("https://repo.wallarm.com")
|
installerOk := shared.HTTPHead("https://meganode.wallarm.com/6.12/")
|
||||||
r.Checks = append(r.Checks, Check{
|
r.Checks = append(r.Checks, Check{
|
||||||
Name: "installer_reachable", Passed: installerOk,
|
Name: "installer_reachable", Passed: installerOk,
|
||||||
Detail: "repo.wallarm.com",
|
Detail: "repo.wallarm.com",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue