gpt4 book ai didi

ansible - 如何自动安装 Ansible Galaxy 角色?

转载 作者:行者123 更新时间:2023-12-03 04:38:53 25 4
gpt4 key购买 nike

我所有的 Ansible 剧本/角色都已 checkin 我的 git 存储库。

但是,对于 Ansible Galaxy 角色,我始终必须在我想要运行 Ansible 的每台计算机上明确地一一下载它们。

在 Ansible 提示运行时缺少角色之前,甚至很难提前确切地知道需要哪些 Ansible Galaxy 角色。

如何管理 Ansible Galaxy 角色依赖性?我想让它们与我的 Ansible 代码的其余部分一起 checkin 我的 git 存储库,或者当我在新机器上运行 Ansible 时自动识别和下载它们。

最佳答案

对于此用例,您应该使用 requirements.yml 文件。使用各种安装方法中的任何一种来描述您所需的角色:

# Install a role from the Ansible Galaxy
- src: dfarrell07.opendaylight

# Install a role from GitHub
- name: opendaylight
src: https://github.com/dfarrell07/ansible-opendaylight

# Install a role from a specific git branch
- name: opendaylight
src: https://github.com/dfarrell07/ansible-opendaylight
version: origin/master

# Install a role at a specific tag from GitHub
- name: opendaylight
src: https://github.com/dfarrell07/ansible-opendaylight
version: 1.0.0

# Install a role at a specific commit from GitHub
- name: opendaylight
src: https://github.com/dfarrell07/ansible-opendaylight
version: <commit hash>

然后安装它们:

ansible-galaxy install -r requirements.yml

这是一个working example (使用 Ansible 作为 Vagrant 配置程序安装 OpenDaylight)。请参阅relevant Ansible docs了解更多信息。

关于ansible - 如何自动安装 Ansible Galaxy 角色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25230376/

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