Ansible multiple inventory file

2019-03-24 02:55发布

I am trying to use multiple inventory file and dynamic inventory with Ansible 1.4 and dev. Ansible returns No hosts matched.

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

if I run ansible -i test --list-hosts all it returns No hosts matched.

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 ?

标签: ansible
1条回答
该账号已被封号
2楼-- · 2019-03-24 03:22

Remove the .ini from your file names:

$ ls test/
hosts1  hosts2

$ ansible -i test --list-hosts all 
    test1
    test2
    test3
    test5
    test6
    test4
查看更多
登录 后发表回答