【发布时间】:2019-03-24 15:39:57
【问题描述】:
尝试格式化有效的动态库存。这是怎么做到的?
这是一个脚本,它将获取 terraform 的状态文件并使其成为可用的库存。我需要知道 Ansible 中使用的动态清单的格式。
我尝试运行以下库存:ansible all -i test.json -m ping
{
"_meta": {
"hostvars": { }
},
"instances": {
"hosts": ["10.66.70.33"]
}
}
结果:
[WARNING]: * Failed to parse /etc/ansible/test.json with yaml plugin: Invalid "hosts" entry for "instances" group,
requires a dictionary, found "<type 'list'>" instead.
[WARNING]: * Failed to parse /etc/ansible/test.json with ini plugin: /etc/ansible/test.json:2: Expected
key=value host variable assignment, got: {
[WARNING]: Unable to parse /etc/ansible/test.json as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
{ | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname {: Temporary failure in name resolution",
"unreachable": true
}
【问题讨论】: