配置主机清单
分组配置
[zu1]
192.168.1.1
192.168.1.2
192.168.1.3
[zu2]
192.168.1.4
192.168.1.5
192.168.1.6
[zu3]
192.168.1.3
192.168.1.4
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
主机名符号匹配
192.168.1.[1:9]
zu[1:3]
1
2
2
跟上非标准远程端口
# 192.168.1.1 的 ssh 远程端口为 22222
192.168.1.1:22222
1
2
2
主机使用特殊的变量(没有分发公钥)
# 192.168.1.2 没有被 192.168.1.1 分配公钥
192.168.1.2 ansible_ssh_port=22222 ansible_ssh_user=root ansible_ssh_pass=123456
web01 ansible_ssh_host=192.168.1.2 ansible_ssh_port=22222 ansible_ssh_user=root ansible_ssh_pass=123456
1
2
3
4
2
3
4
主机组名嵌入配置
[rsync:children]
rsync_server
rsync_client
[rsync_server]
192.168.1.1
[rsync_client]
192.168.1.2
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
主机变量配置
[web:vars]
ansible_ssh_host=192.168.1.1
ansible_ssh_port=22222
ansible_ssh_user=root
ansible_ssh_pass=123456
[web]
web01
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8