#!/bin/bash

# NFS CSI Plugin 部署脚本
# 这个脚本会安装NFS CSI插件，让您的NFS存储能在Nomad UI中显示

set -e

echo "🚀 开始部署NFS CSI Plugin..."

# 检查是否为root用户
if [ "$EUID" -ne 0 ]; then
    echo "❌ 请以root用户运行此脚本"
    exit 1
fi

# 1. 安装CSI插件
echo "📦 安装NFS CSI插件..."
ansible-playbook -i deployment/ansible/inventories/production/hosts \
    deployment/ansible/playbooks/install/install-nfs-csi-plugin.yml

# 2. 等待Nomad服务重启
echo "⏳ 等待Nomad服务重启..."
sleep 30

# 3. 注册CSI Volume
echo "📝 注册CSI Volume..."
nomad volume register components/nomad/volumes/nfs-csi-volume.hcl

# 4. 验证CSI插件状态
echo "✅ 验证CSI插件状态..."
nomad plugin status

# 5. 显示CSI volumes
echo "📊 显示CSI volumes..."
nomad volume status

echo "🎉 NFS CSI Plugin部署完成！"
echo "现在您可以在Nomad UI中看到CSI插件和volumes了！"






