我的python脚本动态地查询并生成JSON文件,如下所示:
{
"all": {
"hosts": [
"192.158.1.1"
],
"vars": {
"ansible_become_method": "sudo",
"ansible_become": "yes"
}
}
}但是当我执行下面的命令时
ansible -i script.py -m ping 它发出以下警告消息:
我不知道我错过了什么或错了,因为我是新的动态库存与Ansible。
当我运行ansible-inventory -i script.py --list时,我得到以下响应
{
"_meta": {
"hostvars": {}
},
"all": {
"children": [
"ungrouped"
]
},
"ungrouped": {}
}我的不可信版本是2.7.7
库存插件是脚本
enable_plugins = script根据史蒂夫的建议更新了运行-v的,给了我更多的建议
[WARNING]: * Failed to parse /etc/ansible/newhost.py with script plugin: failed to parse executable inventory script results from /etc/ansible/script.py: Syntax
Error while loading YAML. mapping values are not allowed in this context The error appears to have been in '<string>': line 3, column 8, but may be elsewhere in the
file depending on the exact syntax problem.
File "/usr/lib/python2.7/site-packages/ansible/plugins/inventory/script.py", line 125, in parse
raise AnsibleError("failed to parse executable inventory script results from {0}: {1}\n{2}".format(path, to_native(e), err))https://stackoverflow.com/questions/54936175
复制相似问题