test1代表组名,当然没有组名也可以.
[test1]
name1 ansible_ssh_host=192.168.1.111 ansible_ssh_user=
"root" ansible_ssh_pass="1234" ansible_ssh_port=22
name2 ansible_ssh_host=192.168.1.222 ansible_ssh_user=
"root" ansible_ssh_pass="1234" ansible_ssh_port=22
vars代表变量,并且可以自定义变量如testvar就是自定义
[test1]
name1 ansible_ssh_host=192.168.1.[20:50]
[test1:vars]
ansible_ssh_user=root
ansible_ssh_pass="1234"
testvar="test"
组的整合
[dbtest]
name1 ansible_ssh_host=192.168.1.[20:50] ansible_ssh_user="root" ansible_ssh_pass="1234" ansible_ssh_port=22
[webtest]
name2 ansible_ssh_host=192.168.2.[20:50] ansible_ssh_user="root" ansible_ssh_pass="1234" ansible_ssh_port=22
[test:children]
dbtest
webtest
如果需要对dbtest和webtest共同操作,可以直接调用test
其他复杂的组合
ansible webservers:dbservers -m win_ping 调用两组
ansible webservers:!dbservers -m win_ping 在webservers里不在dbservers里的调用
ansible webservers:&dbservers -m win_ping 在这两组里的才调用
ansible ~(web|db).*.91it.org -m win_ping ~代表支持正则表达式
webserver:dbservers:&nginx:!ntp 复杂组合的例子 利用:分开
网友评论