feat: 主机变量支持 - 每台主机独立BMC/IPMI配置

- 后端: inventory生成时写入主机自定义变量(host_vars)
- 前端: 主机编辑表单新增'主机变量'输入区(key=value格式)
- 模板: ipmitool-bmc改为读取主机变量,未配置时用默认值
- 示例: 每台主机设置 bmc_ip=10.10.10.x,Playbook自动区分
- 变量写入inventory: web ansible_host=... bmc_ip=10.10.10.1
This commit is contained in:
cnbugs
2026-07-30 23:07:10 +08:00
parent 0cc2103a90
commit c161c4487a
3 changed files with 43 additions and 17 deletions
+4
View File
@@ -459,6 +459,10 @@ func (s *AnsibleService) updateInventoryFile() {
keyPath := s.resolveSSHKeyPath(h.SSHKey)
line += fmt.Sprintf(" ansible_ssh_private_key_file=%s", keyPath)
}
// 写入主机自定义变量(如 bmc_ip, bmc_user 等)
for k, v := range h.Vars {
line += fmt.Sprintf(" %s=%s", k, v)
}
lines = append(lines, line)
}
lines = append(lines, "")