feat(prod): add production infrastructure management
Add `core prod` command with full production infrastructure tooling:
- `core prod status` — parallel SSH health checks across all hosts,
Galera cluster state, Redis sentinel, Docker, LB health
- `core prod setup` — Phase 1 foundation: Hetzner topology discovery,
managed LB creation, CloudNS DNS record management
- `core prod dns` — CloudNS record CRUD with idempotent EnsureRecord
- `core prod lb` — Hetzner Cloud LB status and creation
- `core prod ssh <host>` — SSH into hosts defined in infra.yaml
New packages:
- pkg/infra: config parsing, Hetzner Cloud/Robot API, CloudNS DNS API
- infra.yaml: declarative production topology (hosts, LB, DNS, SSL,
Galera, Redis, containers, S3, CDN, CI/CD, monitoring, backups)
Docker:
- Dockerfile.app (PHP 8.3-FPM, multi-stage)
- Dockerfile.web (Nginx + security headers)
- docker-compose.prod.yml (app, web, horizon, scheduler, mcp, redis, galera)
Ansible playbooks (runnable via `core deploy ansible`):
- galera-deploy.yml, redis-deploy.yml, galera-backup.yml
- inventory.yml with all production hosts
CI/CD:
- .forgejo/workflows/deploy.yml for Forgejo Actions pipeline
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 03:03:29 +00:00
|
|
|
package prod
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"os"
|
|
|
|
|
"os/exec"
|
|
|
|
|
"syscall"
|
|
|
|
|
|
2026-02-16 14:24:37 +00:00
|
|
|
"forge.lthn.ai/core/go/pkg/cli"
|
feat(prod): add production infrastructure management
Add `core prod` command with full production infrastructure tooling:
- `core prod status` — parallel SSH health checks across all hosts,
Galera cluster state, Redis sentinel, Docker, LB health
- `core prod setup` — Phase 1 foundation: Hetzner topology discovery,
managed LB creation, CloudNS DNS record management
- `core prod dns` — CloudNS record CRUD with idempotent EnsureRecord
- `core prod lb` — Hetzner Cloud LB status and creation
- `core prod ssh <host>` — SSH into hosts defined in infra.yaml
New packages:
- pkg/infra: config parsing, Hetzner Cloud/Robot API, CloudNS DNS API
- infra.yaml: declarative production topology (hosts, LB, DNS, SSL,
Galera, Redis, containers, S3, CDN, CI/CD, monitoring, backups)
Docker:
- Dockerfile.app (PHP 8.3-FPM, multi-stage)
- Dockerfile.web (Nginx + security headers)
- docker-compose.prod.yml (app, web, horizon, scheduler, mcp, redis, galera)
Ansible playbooks (runnable via `core deploy ansible`):
- galera-deploy.yml, redis-deploy.yml, galera-backup.yml
- inventory.yml with all production hosts
CI/CD:
- .forgejo/workflows/deploy.yml for Forgejo Actions pipeline
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 03:03:29 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var sshCmd = &cobra.Command{
|
|
|
|
|
Use: "ssh <host>",
|
|
|
|
|
Short: "SSH into a production host",
|
|
|
|
|
Long: `Open an SSH session to a production host defined in infra.yaml.
|
|
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
core prod ssh noc
|
|
|
|
|
core prod ssh de
|
|
|
|
|
core prod ssh de2
|
|
|
|
|
core prod ssh build`,
|
|
|
|
|
Args: cobra.ExactArgs(1),
|
|
|
|
|
RunE: runSSH,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func runSSH(cmd *cobra.Command, args []string) error {
|
|
|
|
|
cfg, _, err := loadConfig()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
name := args[0]
|
|
|
|
|
host, ok := cfg.Hosts[name]
|
|
|
|
|
if !ok {
|
|
|
|
|
// List available hosts
|
|
|
|
|
cli.Print("Unknown host '%s'. Available:\n", name)
|
|
|
|
|
for n, h := range cfg.Hosts {
|
|
|
|
|
cli.Print(" %s %s (%s)\n", cli.BoldStyle.Render(n), h.IP, h.Role)
|
|
|
|
|
}
|
|
|
|
|
return fmt.Errorf("host '%s' not found in infra.yaml", name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sshArgs := []string{
|
|
|
|
|
"ssh",
|
|
|
|
|
"-i", host.SSH.Key,
|
|
|
|
|
"-p", fmt.Sprintf("%d", host.SSH.Port),
|
|
|
|
|
"-o", "StrictHostKeyChecking=accept-new",
|
|
|
|
|
fmt.Sprintf("%s@%s", host.SSH.User, host.IP),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cli.Print("%s %s@%s (%s)\n",
|
|
|
|
|
cli.BoldStyle.Render("▶"),
|
|
|
|
|
host.SSH.User, host.FQDN,
|
|
|
|
|
cli.DimStyle.Render(host.IP))
|
|
|
|
|
|
|
|
|
|
sshPath, err := exec.LookPath("ssh")
|
|
|
|
|
if err != nil {
|
|
|
|
|
return fmt.Errorf("ssh not found: %w", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Replace current process with SSH
|
|
|
|
|
return syscall.Exec(sshPath, sshArgs, os.Environ())
|
|
|
|
|
}
|