OS deployment: image catalog with upstream sync, deploy/release jobs, agent deploy mode, UI and CLI

- rollcall os list|sync|import|promote|rm: <os_dir>/<name>/<version>/{disk.raw.zst,meta.json},
  current symlink, vendor checksum verification (GNU/BSD formats, sha256/sha512), qemu-img -> raw,
  zstd in-process, keep-N pruning, nightly rollcall-os-sync.timer, deploy/os-sources.json
  (Debian 13, Ubuntu 24.04, Rocky 9, AlmaLinux 9, CentOS Stream 9)
- jobs table + API: deploy (disk pick, hostname/IP allocation, job token, per-MAC deploy PXE
  entry), release (wipe), progress, cancel, cloud-init phone_home
- agent/rollcall-deploy.py: streamed write with sha256 + pv progress, NoCloud seed, SELinux
  autorelabel, efibootmgr on UEFI; commissioning image gains zstd/parted/xfsprogs/...
- web UI: deploy/release controls, deployment card with progress, OS catalog table
- README: deployment section, image freshness policy

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Fable 5.1 committed 2026-10-27 10:10:39 +01:00
1 parent 1452b79218
commit fad4e1c8bd
24 files changed
+2194 -26

No files matched your search

+143 -3
View File
@@ -99,9 +99,19 @@ func runClient(cmd string, args []string) error {
if err := c.do("GET", "/api/v1/machines", nil, &ms); err != nil {
return err
}
f := "%-16s %-12s %-10s %-10s %-14s %-24s %4s %7s %3s %7s %3s %2s %3s %s\n"
fmt.Printf(f, "ID", "STATE", "NODE", "PROFILE", "MGMT-IP", "MODEL", "CPU", "RAM", "DSK", "STORAGE", "NIC", "IB", "GPU", "BMC")
f := "%-16s %-14s %-10s %-16s %-14s %-24s %4s %7s %3s %7s %3s %2s %3s %s\n"
fmt.Printf(f, "ID", "STATE", "NODE", "PROFILE/OS", "MGMT-IP", "MODEL", "CPU", "RAM", "DSK", "STORAGE", "NIC", "IB", "GPU", "BMC")
for _, m := range ms {
state := m.State
if m.Job != nil {
var p obj
_ = json.Unmarshal(m.Job.Progress, &p)
state = fmt.Sprintf("%s %.0f%%", m.Job.Kind, num(p["pct"]))
}
what := deref(m.Profile)
if what == "" && m.OS != nil {
what = *m.OS
}
bmc := "-"
if m.BMC != nil {
b := *m.BMC
@@ -112,7 +122,7 @@ func runClient(cmd string, args []string) error {
bmc = fmt.Sprintf("%s (%s,%s)", str(b["address"]), str(b["source"]), ok)
}
model := strings.TrimSpace(deref(m.Manufacturer) + " " + deref(m.Product))
fmt.Printf(f, m.ID, m.State, deref(m.NodeName), deref(m.Profile), deref(m.MgmtIP), trunc(model, 24), m.CPUs, human(m.MemoryBytes),
fmt.Printf(f, m.ID, state, deref(m.NodeName), trunc(what, 16), deref(m.MgmtIP), trunc(model, 24), m.CPUs, human(m.MemoryBytes),
fmt.Sprint(int(m.Disks)), human(m.StorageBytes), fmt.Sprint(m.NICs), fmt.Sprint(m.IBHCAs), fmt.Sprint(m.GPUs), bmc)
}
case "show":
@@ -177,12 +187,142 @@ func runClient(cmd string, args []string) error {
return err
}
fmt.Println("deleted", str(d["deleted"]))
case "deploy", "release", "jobs", "job":
return c.deployCmd(cmd, args)
default:
return c.statelessCmd(cmd, args)
}
return nil
}
func (c *client) deployCmd(cmd string, args []string) error {
switch cmd {
case "deploy":
if len(args) < 2 {
usage()
}
fs := newFlags("deploy")
ver := fs.String("version", "", "image version (default: current)")
disk := fs.String("disk", "", "target disk, e.g. /dev/sda (default: smallest disk that fits)")
host := fs.String("hostname", "", "hostname (default: existing node name or next free)")
upgrade := fs.Bool("upgrade", false, "cloud-init package_upgrade on first boot")
pkgs := fs.String("packages", "", "comma-separated packages to install on first boot")
ud := fs.String("user-data", "", "file with a complete #cloud-config to use instead of the generated one")
boot := fs.Bool("boot", false, "set bootdev pxe and power-cycle via BMC")
watch := fs.Bool("watch", false, "follow job progress")
_ = fs.Parse(args[2:])
req := obj{"os": args[1], "version": *ver, "disk": *disk, "hostname": *host, "package_upgrade": *upgrade, "boot": *boot}
if *pkgs != "" {
req["packages"] = strings.Split(*pkgs, ",")
}
if *ud != "" {
b, err := os.ReadFile(*ud)
if err != nil {
return err
}
req["user_data"] = string(b)
}
var d obj
if err := c.do("POST", "/api/v1/machines/"+args[0]+"/deploy", req, &d); err != nil {
return err
}
fmt.Printf("%s: job %s %s/%s -> %s hostname=%s mgmt=%s\n", str(d["id"]), str(d["job"]), str(d["os"]), str(d["version"]), str(d["disk"]), str(d["hostname"]), str(d["mgmt_ip"]))
if d["ipmi"] != nil {
fmt.Println(str(d["ipmi"]))
}
if *watch {
return c.watchJob(args[0])
}
case "release":
if len(args) < 1 {
usage()
}
fs := newFlags("release")
boot := fs.Bool("boot", false, "set bootdev pxe and power-cycle via BMC")
wipe := fs.String("wipe", "quick", "quick (signatures + first/last 64 MiB) or full")
watch := fs.Bool("watch", false, "follow job progress")
_ = fs.Parse(args[1:])
var d obj
if err := c.do("POST", "/api/v1/machines/"+args[0]+"/release", obj{"boot": *boot, "wipe": *wipe}, &d); err != nil {
return err
}
fmt.Printf("%s: job %s wipe %s\n", str(d["id"]), str(d["job"]), str(d["disk"]))
if d["ipmi"] != nil {
fmt.Println(str(d["ipmi"]))
}
if *watch {
return c.watchJob(args[0])
}
case "jobs":
if len(args) < 1 {
usage()
}
if len(args) > 1 && args[1] == "-watch" {
return c.watchJob(args[0])
}
var jobs []Job
if err := c.do("GET", "/api/v1/machines/"+args[0]+"/jobs", nil, &jobs); err != nil {
return err
}
fmt.Printf("%-10s %-8s %-10s %-20s %-20s %s\n", "JOB", "KIND", "STATE", "CREATED", "FINISHED", "OS / PROGRESS / ERROR")
for _, j := range jobs {
sp := j.spec()
var p obj
_ = json.Unmarshal(j.Progress, &p)
fin := ""
if j.Finished != nil {
fin = j.Finished.Local().Format("2006-01-02 15:04:05")
}
extra := sp.OS + "/" + sp.Version + " " + sp.Disk
if j.State == "running" {
extra += fmt.Sprintf(" %s %.0f%% %s", str(p["phase"]), num(p["pct"]), str(p["msg"]))
}
if j.Error != nil {
extra += " " + *j.Error
}
fmt.Printf("%-10s %-8s %-10s %-20s %-20s %s\n", j.ID, j.Kind, j.State, j.Created.Local().Format("2006-01-02 15:04:05"), fin, extra)
}
case "job":
if len(args) < 2 || args[0] != "cancel" {
usage()
}
var d obj
if err := c.do("POST", "/api/v1/machines/"+args[1]+"/jobs/cancel", nil, &d); err != nil {
return err
}
fmt.Printf("job %s cancelled\n", str(d["job"]))
}
return nil
}
func (c *client) watchJob(id string) error {
last := ""
for {
var jobs []Job
if err := c.do("GET", "/api/v1/machines/"+id+"/jobs", nil, &jobs); err != nil {
return err
}
if len(jobs) == 0 {
return fmt.Errorf("no jobs")
}
j := jobs[0]
var p obj
_ = json.Unmarshal(j.Progress, &p)
line := fmt.Sprintf("%s %s %-9s %-12s %3.0f%% %s", time.Now().Format("15:04:05"), j.ID, j.State, str(p["phase"]), num(p["pct"]), str(p["msg"]))
if line[9:] != last {
fmt.Println(line)
last = line[9:]
}
if j.State != "pending" && j.State != "running" {
if j.Error != nil {
return fmt.Errorf("%s", *j.Error)
}
return nil
}
time.Sleep(3 * time.Second)
}
}
func (c *client) statelessCmd(cmd string, args []string) error {
switch cmd {
case "images":