Ansible 多清单文件 [英] Ansible multiple inventory file
问题描述
我正在尝试在 Ansible 1.4 和 dev 中使用多个清单文件和动态清单.Ansible 返回没有匹配的主机.
I am trying to use multiple inventory file and dynamic inventory with Ansible 1.4 and dev. Ansible returns No hosts matched.
我在一个目录中有两个主机文件的模拟场景 test 列出了目录的内容.
I have a simulated scenario with two hosts file in a directory test the content of the directory is listed.
hosts1.ini
[group1]
test1 ansible_ssh_host=127.0.0.1
test2 ansible_ssh_host=127.0.0.2
[group2]
test3 ansible_ssh_host=127.0.0.3
hosts2.ini
[group3]
test4 ansible_ssh_host=127.0.0.4
[group4]
test5 ansible_ssh_host=127.0.0.4
test6 ansible_ssh_host=127.0.0.5
如果我运行 ansible -i test --list-hosts all,它返回没有匹配的主机.
if I run ansible -i test --list-hosts all it returns No hosts matched.
我深入研究了代码,发现 dir.py 做了一个小的修改,我觉得它太有用了.但我想我一定是做错了什么,不需要 hack.关于如何解决它的任何想法?
I digged into the code and found dir.py with a small amended i got it too work. But I think i must have done something wrong and the hack is not required. Any ideas on how to solve it ?
推荐答案
从文件名中删除 .ini
:
$ ls test/
hosts1 hosts2
$ ansible -i test --list-hosts all
test1
test2
test3
test5
test6
test4
这篇关于Ansible 多清单文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!