gpt4 book ai didi

git - 使用私有(private) git 角色依赖的 Ansible 剧本

转载 作者:太空狗 更新时间:2023-10-29 13:03:11 26 4
gpt4 key购买 nike

我在使用一组私有(private)角色(即私有(private) git 存储库中的 Ansible 角色)运行 Ansible 剧本时遇到问题。

例如,我有一个使用角色 base 的剧本,它依赖于 dep,两者都托管在私有(private) 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

有没有办法正确使用私有(private)仓库中的角色依赖?

最佳答案

看起来这是 1.9 中的错误。我创建了一个 PR ( https://github.com/ansible/ansible/pull/13802 ),但我怀疑它是否会被 merge ,因为 Ansible 2.0 刚刚发布。

关于git - 使用私有(private) git 角色依赖的 Ansible 剧本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34678870/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com