Fold alerts under their host, recurring maintenance, run playbooks from alerts, and an Updates page
- Servers can say what they run on (or it is worked out from the Proxmox node); when the host is down the guests' offline alerts fold under it: held back, not counted, not notified, still recorded. - Recurring maintenance schedules made into ordinary windows a week ahead (maintenance_schedules). - Run a Semaphore template limited to a server from its page or an alert, and watch the run. - Agents report pending updates (apt, dnf, zypper, Windows Update); an Updates page lists them. - Migrations 0024 and 0025. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
44e393f172
commit
171511c6db
45 files changed
+6772
-44
No files matched your search
@@ -633,6 +633,14 @@ integrationsRouter.get("/:id/semaphore/templates", asyncHandler(async (req, res)
|
||||
}
|
||||
}));
|
||||
|
||||
// Which hosts a run may be limited to: names, addresses and ansible patterns (commas, colons, wildcards) — and nothing that could be
|
||||
// taken for an option. Semaphore hands the value to ansible as an argument, but it is still only ever shown the characters a host has.
|
||||
const runBodySchema = z
|
||||
.object({
|
||||
limit: z.union([z.literal(""), z.string().trim().regex(/^[A-Za-z0-9][A-Za-z0-9._,:*\-]{0,199}$/, "Use host names or patterns like web01,db*")]).optional(),
|
||||
})
|
||||
.default({});
|
||||
|
||||
integrationsRouter.post(
|
||||
"/:id/semaphore/projects/:projectId/templates/:templateId/run",
|
||||
requireRole("operator"),
|
||||
@@ -645,16 +653,25 @@ integrationsRouter.post(
|
||||
if (!Number.isInteger(projectId) || !Number.isInteger(templateId)) {
|
||||
return res.status(400).json({ error: "invalid_id" });
|
||||
}
|
||||
const body = runBodySchema.safeParse(req.body ?? {});
|
||||
if (!body.success) {
|
||||
return res.status(400).json({ error: "invalid_body", message: "The hosts to limit it to can only be host names or patterns like web01,db*.", details: body.error.flatten() });
|
||||
}
|
||||
|
||||
try {
|
||||
const task = await found.adapter.runTemplate(projectId, templateId);
|
||||
const actor = req.currentUser!;
|
||||
const limit = body.data.limit || undefined;
|
||||
const task = await found.adapter.runTemplate(projectId, templateId, {
|
||||
limit,
|
||||
message: `Started in Homelab Manager by ${actor.name ?? actor.email ?? actor.oidcSub}${limit ? ` (limited to ${limit})` : ""}`,
|
||||
});
|
||||
await recordAudit({
|
||||
actor: req.currentUser!,
|
||||
actor,
|
||||
category: "integration",
|
||||
action: "run_template",
|
||||
targetType: "semaphore_template",
|
||||
targetId: templateId,
|
||||
detail: { integrationId: found.integration.id, projectId, taskId: task.id },
|
||||
detail: { integrationId: found.integration.id, projectId, taskId: task.id, ...(limit ? { limit } : {}) },
|
||||
});
|
||||
res.status(201).json({ task });
|
||||
} catch (err) {
|
||||
@@ -663,6 +680,20 @@ integrationsRouter.post(
|
||||
}),
|
||||
);
|
||||
|
||||
// How a run is getting on: waiting, running, success or error.
|
||||
integrationsRouter.get("/:id/semaphore/projects/:projectId/tasks/:taskId", asyncHandler(async (req, res) => {
|
||||
const found = await requireSemaphoreAdapter(req, res);
|
||||
if (!found) return;
|
||||
const projectId = Number(req.params.projectId);
|
||||
const taskId = Number(req.params.taskId);
|
||||
if (!Number.isInteger(projectId) || !Number.isInteger(taskId)) return res.status(400).json({ error: "invalid_id" });
|
||||
try {
|
||||
res.json({ task: await found.adapter.getTask(projectId, taskId) });
|
||||
} catch (err) {
|
||||
res.status(502).json({ error: err instanceof Error ? err.message : String(err) });
|
||||
}
|
||||
}));
|
||||
|
||||
// ─── Proxmox ─────────────────────────────────────────────────────────────────
|
||||
|
||||
async function requireProxmoxAdapter(req: Request, res: Response) {
|
||||
|
||||
Reference in new issue
Block a user