You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Ansible Azure动态插件生成Inventory时遇报错求助

解决Ansible Azure动态Inventory解析错误

问题原因

报错Plugin configuration YAML file, not YAML inventory表明Ansible未将你的配置文件识别为Azure动态inventory插件的配置,核心原因通常是缺少azure.azcollection集合(azure_rm插件属于该集合),或者集合未正确加载。

解决步骤

  • 安装azure.azcollection集合
    执行以下命令安装官方Azure集合:

    ansible-galaxy collection install azure.azcollection
    

    同时安装依赖的Python SDK包:

    pip install azure-core azure-mgmt-compute azure-mgmt-network azure-mgmt-resource azure-mgmt-storage
    
  • 验证CLI认证有效性
    你的inventory配置使用auth_source: cli,确保Azure CLI已正确登录并有权限访问目标资源组:

    az account show
    

    如果未登录,执行az login完成认证。

  • 重新测试inventory解析
    再次运行原命令验证:

    ansible-inventory -i inventory_azure_rm.yml --graph -vv
    
  • 额外检查(若问题仍存在)

    1. 确认ansible.cfg中未错误限制inventory插件路径,默认安装集合后插件会被自动识别;
    2. 检查inventory文件的缩进是否符合YAML规范(你的当前配置缩进是正确的,但可再次确认);
    3. 若使用的Ansible版本过低(如2.12.x),尝试升级到较新版本(如2.15+)以获得更好的兼容性。

内容的提问来源于stack exchange,提问作者N Hunt

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 19:25:06