创建inventory目录,可以在这个目录下添加多个不同业务的文件
[root@node110 inventory]# pwd
/etc/ansible/inventory
[root@node110 inventory]# tree
.
|-- docker
`-- hosts
0 directories, 2 files
修改配置文件:
vim /etc/ansible/ansible.cfg
#inventory = /etc/ansible/hosts
inventory = /etc/ansible/inventory #将指定文件,修改成指定目录
#library = /usr/share/my_modules/
#remote_tmp = ~/.ansible/tmp
查看配置是否生效:
[root@node110 inventory]# cat docker
[docker]
172.17.42.10[1:3]
[docker:vars]
ansible_ssh_pass='123456'
[ansible:children]
docker
[root@node110 inventory]# ansible docker --list-hosts
hosts (3):
172.17.42.101
172.17.42.102
172.17.42.103
2017-04-18
ansible hosts 多个inventory列表
评论
发表评论
姓 名: