Ansible无法识别配置中设置的默认清单

时间:2020-03-25 16:25:15

标签: ansible

如果我明确指定Ansible清单文件,则可以使用它来ping所有主机:

ansible -i mmp_default/mmp_static_default  all -m ping

mmp-websockets002.prod01.company.com | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
}
mmp-staticweb001.prod01.company.com | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"

但是在我的配置中将其设置为默认清单不起作用:

ansible all -m ping
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

这是我的配置:

sudo cat /etc/ansible/ansible.cfg
[defaults]
ansible_managed = This file is managed by Merlin. Do not edit directly.
deprecation_warnings = False
timeout=30
remote_user = centos
private_key_file = /home/centos/AWS.pem

[privilege_escalation]
become=True
become_user=root

[inventory]
## enable inventory plugins, default: 'host_list', 'script', 'yaml', 'ini'
enable_plugins = auto, ini
inventory = /home/centos/R2.4.1/merlin/mmp_default/mmp_static_default

我的库存清单为:inventory = /home/centos/R2.4.1/merlin/mmp_default/mmp_static_default

为什么无法识别我在配置中设置的清单文件?

1 个答案:

答案 0 :(得分:1)

the doc中,inventory的设置应位于默认部分:

[defaults]
...
inventory = /home/centos/R2.4.1/merlin/mmp_default/mmp_static_default
...

[privilege_escalation]
....