我遇到了一个问题,无法运行带有一组私有角色的 Ansible playbook(即,存储在私有 Git 仓库中的 Ansible 角色)。
例如,我有一个 playbook 使用了名为
有没有一种正确使用私有仓库中角色依赖的方法?
例如,我有一个 playbook 使用了名为
base
的角色,它依赖于 dep
角色,这两个角色都存储在私有 git 仓库中。运行 ansible-galaxy
可以正确地提取和安装所有角色和依赖项,但之后 ansible-playbook
却无法使用正确的角色名称。
play.yml
- hosts: test
roles:
- role: base
requirements.yml
- name: base
src: ssh://git@10.0.0.1/ansible/role-base.git
scm: git
role-base/meta/main.yml
galaxy-info:
author: Me
description: Test Ansible role dependencies
min_ansible_version: 1.9
platforms: Ubuntu
dependencies:
- name: dep
src: ssh://git@10.0.0.1/ansible/role-dep.git
scm: git
$ ansible-galaxy -r requirements.yml
- executing: git clone ssh://git@10.0.0.1/ansible/role-base.git base
- executing: git archive --prefix=base/ --output=/tmp/tmp4YKG7a.tar
- extracting base to ansible-roles/base
- base was installed successfully
- adding dependency: dep
- executing: git clone ssh://git@10.0.0.1/ansible/role-dep.git dep
- executing: git archive --prefix=dep/ --output=/tmp/tmpT2YiW4.tar
- extracting base to ansible-roles/dep
- dep was installed successfully
$ ansible-playbook play.yml
ERROR: expected a role name in dictionary: {'scm': 'git', 'src': 'ssh://git@10.0.0.1/ansible/role-dep.git', 'name': 'dep'}
我尝试使用替代角色名称系统作为依赖项:
dependencies:
- role: "git+ssh://git@10.0.0.1/ansible/role-dep.git,,dep"
这对于ansible-galaxy
来说是可以接受的,但是ansible-playbook
仍然失败了...
$ ansible-galaxy -r requirements.yml
- executing: git clone ssh://git@10.0.0.1/ansible/role-base.git base
- executing: git archive --prefix=base/ --output=/tmp/tmpTcvpDu.tar
- extracting base to ansible-roles/base
- base was installed successfully
- adding dependency: dep
- executing: git clone ssh://git@10.0.0.1/ansible/role-dep.git dep
- executing: git archive --prefix=dep/ --output=/tmp/tmpd726OV.tar
- extracting base to ansible-roles/dep
- dep was installed successfully
$ ansible-playbook play.yml
ERROR: cannot find role in <pwd>/roles/git+ssh://git@10.0.0.1/ansible/role-dep.git,,dep or <pwd>/git+ssh://git@10.0.0.1/ansible/role-dep.git,,dep or <pwd>/ansible-roles/git+ssh://git@10.0.0.1/ansible/role-dep.git,,dep
有没有一种正确使用私有仓库中角色依赖的方法?