feat: 1) ListGroups返回组内主机详细信息 2) 前端刷新间隔改为5分钟 3) 命令执行和Playbook页面主机组支持展开显示组内主机

This commit is contained in:
Hermes Agent
2026-05-13 17:57:41 +08:00
commit 9c1f44e91a
20 changed files with 4062 additions and 0 deletions
+110
View File
@@ -0,0 +1,110 @@
#!/bin/bash
# Ansible Deploy 部署脚本
set -e
echo "=== Ansible Deploy 批量部署工具 ==="
# 检查依赖
check_dependencies() {
echo "检查依赖..."
# 检查Go
if ! command -v go &> /dev/null; then
echo "错误: Go未安装"
exit 1
fi
echo "✓ Go已安装: $(go version)"
# 检查Ansible
if ! command -v ansible &> /dev/null; then
echo "警告: Ansible未安装,是否安装? (y/n)"
read -r answer
if [ "$answer" = "y" ]; then
pip install ansible
else
echo "警告: Ansible未安装,部分功能可能不可用"
fi
else
echo "✓ Ansible已安装: $(ansible --version | head -1)"
fi
# 检查SSH
if ! command -v ssh &> /dev/null; then
echo "错误: SSH未安装"
exit 1
fi
echo "✓ SSH已安装"
}
# 创建目录结构
create_dirs() {
echo "创建目录结构..."
mkdir -p ~/ansible-deploy/{inventory,playbooks,logs}
echo "✓ 目录已创建"
}
# 初始化配置文件
init_config() {
echo "初始化配置文件..."
# 复制配置
if [ ! -f ~/ansible-deploy/config.yaml ]; then
cp config/config.yaml ~/ansible-deploy/config.yaml
echo "✓ 配置文件已创建"
fi
# 创建默认inventory
if [ ! -f ~/ansible-deploy/inventory/hosts ]; then
cat > ~/ansible-deploy/inventory/hosts << 'EOF'
# Ansible Inventory File
# 添加你的主机信息,格式:
# server1 ansible_host=192.168.1.10 ansible_user=root
[webservers]
web1 ansible_host=192.168.1.10 ansible_user=root
web2 ansible_host=192.168.1.11 ansible_user=root
[dbservers]
db1 ansible_host=192.168.1.20 ansible_user=root
[all:vars]
ansible_python_interpreter=/usr/bin/python3
EOF
echo "✓ Inventory文件已创建"
fi
}
# 构建项目
build_project() {
echo "构建项目..."
cd /root/ansible-deploy
go build -o ansible-deploy cmd/main.go
echo "✓ 构建成功: ansible-deploy"
}
# 安装
install_project() {
echo "安装..."
cp ansible-deploy /usr/local/bin/
chmod +x /usr/local/bin/ansible-deploy
echo "✓ 安装成功"
}
# 主函数
main() {
check_dependencies
create_dirs
init_config
build_project
install_project
echo ""
echo "=== 安装完成 ==="
echo "启动服务: ansible-deploy -port 8080"
echo "配置文件: ~/ansible-deploy/config.yaml"
echo "访问地址: http://localhost:8080"
}
main "$@"