【发布时间】:2019-06-26 00:00:52
【问题描述】:
据我了解,使用 ansible-inventory-plugins 而不是 dynamic-inventory-provisioners 是处理动态主机的新方法,如云提供商等。
所以,起初我已经在我的环境中设置了 azure 凭据:
± env | grep AZ
AZURE_SECRET=asdf
AZURE_TENANT=asdf
AZURE_SUBSCRIPTION_ID=asdf
AZURE_CLIENT_ID=asdf
接下来,我写了一个 ansible.cfg,内容如下:
± cat ansible.cfg
[inventory]
enable_plugins = azure_rm
最后我用ansible inventory plugin页面所示的最小设置编写了yaml文件:
± cat foo.azure_rm.yaml
---
plugin: azure_rm
当我在该文件上运行 ansible-inventory 二进制文件时,我得到:
± ansible-inventory -i foo.azure_rm.yaml --list
[WARNING]: * Failed to parse /path/to/foo.azure_rm.yaml with azure_rm plugin: Unicode-objects must be encoded before hashing
[WARNING]: Unable to parse /path/to/foo.azure_rm.yaml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
{
"_meta": {
"hostvars": {}
},
"all": {
"children": [
"ungrouped"
]
},
"ungrouped": {}
}
总结:主要问题似乎是行:
[WARNING]: * Failed to parse /path/to/foo.azure_rm.yaml with azure_rm plugin: Unicode-objects must be encoded before hashing
帮忙,有人吗?
【问题讨论】:
-
检查 /path/to/foo.azure_rm.yaml 文件的编码。确保它是“正常”的东西,比如 UTF-8
-
@M_dk,是的……
标签: azure ansible yaml ansible-inventory