hosts文件主要有分组和不分组两种写法,
不分组的写法:
直接写ip 后边可以接变量,一个IP独占一行变量间用空格隔开;
192.168.10.11 192.168.10.22
分组写法:
组名用中括号[ ]括起来,一个IP占一行
[linux] 192.168.10.33 192.168.10.44 [web] 192.168.10.44 192.168.10.55
管理主机执行hostname命令:
ansible [web] -m shell -a "hostname" ansible [web]:[linux] -m shell -a "hostname" ansible [web]:![linux] -m shell -a "hostname" ansible [web]:&[linux] -m shell -a "hostname"
先介绍到这里,想到什么再补充,再见!