feat: Ansible Playbook 全栈 CRUD + 真实执行 — 替换mock为后端持久化
后端: - models/automation.go: Playbook 模型新增 Category/Tags 字段; 新增 CreatePlaybookRequest - handlers/automation.go: 新增 runPlaybookLocal(写临时YML+ansible-playbook --connection=local执行) + randomCode(crypto/rand生成唯一code) + List/Get/Create/Update/Delete/Execute Playbook 完整CRUD Execute 创建TaskExecution(task_type=playbook)记录,采集stdout/stderr/退出码/耗时 - routes/routes.go: 注册 /playbooks 路由组(7个端点) 前端: - services/api.ts: ansibleApi 从mock改为真实 /playbooks 后端调用 - AnsibleManager.tsx 完全重写: - Playbook管理: 真实数据卡片列表(id/name/category/tags/run_count/timeout) + 搜索/分类筛选 - 新建/编辑对话框复用(编辑模式预填数据) — 新增编辑入口(原无编辑功能) - 查看内容: 终端风格YAML查看器 + 快捷编辑按钮 - 执行: ConfirmProvider确认 + ansible-playbook本地执行 + toast结果反馈 - 执行记录tab: 真实TaskExecution记录(任务名/状态/开始时间/耗时/日志查看) - 统计卡片: 总数/执行中/今日成功/今日失败(基于真实执行记录) - 移除原inventory占位tab(无后端支持,避免非功能按钮) - tags JSON数组与前端string[]互转映射
This commit is contained in:
1 parent
2807e4895b
commit
ae6af93360
5 files changed
+772
-419
No files matched your search
@@ -261,6 +261,16 @@ func Register(r *gin.Engine, db *gorm.DB, log *zap.Logger, cfg *config.Config) {
|
||||
scripts.POST("/:id/execute", automationHandler.ExecuteScript)
|
||||
}
|
||||
|
||||
playbooks := authorized.Group("/playbooks")
|
||||
{
|
||||
playbooks.GET("", automationHandler.ListPlaybooks)
|
||||
playbooks.POST("", automationHandler.CreatePlaybook)
|
||||
playbooks.GET("/:id", automationHandler.GetPlaybook)
|
||||
playbooks.PUT("/:id", automationHandler.UpdatePlaybook)
|
||||
playbooks.DELETE("/:id", automationHandler.DeletePlaybook)
|
||||
playbooks.POST("/:id/execute", automationHandler.ExecutePlaybook)
|
||||
}
|
||||
|
||||
// 任务执行记录(脚本/定时任务执行历史)
|
||||
authorized.GET("/task-executions", automationHandler.ListExecutions)
|
||||
|
||||
|
||||
Reference in new issue
Block a user