AWX运行playbook拉取galaxy集合报错name/source无法解析工件
故障现象
在AWX中运行基础playbook时,fetch galaxy collections from collections/requirements.(yml/yaml)任务持续执行失败,报错信息如下:
ERROR! Neither the collection requirement entry key 'name', nor 'source' point to a concrete resolvable collection artifact. Also 'name' is not an FQCN. A valid collection name must be in the format
. . Please make sure that the namespace and the collection name contain characters from [a-zA-Z0-9_] only. Tip: Make sure you are pointing to the right subdirectory — /var/lib/awx/projects/.__awx_cache/_8__testproject/stage/tmp/ansible-local-640q06qxv5r/tmpn_dk6jym/pylibsshmg6_wq45 looks like a directory but it is neither a collection, nor a namespace dir.
环境信息
ansible [core 2.13.1] config file = None configured module search path = ['/Users/garandre/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ansible ansible collection location = /Users/garandre/.ansible/collections:/usr/share/ansible/collections executable location = /Library/Frameworks/Python.framework/Versions/3.10/bin/ansible python version = 3.10.4 (v3.10.4:9d38120e33, Mar 23 2022, 17:29:05) [Clang 13.0.0 (clang-1300.0.29.30)] jinja version = 3.1.2 libyaml = False
原requirements.yml配置
--- collections: - name: https://git@github.com/ansible/pylibssh.git type: git version: '0.4.0' - name: https://git@github.com/ansible-collections/cisco.iosxr type: git version: '3.2.0'
已对照官方Git源安装集合的指引多次排查,问题未解决。
修复方案
- 移除无效的pylibssh配置项:pylibssh是Ansible依赖的Python SSH库,不属于Ansible集合,不能放在collections依赖列表中,直接删除该项。该依赖需要在AWX执行环境镜像中通过pip安装,不要写入collections的requirements文件。报错提示中提到的pylibssh开头的临时目录无法识别为集合,就是这个错误配置导致的。
- 修正Git源集合的字段配置:Ansible core 2.13版本对Git类型集合的配置校验规则收紧,
name字段必须填写符合<命名空间>.<集合名>格式的合法FQCN,Git仓库地址需要填写到独立的source字段,不能直接填在name字段中,否则会触发名称格式校验错误。 - 修正后的配置参考:
--- collections: - name: cisco.iosxr type: git source: cisco.iosxr集合对应的Git仓库地址 version: '3.2.0'
- 补充排查点:如果Git仓库未将集合描述文件
galaxy.yml存放在仓库根目录,需要额外添加路径参数指定集合所在的子目录;配置修正后如果仍拉取失败,依次检查AWX执行环境是否预装git客户端、是否配置了对应Git仓库的访问凭据、网络策略是否允许访问仓库地址。
内容的提问来源于stack exchange,提问作者garrett_17

