Bog*_*dan 0 ansible ansible-inventory azure-rm
我正在尝试为 Ansible 设置动态清单以与 Azure 一起使用,但我收到一些消息,因为 Ansible 无法解析我的 yaml 文件。
到目前为止我做了什么:
创建了 Azure 服务主体并将凭据添加到 /home/user/.azure/credentials (我知道他们建议将它们放在 /home/.azure/credentials 中,我尝试过这样做,但我的 Ansible 似乎在 /home 中查找它们/用户目录。
我将 python 插件(原始的、未经编辑的插件)及其 yaml 配置文件放置在 /etc/ansible/inventory_plugins 中。配置文件如下所示:
plugin: azure_rm
include_vm_resource_groups:
- vm_1197_rg
auth_source: auto
Run Code Online (Sandbox Code Playgroud)
- 使用以下命令测试功能:ansible all -m ping -i ./myazure_rm.yml
输出:
ansible 2.8.1 配置文件 = /etc/ansible/ansible.cfg 配置模块搜索路径 = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python模块位置 = /usr/lib/python2.7/site-packages/ansible 可执行文件位置 = /bin/ansible python 版本 = 2.7.5 (默认,2019 年 4 月 9 日,14:30:50) [GCC 4.8.5 20150623 ( Red Hat 4.8.5-36)] 使用 /etc/ansible/ansible.cfg 作为配置文件 由于清单源不存在或当前用户无法读取而跳过 azure_rm 拒绝将 /etc/ansible/inventory_plugins/myazure_rm.yml 解析为它没有通过它的 verify_file() 方法 [警告]:无法将 /etc/ansible/inventory_plugins/myazure_rm.yml 解析为清单源
[警告]:没有解析清单,只有隐式本地主机可用
[警告]:如果主机列表为空,则只有 localhost 可用。请注意,隐式 localhost 与“all”不匹配
'使用azure_rm库存插件时,库存文件的名称实际上对于解析很重要。
它必须以以下任一方式结束:
azure_rm.ymlazure_rm.yaml例如,以下任何文件名都是有效的:
inventory_azure_rm.ymlinventoryazure_rm.ymlwhy_is_this_a_good_idea_azure_rm.yml如果文件不以您结尾,azure_rm.yml您将收到一条通用错误消息,如下所示:
[WARNING]: * Failed to parse $FILENAME with auto plugin: inventory config '$FILENAME ' could not be verified by plugin 'azure_rm'
Run Code Online (Sandbox Code Playgroud)