2026-07-28 11:05:57 +08:00
|
|
|
# =============================================================================
|
|
|
|
|
# Ansible Inventory 示例文件
|
|
|
|
|
# =============================================================================
|
|
|
|
|
# Inventory 定义了要管理的主机列表和分组
|
|
|
|
|
# 实际使用时,平台会动态生成 inventory 并传入变量
|
|
|
|
|
#
|
|
|
|
|
# 使用方式:
|
|
|
|
|
# ansible-playbook -i inventory.example.yml mysql-deploy.yml \
|
|
|
|
|
# -e "target_hosts=mysql_hosts" \
|
|
|
|
|
# -e "instance_name=db01" \
|
|
|
|
|
# -e "topology=mgr_3" \
|
|
|
|
|
# -e "mysql_version=8.0" \
|
|
|
|
|
# -e "memory_mb=8192" \
|
|
|
|
|
# -e "storage_gb=100"
|
|
|
|
|
# =============================================================================
|
|
|
|
|
|
2026-07-23 12:05:07 +08:00
|
|
|
all:
|
|
|
|
|
children:
|
2026-07-28 11:05:57 +08:00
|
|
|
# --- MySQL 主机组 ---
|
|
|
|
|
# 按拓扑需求选择对应数量的主机:
|
|
|
|
|
# standalone = 1 台
|
|
|
|
|
# primary_replica = 2 台(一主一从)
|
|
|
|
|
# mgr_3 = 3 台(三节点组复制)
|
2026-07-23 12:05:07 +08:00
|
|
|
mysql_hosts:
|
|
|
|
|
hosts:
|
2026-07-28 11:05:57 +08:00
|
|
|
# 格式:主机名: { ansible_host: IP地址 }
|
2026-07-23 12:05:07 +08:00
|
|
|
k8s-server-01: { ansible_host: 192.168.1.4 }
|
|
|
|
|
k8s-server-02: { ansible_host: 192.168.1.5 }
|
|
|
|
|
k8s-server-03: { ansible_host: 192.168.1.2 }
|
|
|
|
|
k8s-worker-01: { ansible_host: 192.168.1.3 }
|
2026-07-28 11:05:57 +08:00
|
|
|
|
|
|
|
|
# --- 全局变量 ---
|
2026-07-23 12:05:07 +08:00
|
|
|
vars:
|
2026-07-28 11:05:57 +08:00
|
|
|
ansible_user: root # SSH 登录用户(需要 root 权限执行系统级操作)
|
|
|
|
|
ansible_python_interpreter: /usr/bin/python3 # Python 解释器路径(Ubuntu 默认位置)
|