1。ansible主机清单的配置
以下是ansible安装完成后的源文件
root@test-1 ~ #猫/etc/ansible/hosts #这是默认ansible“主机”文件。 # #应该住在/etc/ansible/hosts # #——评论以“#”字符开始 # - - - - - -空行被忽略 #——组主机由[标题]元素分隔 #——你可以输入主机名或ip地址 #——一个主机名/ip可以多个组的成员 例1:未分组的主机,指定之前组标头。 (网路) 根ansible_host_pass 192.168.200.131 ansible_host_user==' 123456 ' 192.168.200.132 192.168.200.133 192.168.200.134 192.168.200.135 192.168.200.136 # # green.example.com # # blue.example.com # # 192.168.100.1 # # 192.168.100.10 # 2:交货一批主机属于“网路”组 # #(网路) # # alpha.example.org # # beta.example.org # # 192.168.1.100 # # 192.168.1.110 #如果你有多个主机后,您可以指定一个模式 #他们是这样的: # # [001:006].example.com #例3:数据库服务器的集合在“dbservers”组 # # (dbservers) # # # # db01.intranet.mydomain.net # # db02.intranet.mydomain.net # # 10.25.1.56 # # 10.25.1.57 #这是宿主范围的另一个例子,这一次没有 # 0领先: # # db - [99:101] -node.example.com
2。ansible定义方式:
1)直接指明主机地址或主机名
test_2.xxxx.cn2 192.168.200.132
(网路) 根ansible_host_pass 192.168.200.131 ansible_host_user==' 123456 ' 192.168.200.132 192.168.200.133 192.168.200.134 192.168.200.135 192.168.200.136
格式:【主机名】【指定用户】【主机地址】【主机密码】 (网路) 192.168.200.131 ansible_host_user=根test 1=192.168.200.131 ansible_host_pass=' 123456 '