ansible galaxy依赖于空meta/main.yml失败
我有一个requirements.yml文件,其中列出了Ansible角色的依赖项:ansible galaxy依赖于空meta/main.yml失败,ansible,ansible-2.x,ansible-galaxy,Ansible,Ansible 2.x,Ansible Galaxy,我有一个requirements.yml文件,其中列出了Ansible角色的依赖项: --- - src: git@gitrepo:group/dependency1.git scm: git name: name1 - src: git@gitrepo:group/dependency1.git scm: git name: name2 这些角色本身没有任何依赖关系,而且由于它们位于专用SCM系统上(除其他原因外),因此不需要任何元数据。但是,加载Ansible依赖项需要
---
- src: git@gitrepo:group/dependency1.git
scm: git
name: name1
- src: git@gitrepo:group/dependency1.git
scm: git
name: name2
这些角色本身没有任何依赖关系,而且由于它们位于专用SCM系统上(除其他原因外),因此不需要任何元数据。但是,加载Ansible依赖项需要此文件存在。因此,依赖项有一个空的meta/main.yml来启用ansible galaxy
使用以下命令安装依赖项时:
ansible-galaxy install --role-file requirements.yml --roles-path foo
安装第一个依赖项后,将出现以下错误:
ERROR! Unexpected Exception: 'NoneType' object has no attribute 'get'
使用非常详细的输出,可以找到错误:
galaxy.py", line 394
经过实验后,再运行几次该命令将逐步通过依赖项,一次一个。因此,嵌套依赖关系将失败;因为要么父级安装后出错,要么ansible galaxy认为父级已安装并跳过依赖项
if not no_deps and installed:
role_dependencies = role.metadata.get('dependencies') or []
...
问题是:如何阻止此错误的发生并让ansible galaxy正确处理我的依赖项?事实证明,一个空白的meta/main.yml不足以处理作为依赖项的角色。我的假设是,如果文件为空,则初始化角色对象时没有元数据字段,如下所示: “角色”在这一行之前使用,因此将是一个实例,而这是第一次提到“元数据” 这段代码是关于安装嵌套依赖项的,因为上面的一行正在进行检查,以确定它是否应该处理嵌套依赖项
if not no_deps and installed:
role_dependencies = role.metadata.get('dependencies') or []
...
如果此行还检查了元数据的存在,例如:
if not no_deps and installed and metadata:
那么,这一节将被(正确地)跳过。但是,由于Ansible没有进行此检查,元数据是“非类型”对象,它实际上没有属性“get”
这意味着meta/main.yml文件中至少需要一个键才能作为依赖项处理。具有以下meta/main.yml文件:
---
galaxy_info:
这就足够了。我只是在devel
中。应使2.4版的Ansible