我可以在私有git仓库中添加角色作为Ansible中的元/依赖吗?

问题描述 投票:0回答:1

我有一堆Ansible角色,我想重用。它们每个都保存在私人BitBucket的回购中。

我希望将我在Git中托管的项目添加为我正在处理的角色的元/依赖项,但我无法弄清楚语法是什么。

在此非工作示例中,角色需要在运行之前首先使用参数部署另一个角色。

仅供参考,远程角色“acm_layout”旨在为服务器创建标准目录布局,以便在知道所有标准目录已存在的情况下运行我的角色。

---
dependencies:
   - { role: project_keys } # Works fine, just reuses a local role

   - name: acm_layout # Doesn't work, but this is what I want to fix
     src: ssh://[email protected]/acm/acm_layout.git
     scm: git
     version: feature/initialize
     application_storage_dir: "{{base_storage_dir}}"
     application_data_dir: "{{app_data_dir}}"

当我运行这个时,我收到以下错误:

ERROR! the role 'acm_layout' was not found in [lots of paths deleted]

The error appears to have been in '/home/zs5fgzg/_tmp/horizon_deployment_scf/ansible/roles/horizon_layout/meta/main.yaml': line 4, column 6, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

   - { role: horizon_keys }
   - src: ssh://[email protected]:7999/acm/acm_layout.git
     ^ here

那么这样做的正确方法是什么?

ansible
1个回答
1
投票

是的,您可以使用ansible-galaxy install和requirements.yml选项远程获取角色。创建requirements.yml如下

https://github.com/avinash6784/elk-stack/blob/master/requirements.yml

并运行以下命令

$ ansible-galaxy install -r requirements.yml -p roles /

有关如何使用ansible-galaxy获取角色的更多信息,请访问http://docs.ansible.com/ansible/latest/galaxy.html

© www.soinside.com 2019 - 2024. All rights reserved.