[master]
192.168.100.28 host_id=1
192.168.100.29 host_id=2
192.168.100.30 host_id=3
[node]
192.168.100.31 ansible_ssh_port=22 ansible_ssh_user=root ansible_ssh_pass='root' host_id=4
[all:vars] # 定义全局变量
ansible_ssh_private_key_file=/root/.ssh/id_rsa
ansible_ssh_port=22
ansible_ssh_user=root
[master:vars] # 定义 master 组变量
ansible_ssh_port=22
ansible_ssh_user=root
ansible_ssh_pass='root'
[node:vars] # 定义 node 组的变量
mysql_port=3806
[cluster:children]
master
node
Master_Count: "{{ groups['master'] | length }}"
Node_Count: "{{ groups['node'] | length }}"
Cluster_Count: "{{ groups['cluster'] | length }}"